Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38114 > unrolled thread

Approach to find out parsed values that goes wrong?

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2020-01-22 21:25 -0800
Last post2020-01-24 21:32 -0800
Articles 20 on this page of 27 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 21:25 -0800
    Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:05 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:10 -0800
        Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:41 -0800
          Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 23:12 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-22 22:27 -0800
    Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-23 04:50 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 06:12 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 06:33 -0800
      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 06:55 -0800
        Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-23 11:48 -0800
          Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 14:54 -0800
            Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 14:58 -0800
              Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 15:00 -0800
                Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-23 15:20 -0800
            Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-23 17:59 -0800
              Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-24 01:03 -0800
                Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-24 05:38 -0800
                  Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-24 11:23 -0800
                    Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-24 17:12 -0800
                      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-25 06:48 -0800
                      Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-26 11:22 -0800
                        Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-26 14:17 -0800
                          Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-26 22:38 -0800
                            Re: Approach to find out parsed values that goes wrong? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-28 05:13 -0800
                              Re: Approach to find out parsed values that goes wrong? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-28 17:35 -0800
                    Re: Approach to find out parsed values that goes wrong? luserdroog <luser.droog@gmail.com> - 2020-01-24 21:32 -0800

Page 1 of 2  [1] 2  Next page →


#38114 — Approach to find out parsed values that goes wrong?

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-22 21:25 -0800
SubjectApproach to find out parsed values that goes wrong?
Message-ID<974481a0-2ccc-43e4-aee3-5075ca956e5c@googlegroups.com>
I am oarsing a file following a format, even made some what an editor for it.
However sometimes the values not expected "bad parsed" at some instance.
But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.

Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.

I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?

I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
I still bomb out try to reparse it for my sequenser.

Seeing that i miss event 3289,3290 in list do not help me that much.
I somehow must find out what they contain.

[toc] | [next] | [standalone]


#38115

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-22 22:05 -0800
Message-ID<75341974-1209-4fb5-aa61-c81443d32c5e@googlegroups.com>
In reply to#38114
Den torsdag 23 januari 2020 kl. 06:25:57 UTC+1 skrev Jonas Thörnvall:
> I am oarsing a file following a format, even made some what an editor for it.
> However sometimes the values not expected "bad parsed" at some instance.
> But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> 
> Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> 
> I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> 
> I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> I still bomb out try to reparse it for my sequenser.
> 
> Seeing that i miss event 3289,3290 in list do not help me that much.
> I somehow must find out what they contain.

Here is the order of blocks of different "message type".
There is things like a channel but does not really matter since a channel can hhave many blocks, but each block consist of these

	parseCC(i);
        parsePitchBend(i);
	parsePrograms(i);
	parseNotes(i);
        //Here is where my code bugs out it seem to incorporate 2? extra event 
        //before next block processed "well the code says channel" but it is 
        //really block since a channel can have many block "that is really 
        //instruments 

My full code to decipher the fork misstake in next post.

Here is the fork where parsing goes wrong when there comes a new block 


  {
          "duration": 3.329729499999985,
          "durationTicks": 1800,
          "midi": 53,
          "name": "F3",
          "ticks": 263160,
          "time": 267.06666610833395,
          "velocity": 0.2755905511811024
        },
        {
          "duration": 3.082417666666572,
          "durationTicks": 1740,
          "midi": 61,
          "name": "C#4",
          "ticks": 263220,
          "time": 267.31397794166736,
          "velocity": 0.33070866141732286
        }
//Here two extra elements seem to be interpretated.
      ]
    },
    {
      "channel": 0,
      "controlChanges": {
        "7": [
          {
            "number": 7,
            "ticks": 0,
            "time": 0,
            "value": 0.7874015748031497
          }
        ],
        "10": [
          {
            "number": 10,
            "ticks": 0,
            "time": 0,
            "value": 0.5039370078740157
          }
        ],

[toc] | [prev] | [next] | [standalone]


#38116

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-22 22:10 -0800
Message-ID<68a08d9a-d78b-4fcf-b9a7-4c0f0ee7e324@googlegroups.com>
In reply to#38115
Den torsdag 23 januari 2020 kl. 07:05:55 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 06:25:57 UTC+1 skrev Jonas Thörnvall:
> > I am oarsing a file following a format, even made some what an editor for it.
> > However sometimes the values not expected "bad parsed" at some instance.
> > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > 
> > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > 
> > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > 
> > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > I still bomb out try to reparse it for my sequenser.
> > 
> > Seeing that i miss event 3289,3290 in list do not help me that much.
> > I somehow must find out what they contain.
> 
> Here is the order of blocks of different "message type".
> There is things like a channel but does not really matter since a channel can hhave many blocks, but each block consist of these
> 
> 	parseCC(i);
>         parsePitchBend(i);
> 	parsePrograms(i);
> 	parseNotes(i);
>         //Here is where my code bugs out it seem to incorporate 2? extra event 
>         //before next block processed "well the code says channel" but it is 
>         //really block since a channel can have many block "that is really 
>         //instruments 
> 
> My full code to decipher the fork misstake in next post.
> 
> Here is the fork where parsing goes wrong when there comes a new block 
> 
> 
>   {
>           "duration": 3.329729499999985,
>           "durationTicks": 1800,
>           "midi": 53,
>           "name": "F3",
>           "ticks": 263160,
>           "time": 267.06666610833395,
>           "velocity": 0.2755905511811024
>         },
>         {
>           "duration": 3.082417666666572,
>           "durationTicks": 1740,
>           "midi": 61,
>           "name": "C#4",
>           "ticks": 263220,
>           "time": 267.31397794166736,
>           "velocity": 0.33070866141732286
>         }
> //Here two extra elements seem to be interpretated.
>       ]
>     },
>     {
>       "channel": 0,
>       "controlChanges": {
>         "7": [
>           {
>             "number": 7,
>             "ticks": 0,
>             "time": 0,
>             "value": 0.7874015748031497
>           }
>         ],
>         "10": [
>           {
>             "number": 10,
>             "ticks": 0,
>             "time": 0,
>             "value": 0.5039370078740157
>           }
>         ],

// THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE STARTS
function reparseMidi(){
	console.log("reparseMidi");
	document.getElementById("keystream").value="";
	track=[];
	makeTrack();
	document.getElementById("keystream").value=importedMidi;
	myChannels = importedMidi.split("channel");
	parseInfo();
	for (var i=1;i<myChannels.length;i++){
		//EXTRACT EACH CHANNEL
		console.log("****** NEW CHANNEL *********");
		channelStart=myChannels[i].indexOf(":");
		channelEnd=myChannels[i].indexOf(",");
		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
		importChannel=parseInt(importChannel);
		activetrack=importChannel+1;
		document.getElementById("track").value=activetrack;
		console.log("ActiveTrack= "+activetrack);
		
		//There can be more "channel posts/objects" then one, on same channel
		alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
		parseCC(i);
		parsePitchBend(i);
		parsePrograms(i);
		parseNotes(i);
		track[activetrack].midiMess.sort(dynamicSort("time"));
	}	
	
	maxtrack=16;
	downMixALLEventList();
	getNoteTicks(activetrack);
	console.log("****** Finished import *********");
	//Set to track 1 and close menu
	document.getElementById("track").value=1;
	changeTrack();
	MA();
}


function parseInfo(){
	impPPQStart=myChannels[0].indexOf('"ppq": ')+7;
	impPPQEnd=myChannels[0].indexOf('"tempos":');
	impPPQ=myChannels[0].substring(impPPQStart,impPPQEnd);
	impPPQ=impPPQ.replace(",",""); 
	impPPQ=parseInt(impPPQ);
	document.getElementById("ppq").value=impPPQ;
	impBPMStart=myChannels[0].indexOf('"tempos": [');
    impBPMEnd=myChannels[0].indexOf('"timeSignatures"');
	impBPM=myChannels[0].substring(impBPMStart,impBPMEnd);
	impBPM=impBPM.replace(",",""); 
	BPMS=impBPM.split("bpm");
	TICKS=impBPM.split("ticks");
	for (var i=1;i<BPMS.length;i++){
		BPMsplit(i);
		TICKsplit(i);
	}
}

function TICKsplit(IN){
	TICKstart=TICKS[IN].indexOf('":')+2;
	TICKend=TICKS[IN].indexOf('}');
	TICKS[IN]=TICKS[IN].substring(TICKstart,TICKend);
	TICKS[IN]=TICKS[IN].replace(",",""); 
	//alert(TICKS[IN]);
}

function BPMsplit(IN){
	BPMstart=BPMS[IN].indexOf(':"')+4;
	BPMend=BPMS[IN].indexOf('"ticks"');
	BPMS[IN]=BPMS[IN].substring(BPMstart,BPMend);
	BPMS[IN]=BPMS[IN].replace(",",""); 
	BPMS[IN]=parseFloat(BPMS[IN]);	
	document.getElementById("bpm").value=BPMS[IN];
	getFormNoteTime();
	//alert(BPMS[IN]);
}

function parseCC(IC){
	impCCStart=myChannels[IC].indexOf('"tracks"');
    impCCEnd=myChannels[IC].indexOf('"pitchBends"');
	impCC=myChannels[IC].substring(impCCStart,impCCEnd);
	//console.log("impCC"+impCC);
	CCpart=impCC.split("[");
	for (var i=1; i <CCpart.length;i++){
	//	console.log("CC="+CCpart[i]);
		CCsplit(i);
	}
}


function parsePitchBend(PB){
	
	
}

function parsePrograms(IP){
	evtype = myChannels[IP].split("instrument");
	console.log("MidiChannel="+activetrack+" Nr of instruments="+evtype.length);
	for (var i=1; i <evtype.length;i++){
		impPRStart=evtype[i].indexOf('"number":')+9;
		impPREnd=evtype[i].indexOf('},');
		impPR=evtype[i].substring(impPRStart,impPREnd);
		impPR=impPR.trim();
		PRChan=191+activetrack;
		//alert("start"+impPR);
		activetrack=parseInt(activetrack);
		track[activetrack].midiMess.push({
			time: 0,
			data0:PRChan,
			data1:impPR,
		});
	}
}

function parseNotes(IC){
	evtype = myChannels[IC].split("notes");
	impNote=evtype[1].split("},");
	for (var i=0; i <impNote.length;i++){
		noteSplit(i);
	}
}

function CCsplit(IN){
	CCStartNumber=CCpart[IN].indexOf('"number":')+9;
    CCEndNumber=CCpart[IN].indexOf('"ticks"');
	CCNumber=CCpart[IN].substring(CCStartNumber,CCEndNumber);
	CCNumber=CCNumber.replace(",",""); 
	CCNumber=parseInt(CCNumber);
		
	CCStartTick=CCpart[IN].indexOf('"ticks":')+9;
    CCEndTick=CCpart[IN].indexOf('"time"');
	CCTick=CCpart[IN].substring(CCStartTick,CCEndTick);
	CCTick=CCTick.replace(",",""); 
	CCTick=parseInt(CCTick);
	//alert("CC tick "+CCTick); This should be used later to recalculate time at other BPM
	
	CCStartTime=CCpart[IN].indexOf('"time":')+7;
    CCEndTime=CCpart[IN].indexOf('"value"');
	CCTime=CCpart[IN].substring(CCStartTime,CCEndTime);
	CCTime=CCTime.replace(",",""); 
	CCTime=parseFloat(CCTime*1000);
	
	CCStartValue=CCpart[IN].indexOf('"value":')+9;
	CCEndValue=CCpart[IN].indexOf('}');
	CCEValue=CCpart[IN].substring(CCStartValue,CCEndValue);
	CCEValue=CCEValue.replace(",",""); 
	CCEValue=Math.round(CCEValue*127);
		
	CCchan=176+importChannel;
	CCchan=parseInt(CCchan);
		
	//alert("CC time "+CCTime+" CC number "+CCNumber+" CC chanel "+CCchan+" CC value "+CCEValue);
	pushCC(IN);
}

function pushCC(IN){
	if (CCNumber!=11 && CCNumber!=0 && CCNumber!=32 && CCNumber!=121 ){
		//track[activetrack].eventTicks.push(CCTick);
		track[activetrack].midiMess.push({
			time: CCTime,
			data0:CCchan,
			data1:CCNumber,
			data2:CCEValue
		});
	}
 // console.log ("Event="+midiMess.length+" Time "+track[activetrack].midiMess[midiMess.length].time +" data0 "+track[activetrack].midiMess[midiMess.length].data0+" data1 "+track[activetrack].midiMess[midiMess.length].data1+" data2 "+track[activetrack].midiMess[midiMess.length].data2);  
}

function noteSplit(IN){
	impStartTick=impNote[IN].indexOf('"ticks":')+9;
    impEndTick=impNote[IN].indexOf('"time"');
	impTick=impNote[IN].substring(impStartTick,impEndTick);
	impTick=impTick.replace(",",""); 
	impTick=parseInt(impTick);
	//alert("imptick="+impTick);
	
	durStartTick=impNote[IN].indexOf('Ticks":')+7;
    durEndTick=impNote[IN].indexOf('"midi');
	durTick=impNote[IN].substring(durStartTick,durEndTick);
	durTick=durTick.replace(",",""); 
	durTick=parseInt(durTick);
	
	endTick=impTick+durTick;
	//alert(endTick);
		
	impTimeStart=impNote[IN].indexOf('"time": ')+8;
	impTimeEnd=impNote[IN].indexOf('"velocity":');
	impTime=impNote[IN].substring(impTimeStart,impTimeEnd);
	impTime=impTime.replace(",",""); 
    impTime=parseFloat(impTime*1000);
	
	impNoteStart=impNote[IN].indexOf('"midi": ')+8;
	impNoteEnd=impNote[IN].indexOf('"name":');
	impKey=impNote[IN].substring(impNoteStart,impNoteEnd);
	impKey=impKey.replace(",",""); 
	impKey=impKey.replace(".",""); 
	impKey=impKey.trim();
	impKey=parseInt(impKey);
	
	
	impDurationStart=impNote[IN].indexOf('"duration": ')+12;
	impDurationEnd=impNote[IN].indexOf('"durationTicks":');
	impDuration=impNote[IN].substring(impDurationStart,impDurationEnd);
	impDuration=impDuration.replace(",",""); 
	impDuration=parseFloat(impDuration*1000);
	
	impVelocityStart=impNote[IN].indexOf('"velocity": ')+12;
	impVelocityEnd=impNote[IN].indexOf("},"	);
	impVelocity=impNote[IN].substring(impVelocityStart,impNote[IN].length);
	impVelocity=Math.round(impVelocity*127);
		
	impOffTime=impTime+impDuration;
	NoteOffChan=128+importChannel;
	NoteOnChan=144+importChannel;
	pushNote(IN);
	
}

function pushNote(IN){
	//if (activetrack==2){alert("channel 2");}
 // track[activetrack].eventTicks.push(impTick);	
  track[activetrack].midiMess.push({
      time: impTime,
      data0:NoteOnChan,
      data1:impKey,
      data2:impVelocity
  });
 // console.log ("Event="+IN+" Time "+track[activetrack].midiMess[IN].time +" data0 "+track[activetrack].midiMess[IN].data0+" data1 "+track[activetrack].midiMess[IN].data1+" data2 "+track[activetrack].midiMess[IN].data2);  
// track[activetrack].eventTicks.push(endTick);
 track[activetrack].midiMess.push({
      time: impOffTime,
      data0:NoteOffChan,
      data1:impKey,
  });
// IN=IN+1;
// console.log ("Event="+IN+" Time "+track[activetrack].midiMess[IN+1].time +" data0 "+track[activetrack].midiMess[IN+1].data0+" data1 "+track[activetrack].midiMess[IN+1].data1+" data2 "+track[activetrack].midiMess[IN+1].data2);  
}

[toc] | [prev] | [next] | [standalone]


#38118

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-22 22:41 -0800
Message-ID<e4a52db6-038c-43ca-afab-e01dbe93290d@googlegroups.com>
In reply to#38116
Den torsdag 23 januari 2020 kl. 07:10:09 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 07:05:55 UTC+1 skrev Jonas Thörnvall:
> > Den torsdag 23 januari 2020 kl. 06:25:57 UTC+1 skrev Jonas Thörnvall:
> > > I am oarsing a file following a format, even made some what an editor for it.
> > > However sometimes the values not expected "bad parsed" at some instance.
> > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > 
> > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > 
> > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > 
> > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > I still bomb out try to reparse it for my sequenser.
> > > 
> > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > I somehow must find out what they contain.
> > 
> > Here is the order of blocks of different "message type".
> > There is things like a channel but does not really matter since a channel can hhave many blocks, but each block consist of these
> > 
> > 	parseCC(i);
> >         parsePitchBend(i);
> > 	parsePrograms(i);
> > 	parseNotes(i);
> >         //Here is where my code bugs out it seem to incorporate 2? extra event 
> >         //before next block processed "well the code says channel" but it is 
> >         //really block since a channel can have many block "that is really 
> >         //instruments 
> > 
> > My full code to decipher the fork misstake in next post.
> > 
> > Here is the fork where parsing goes wrong when there comes a new block 
> > 
> > 
> >   {
> >           "duration": 3.329729499999985,
> >           "durationTicks": 1800,
> >           "midi": 53,
> >           "name": "F3",
> >           "ticks": 263160,
> >           "time": 267.06666610833395,
> >           "velocity": 0.2755905511811024
> >         },
> >         {
> >           "duration": 3.082417666666572,
> >           "durationTicks": 1740,
> >           "midi": 61,
> >           "name": "C#4",
> >           "ticks": 263220,
> >           "time": 267.31397794166736,
> >           "velocity": 0.33070866141732286
> >         }
> > //Here two extra elements seem to be interpretated.
> >       ]
> >     },
> >     {
> >       "channel": 0,
> >       "controlChanges": {
> >         "7": [
> >           {
> >             "number": 7,
> >             "ticks": 0,
> >             "time": 0,
> >             "value": 0.7874015748031497
> >           }
> >         ],
> >         "10": [
> >           {
> >             "number": 10,
> >             "ticks": 0,
> >             "time": 0,
> >             "value": 0.5039370078740157
> >           }
> >         ],
> 
> // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE STARTS
> function reparseMidi(){
> 	console.log("reparseMidi");
> 	document.getElementById("keystream").value="";
> 	track=[];
> 	makeTrack();
> 	document.getElementById("keystream").value=importedMidi;
> 	myChannels = importedMidi.split("channel");
> 	parseInfo();
> 	for (var i=1;i<myChannels.length;i++){
> 		//EXTRACT EACH CHANNEL
> 		console.log("****** NEW CHANNEL *********");
> 		channelStart=myChannels[i].indexOf(":");
> 		channelEnd=myChannels[i].indexOf(",");
> 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> 		importChannel=parseInt(importChannel);
> 		activetrack=importChannel+1;
> 		document.getElementById("track").value=activetrack;
> 		console.log("ActiveTrack= "+activetrack);
> 		
> 		//There can be more "channel posts/objects" then one, on same channel
> 		alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> 		parseCC(i);
> 		parsePitchBend(i);
> 		parsePrograms(i);
> 		parseNotes(i);
> 		track[activetrack].midiMess.sort(dynamicSort("time"));
> 	}	
> 	
> 	maxtrack=16;
> 	downMixALLEventList();
> 	getNoteTicks(activetrack);
> 	console.log("****** Finished import *********");
> 	//Set to track 1 and close menu
> 	document.getElementById("track").value=1;
> 	changeTrack();
> 	MA();
> }
> 
> 
> function parseInfo(){
> 	impPPQStart=myChannels[0].indexOf('"ppq": ')+7;
> 	impPPQEnd=myChannels[0].indexOf('"tempos":');
> 	impPPQ=myChannels[0].substring(impPPQStart,impPPQEnd);
> 	impPPQ=impPPQ.replace(",",""); 
> 	impPPQ=parseInt(impPPQ);
> 	document.getElementById("ppq").value=impPPQ;
> 	impBPMStart=myChannels[0].indexOf('"tempos": [');
>     impBPMEnd=myChannels[0].indexOf('"timeSignatures"');
> 	impBPM=myChannels[0].substring(impBPMStart,impBPMEnd);
> 	impBPM=impBPM.replace(",",""); 
> 	BPMS=impBPM.split("bpm");
> 	TICKS=impBPM.split("ticks");
> 	for (var i=1;i<BPMS.length;i++){
> 		BPMsplit(i);
> 		TICKsplit(i);
> 	}
> }
> 
> function TICKsplit(IN){
> 	TICKstart=TICKS[IN].indexOf('":')+2;
> 	TICKend=TICKS[IN].indexOf('}');
> 	TICKS[IN]=TICKS[IN].substring(TICKstart,TICKend);
> 	TICKS[IN]=TICKS[IN].replace(",",""); 
> 	//alert(TICKS[IN]);
> }
> 
> function BPMsplit(IN){
> 	BPMstart=BPMS[IN].indexOf(':"')+4;
> 	BPMend=BPMS[IN].indexOf('"ticks"');
> 	BPMS[IN]=BPMS[IN].substring(BPMstart,BPMend);
> 	BPMS[IN]=BPMS[IN].replace(",",""); 
> 	BPMS[IN]=parseFloat(BPMS[IN]);	
> 	document.getElementById("bpm").value=BPMS[IN];
> 	getFormNoteTime();
> 	//alert(BPMS[IN]);
> }
> 
> function parseCC(IC){
> 	impCCStart=myChannels[IC].indexOf('"tracks"');
>     impCCEnd=myChannels[IC].indexOf('"pitchBends"');
> 	impCC=myChannels[IC].substring(impCCStart,impCCEnd);
> 	//console.log("impCC"+impCC);
> 	CCpart=impCC.split("[");
> 	for (var i=1; i <CCpart.length;i++){
> 	//	console.log("CC="+CCpart[i]);
> 		CCsplit(i);
> 	}
> }
> 
> 
> function parsePitchBend(PB){
> 	
> 	
> }
> 
> function parsePrograms(IP){
> 	evtype = myChannels[IP].split("instrument");
> 	console.log("MidiChannel="+activetrack+" Nr of instruments="+evtype.length);
> 	for (var i=1; i <evtype.length;i++){
> 		impPRStart=evtype[i].indexOf('"number":')+9;
> 		impPREnd=evtype[i].indexOf('},');
> 		impPR=evtype[i].substring(impPRStart,impPREnd);
> 		impPR=impPR.trim();
> 		PRChan=191+activetrack;
> 		//alert("start"+impPR);
> 		activetrack=parseInt(activetrack);
> 		track[activetrack].midiMess.push({
> 			time: 0,
> 			data0:PRChan,
> 			data1:impPR,
> 		});
> 	}
> }
> 
> function parseNotes(IC){
> 	evtype = myChannels[IC].split("notes");
> 	impNote=evtype[1].split("},");
> 	for (var i=0; i <impNote.length;i++){
> 		noteSplit(i);
> 	}
> }
> 
> function CCsplit(IN){
> 	CCStartNumber=CCpart[IN].indexOf('"number":')+9;
>     CCEndNumber=CCpart[IN].indexOf('"ticks"');
> 	CCNumber=CCpart[IN].substring(CCStartNumber,CCEndNumber);
> 	CCNumber=CCNumber.replace(",",""); 
> 	CCNumber=parseInt(CCNumber);
> 		
> 	CCStartTick=CCpart[IN].indexOf('"ticks":')+9;
>     CCEndTick=CCpart[IN].indexOf('"time"');
> 	CCTick=CCpart[IN].substring(CCStartTick,CCEndTick);
> 	CCTick=CCTick.replace(",",""); 
> 	CCTick=parseInt(CCTick);
> 	//alert("CC tick "+CCTick); This should be used later to recalculate time at other BPM
> 	
> 	CCStartTime=CCpart[IN].indexOf('"time":')+7;
>     CCEndTime=CCpart[IN].indexOf('"value"');
> 	CCTime=CCpart[IN].substring(CCStartTime,CCEndTime);
> 	CCTime=CCTime.replace(",",""); 
> 	CCTime=parseFloat(CCTime*1000);
> 	
> 	CCStartValue=CCpart[IN].indexOf('"value":')+9;
> 	CCEndValue=CCpart[IN].indexOf('}');
> 	CCEValue=CCpart[IN].substring(CCStartValue,CCEndValue);
> 	CCEValue=CCEValue.replace(",",""); 
> 	CCEValue=Math.round(CCEValue*127);
> 		
> 	CCchan=176+importChannel;
> 	CCchan=parseInt(CCchan);
> 		
> 	//alert("CC time "+CCTime+" CC number "+CCNumber+" CC chanel "+CCchan+" CC value "+CCEValue);
> 	pushCC(IN);
> }
> 
> function pushCC(IN){
> 	if (CCNumber!=11 && CCNumber!=0 && CCNumber!=32 && CCNumber!=121 ){
> 		//track[activetrack].eventTicks.push(CCTick);
> 		track[activetrack].midiMess.push({
> 			time: CCTime,
> 			data0:CCchan,
> 			data1:CCNumber,
> 			data2:CCEValue
> 		});
> 	}
>  // console.log ("Event="+midiMess.length+" Time "+track[activetrack].midiMess[midiMess.length].time +" data0 "+track[activetrack].midiMess[midiMess.length].data0+" data1 "+track[activetrack].midiMess[midiMess.length].data1+" data2 "+track[activetrack].midiMess[midiMess.length].data2);  
> }
> 
> function noteSplit(IN){
> 	impStartTick=impNote[IN].indexOf('"ticks":')+9;
>     impEndTick=impNote[IN].indexOf('"time"');
> 	impTick=impNote[IN].substring(impStartTick,impEndTick);
> 	impTick=impTick.replace(",",""); 
> 	impTick=parseInt(impTick);
> 	//alert("imptick="+impTick);
> 	
> 	durStartTick=impNote[IN].indexOf('Ticks":')+7;
>     durEndTick=impNote[IN].indexOf('"midi');
> 	durTick=impNote[IN].substring(durStartTick,durEndTick);
> 	durTick=durTick.replace(",",""); 
> 	durTick=parseInt(durTick);
> 	
> 	endTick=impTick+durTick;
> 	//alert(endTick);
> 		
> 	impTimeStart=impNote[IN].indexOf('"time": ')+8;
> 	impTimeEnd=impNote[IN].indexOf('"velocity":');
> 	impTime=impNote[IN].substring(impTimeStart,impTimeEnd);
> 	impTime=impTime.replace(",",""); 
>     impTime=parseFloat(impTime*1000);
> 	
> 	impNoteStart=impNote[IN].indexOf('"midi": ')+8;
> 	impNoteEnd=impNote[IN].indexOf('"name":');
> 	impKey=impNote[IN].substring(impNoteStart,impNoteEnd);
> 	impKey=impKey.replace(",",""); 
> 	impKey=impKey.replace(".",""); 
> 	impKey=impKey.trim();
> 	impKey=parseInt(impKey);
> 	
> 	
> 	impDurationStart=impNote[IN].indexOf('"duration": ')+12;
> 	impDurationEnd=impNote[IN].indexOf('"durationTicks":');
> 	impDuration=impNote[IN].substring(impDurationStart,impDurationEnd);
> 	impDuration=impDuration.replace(",",""); 
> 	impDuration=parseFloat(impDuration*1000);
> 	
> 	impVelocityStart=impNote[IN].indexOf('"velocity": ')+12;
> 	impVelocityEnd=impNote[IN].indexOf("},"	);
> 	impVelocity=impNote[IN].substring(impVelocityStart,impNote[IN].length);
> 	impVelocity=Math.round(impVelocity*127);
> 		
> 	impOffTime=impTime+impDuration;
> 	NoteOffChan=128+importChannel;
> 	NoteOnChan=144+importChannel;
> 	pushNote(IN);
> 	
> }
> 
> function pushNote(IN){
> 	//if (activetrack==2){alert("channel 2");}
>  // track[activetrack].eventTicks.push(impTick);	
>   track[activetrack].midiMess.push({
>       time: impTime,
>       data0:NoteOnChan,
>       data1:impKey,
>       data2:impVelocity
>   });
>  // console.log ("Event="+IN+" Time "+track[activetrack].midiMess[IN].time +" data0 "+track[activetrack].midiMess[IN].data0+" data1 "+track[activetrack].midiMess[IN].data1+" data2 "+track[activetrack].midiMess[IN].data2);  
> // track[activetrack].eventTicks.push(endTick);
>  track[activetrack].midiMess.push({
>       time: impOffTime,
>       data0:NoteOffChan,
>       data1:impKey,
>   });
> // IN=IN+1;
> // console.log ("Event="+IN+" Time "+track[activetrack].midiMess[IN+1].time +" data0 "+track[activetrack].midiMess[IN+1].data0+" data1 "+track[activetrack].midiMess[IN+1].data1+" data2 "+track[activetrack].midiMess[IN+1].data2);  
> }

If you want to try yourself, how it fail.
https://midisequenser.000webhostapp.com/

It so weird it render real nice, because it use time to render and really do not care about missed notes however to be played the events have to be ordered. And since my parsing bug make it impossible to sort. It will only play right hand piano, but this is of course true for any song that hold more then one "instrument" on a channel. Well maybe even true for any song that holde more then one channel.

But the channels/tracks render perfectly och each track "always something". To play them up in correct order.....

Well you need to sort them which seem impossible.

Here is the midifile i used, probably should had found a smaller one. But it get the bug using only single channel with two instruments/hands.

http://www.piano-midi.de/midis/chopin/chpn_op66.mid

[toc] | [prev] | [next] | [standalone]


#38119

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-22 23:12 -0800
Message-ID<9d360b44-a090-435b-b589-2c8fb451741d@googlegroups.com>
In reply to#38118
Den torsdag 23 januari 2020 kl. 07:42:02 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 07:10:09 UTC+1 skrev Jonas Thörnvall:
> > Den torsdag 23 januari 2020 kl. 07:05:55 UTC+1 skrev Jonas Thörnvall:
> > > Den torsdag 23 januari 2020 kl. 06:25:57 UTC+1 skrev Jonas Thörnvall:
> > > > I am oarsing a file following a format, even made some what an editor for it.
> > > > However sometimes the values not expected "bad parsed" at some instance.
> > > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > > 
> > > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > > 
> > > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > > 
> > > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > > I still bomb out try to reparse it for my sequenser.
> > > > 
> > > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > > I somehow must find out what they contain.
> > > 
> > > Here is the order of blocks of different "message type".
> > > There is things like a channel but does not really matter since a channel can hhave many blocks, but each block consist of these
> > > 
> > > 	parseCC(i);
> > >         parsePitchBend(i);
> > > 	parsePrograms(i);
> > > 	parseNotes(i);
> > >         //Here is where my code bugs out it seem to incorporate 2? extra event 
> > >         //before next block processed "well the code says channel" but it is 
> > >         //really block since a channel can have many block "that is really 
> > >         //instruments 
> > > 
> > > My full code to decipher the fork misstake in next post.
> > > 
> > > Here is the fork where parsing goes wrong when there comes a new block 
> > > 
> > > 
> > >   {
> > >           "duration": 3.329729499999985,
> > >           "durationTicks": 1800,
> > >           "midi": 53,
> > >           "name": "F3",
> > >           "ticks": 263160,
> > >           "time": 267.06666610833395,
> > >           "velocity": 0.2755905511811024
> > >         },
> > >         {
> > >           "duration": 3.082417666666572,
> > >           "durationTicks": 1740,
> > >           "midi": 61,
> > >           "name": "C#4",
> > >           "ticks": 263220,
> > >           "time": 267.31397794166736,
> > >           "velocity": 0.33070866141732286
> > >         }
> > > //Here two extra elements seem to be interpretated.
> > >       ]
> > >     },
> > >     {
> > >       "channel": 0,
> > >       "controlChanges": {
> > >         "7": [
> > >           {
> > >             "number": 7,
> > >             "ticks": 0,
> > >             "time": 0,
> > >             "value": 0.7874015748031497
> > >           }
> > >         ],
> > >         "10": [
> > >           {
> > >             "number": 10,
> > >             "ticks": 0,
> > >             "time": 0,
> > >             "value": 0.5039370078740157
> > >           }
> > >         ],
> > 
> > // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE STARTS
> > function reparseMidi(){
> > 	console.log("reparseMidi");
> > 	document.getElementById("keystream").value="";
> > 	track=[];
> > 	makeTrack();
> > 	document.getElementById("keystream").value=importedMidi;
> > 	myChannels = importedMidi.split("channel");
> > 	parseInfo();
> > 	for (var i=1;i<myChannels.length;i++){
> > 		//EXTRACT EACH CHANNEL
> > 		console.log("****** NEW CHANNEL *********");
> > 		channelStart=myChannels[i].indexOf(":");
> > 		channelEnd=myChannels[i].indexOf(",");
> > 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> > 		importChannel=parseInt(importChannel);
> > 		activetrack=importChannel+1;
> > 		document.getElementById("track").value=activetrack;
> > 		console.log("ActiveTrack= "+activetrack);
> > 		
> > 		//There can be more "channel posts/objects" then one, on same channel
> > 		alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> > 		parseCC(i);
> > 		parsePitchBend(i);
> > 		parsePrograms(i);
> > 		parseNotes(i);
> > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > 	}	
> > 	
> > 	maxtrack=16;
> > 	downMixALLEventList();
> > 	getNoteTicks(activetrack);
> > 	console.log("****** Finished import *********");
> > 	//Set to track 1 and close menu
> > 	document.getElementById("track").value=1;
> > 	changeTrack();
> > 	MA();
> > }
> > 
> > 
> > function parseInfo(){
> > 	impPPQStart=myChannels[0].indexOf('"ppq": ')+7;
> > 	impPPQEnd=myChannels[0].indexOf('"tempos":');
> > 	impPPQ=myChannels[0].substring(impPPQStart,impPPQEnd);
> > 	impPPQ=impPPQ.replace(",",""); 
> > 	impPPQ=parseInt(impPPQ);
> > 	document.getElementById("ppq").value=impPPQ;
> > 	impBPMStart=myChannels[0].indexOf('"tempos": [');
> >     impBPMEnd=myChannels[0].indexOf('"timeSignatures"');
> > 	impBPM=myChannels[0].substring(impBPMStart,impBPMEnd);
> > 	impBPM=impBPM.replace(",",""); 
> > 	BPMS=impBPM.split("bpm");
> > 	TICKS=impBPM.split("ticks");
> > 	for (var i=1;i<BPMS.length;i++){
> > 		BPMsplit(i);
> > 		TICKsplit(i);
> > 	}
> > }
> > 
> > function TICKsplit(IN){
> > 	TICKstart=TICKS[IN].indexOf('":')+2;
> > 	TICKend=TICKS[IN].indexOf('}');
> > 	TICKS[IN]=TICKS[IN].substring(TICKstart,TICKend);
> > 	TICKS[IN]=TICKS[IN].replace(",",""); 
> > 	//alert(TICKS[IN]);
> > }
> > 
> > function BPMsplit(IN){
> > 	BPMstart=BPMS[IN].indexOf(':"')+4;
> > 	BPMend=BPMS[IN].indexOf('"ticks"');
> > 	BPMS[IN]=BPMS[IN].substring(BPMstart,BPMend);
> > 	BPMS[IN]=BPMS[IN].replace(",",""); 
> > 	BPMS[IN]=parseFloat(BPMS[IN]);	
> > 	document.getElementById("bpm").value=BPMS[IN];
> > 	getFormNoteTime();
> > 	//alert(BPMS[IN]);
> > }
> > 
> > function parseCC(IC){
> > 	impCCStart=myChannels[IC].indexOf('"tracks"');
> >     impCCEnd=myChannels[IC].indexOf('"pitchBends"');
> > 	impCC=myChannels[IC].substring(impCCStart,impCCEnd);
> > 	//console.log("impCC"+impCC);
> > 	CCpart=impCC.split("[");
> > 	for (var i=1; i <CCpart.length;i++){
> > 	//	console.log("CC="+CCpart[i]);
> > 		CCsplit(i);
> > 	}
> > }
> > 
> > 
> > function parsePitchBend(PB){
> > 	
> > 	
> > }
> > 
> > function parsePrograms(IP){
> > 	evtype = myChannels[IP].split("instrument");
> > 	console.log("MidiChannel="+activetrack+" Nr of instruments="+evtype.length);
> > 	for (var i=1; i <evtype.length;i++){
> > 		impPRStart=evtype[i].indexOf('"number":')+9;
> > 		impPREnd=evtype[i].indexOf('},');
> > 		impPR=evtype[i].substring(impPRStart,impPREnd);
> > 		impPR=impPR.trim();
> > 		PRChan=191+activetrack;
> > 		//alert("start"+impPR);
> > 		activetrack=parseInt(activetrack);
> > 		track[activetrack].midiMess.push({
> > 			time: 0,
> > 			data0:PRChan,
> > 			data1:impPR,
> > 		});
> > 	}
> > }
> > 
> > function parseNotes(IC){
> > 	evtype = myChannels[IC].split("notes");
> > 	impNote=evtype[1].split("},");
> > 	for (var i=0; i <impNote.length;i++){
> > 		noteSplit(i);
> > 	}
> > }
> > 
> > function CCsplit(IN){
> > 	CCStartNumber=CCpart[IN].indexOf('"number":')+9;
> >     CCEndNumber=CCpart[IN].indexOf('"ticks"');
> > 	CCNumber=CCpart[IN].substring(CCStartNumber,CCEndNumber);
> > 	CCNumber=CCNumber.replace(",",""); 
> > 	CCNumber=parseInt(CCNumber);
> > 		
> > 	CCStartTick=CCpart[IN].indexOf('"ticks":')+9;
> >     CCEndTick=CCpart[IN].indexOf('"time"');
> > 	CCTick=CCpart[IN].substring(CCStartTick,CCEndTick);
> > 	CCTick=CCTick.replace(",",""); 
> > 	CCTick=parseInt(CCTick);
> > 	//alert("CC tick "+CCTick); This should be used later to recalculate time at other BPM
> > 	
> > 	CCStartTime=CCpart[IN].indexOf('"time":')+7;
> >     CCEndTime=CCpart[IN].indexOf('"value"');
> > 	CCTime=CCpart[IN].substring(CCStartTime,CCEndTime);
> > 	CCTime=CCTime.replace(",",""); 
> > 	CCTime=parseFloat(CCTime*1000);
> > 	
> > 	CCStartValue=CCpart[IN].indexOf('"value":')+9;
> > 	CCEndValue=CCpart[IN].indexOf('}');
> > 	CCEValue=CCpart[IN].substring(CCStartValue,CCEndValue);
> > 	CCEValue=CCEValue.replace(",",""); 
> > 	CCEValue=Math.round(CCEValue*127);
> > 		
> > 	CCchan=176+importChannel;
> > 	CCchan=parseInt(CCchan);
> > 		
> > 	//alert("CC time "+CCTime+" CC number "+CCNumber+" CC chanel "+CCchan+" CC value "+CCEValue);
> > 	pushCC(IN);
> > }
> > 
> > function pushCC(IN){
> > 	if (CCNumber!=11 && CCNumber!=0 && CCNumber!=32 && CCNumber!=121 ){
> > 		//track[activetrack].eventTicks.push(CCTick);
> > 		track[activetrack].midiMess.push({
> > 			time: CCTime,
> > 			data0:CCchan,
> > 			data1:CCNumber,
> > 			data2:CCEValue
> > 		});
> > 	}
> >  // console.log ("Event="+midiMess.length+" Time "+track[activetrack].midiMess[midiMess.length].time +" data0 "+track[activetrack].midiMess[midiMess.length].data0+" data1 "+track[activetrack].midiMess[midiMess.length].data1+" data2 "+track[activetrack].midiMess[midiMess.length].data2);  
> > }
> > 
> > function noteSplit(IN){
> > 	impStartTick=impNote[IN].indexOf('"ticks":')+9;
> >     impEndTick=impNote[IN].indexOf('"time"');
> > 	impTick=impNote[IN].substring(impStartTick,impEndTick);
> > 	impTick=impTick.replace(",",""); 
> > 	impTick=parseInt(impTick);
> > 	//alert("imptick="+impTick);
> > 	
> > 	durStartTick=impNote[IN].indexOf('Ticks":')+7;
> >     durEndTick=impNote[IN].indexOf('"midi');
> > 	durTick=impNote[IN].substring(durStartTick,durEndTick);
> > 	durTick=durTick.replace(",",""); 
> > 	durTick=parseInt(durTick);
> > 	
> > 	endTick=impTick+durTick;
> > 	//alert(endTick);
> > 		
> > 	impTimeStart=impNote[IN].indexOf('"time": ')+8;
> > 	impTimeEnd=impNote[IN].indexOf('"velocity":');
> > 	impTime=impNote[IN].substring(impTimeStart,impTimeEnd);
> > 	impTime=impTime.replace(",",""); 
> >     impTime=parseFloat(impTime*1000);
> > 	
> > 	impNoteStart=impNote[IN].indexOf('"midi": ')+8;
> > 	impNoteEnd=impNote[IN].indexOf('"name":');
> > 	impKey=impNote[IN].substring(impNoteStart,impNoteEnd);
> > 	impKey=impKey.replace(",",""); 
> > 	impKey=impKey.replace(".",""); 
> > 	impKey=impKey.trim();
> > 	impKey=parseInt(impKey);
> > 	
> > 	
> > 	impDurationStart=impNote[IN].indexOf('"duration": ')+12;
> > 	impDurationEnd=impNote[IN].indexOf('"durationTicks":');
> > 	impDuration=impNote[IN].substring(impDurationStart,impDurationEnd);
> > 	impDuration=impDuration.replace(",",""); 
> > 	impDuration=parseFloat(impDuration*1000);
> > 	
> > 	impVelocityStart=impNote[IN].indexOf('"velocity": ')+12;
> > 	impVelocityEnd=impNote[IN].indexOf("},"	);
> > 	impVelocity=impNote[IN].substring(impVelocityStart,impNote[IN].length);
> > 	impVelocity=Math.round(impVelocity*127);
> > 		
> > 	impOffTime=impTime+impDuration;
> > 	NoteOffChan=128+importChannel;
> > 	NoteOnChan=144+importChannel;
> > 	pushNote(IN);
> > 	
> > }
> > 
> > function pushNote(IN){
> > 	//if (activetrack==2){alert("channel 2");}
> >  // track[activetrack].eventTicks.push(impTick);	
> >   track[activetrack].midiMess.push({
> >       time: impTime,
> >       data0:NoteOnChan,
> >       data1:impKey,
> >       data2:impVelocity
> >   });
> >  // console.log ("Event="+IN+" Time "+track[activetrack].midiMess[IN].time +" data0 "+track[activetrack].midiMess[IN].data0+" data1 "+track[activetrack].midiMess[IN].data1+" data2 "+track[activetrack].midiMess[IN].data2);  
> > // track[activetrack].eventTicks.push(endTick);
> >  track[activetrack].midiMess.push({
> >       time: impOffTime,
> >       data0:NoteOffChan,
> >       data1:impKey,
> >   });
> > // IN=IN+1;
> > // console.log ("Event="+IN+" Time "+track[activetrack].midiMess[IN+1].time +" data0 "+track[activetrack].midiMess[IN+1].data0+" data1 "+track[activetrack].midiMess[IN+1].data1+" data2 "+track[activetrack].midiMess[IN+1].data2);  
> > }
> 
> If you want to try yourself, how it fail.
> https://midisequenser.000webhostapp.com/
> 
> It so weird it render real nice, because it use time to render and really do not care about missed notes however to be played the events have to be ordered. And since my parsing bug make it impossible to sort. It will only play right hand piano, but this is of course true for any song that hold more then one "instrument" on a channel. Well maybe even true for any song that holde more then one channel.
> 
> But the channels/tracks render perfectly och each track "always something". To play them up in correct order.....
> 
> Well you need to sort them which seem impossible.
> 
> Here is the midifile i used, probably should had found a smaller one. But it get the bug using only single channel with two instruments/hands.
> 
> http://www.piano-midi.de/midis/chopin/chpn_op66.mid

I am not sure why it take so long time load, well the guy have some thousands of BPM changes, i am not sure why maybe some type of midi copy protection, it is a piano piece i do not think classical music use BPM

[toc] | [prev] | [next] | [standalone]


#38117

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-22 22:27 -0800
Message-ID<86e18673-21d5-403e-a251-5a771d3ad3c9@googlegroups.com>
In reply to#38115
Den torsdag 23 januari 2020 kl. 07:05:55 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 06:25:57 UTC+1 skrev Jonas Thörnvall:
> > I am oarsing a file following a format, even made some what an editor for it.
> > However sometimes the values not expected "bad parsed" at some instance.
> > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > 
> > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > 
> > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > 
> > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > I still bomb out try to reparse it for my sequenser.
> > 
> > Seeing that i miss event 3289,3290 in list do not help me that much.
> > I somehow must find out what they contain.
> 
> Here is the order of blocks of different "message type".
> There is things like a channel but does not really matter since a channel can hhave many blocks, but each block consist of these
> 
> 	parseCC(i);
>         parsePitchBend(i);
> 	parsePrograms(i);
> 	parseNotes(i);
>         //Here is where my code bugs out it seem to incorporate 2? extra event 
>         //before next block processed "well the code says channel" but it is 
>         //really block since a channel can have many block "that is really 
>         //instruments 
> 
> My full code to decipher the fork misstake in next post.
> 
> Here is the fork where parsing goes wrong when there comes a new block 
> 
> 
>   {
>           "duration": 3.329729499999985,
>           "durationTicks": 1800,
>           "midi": 53,
>           "name": "F3",
>           "ticks": 263160,
>           "time": 267.06666610833395,
>           "velocity": 0.2755905511811024
>         },
>         {
>           "duration": 3.082417666666572,
>           "durationTicks": 1740,
>           "midi": 61,
>           "name": "C#4",
>           "ticks": 263220,
>           "time": 267.31397794166736,
>           "velocity": 0.33070866141732286
>         }
> //Here two extra elements seem to be interpretated.
>       ]
>     },
>     {
>       "channel": 0,
>       "controlChanges": {
>         "7": [
>           {
>             "number": 7,
>             "ticks": 0,
>             "time": 0,
>             "value": 0.7874015748031497
>           }
>         ],
>         "10": [
>           {
>             "number": 10,
>             "ticks": 0,
>             "time": 0,
>             "value": 0.5039370078740157
>           }
>         ],

I must say my own textfile format for sequenser is a middle way "between bitfiddling" and go total berserk all in on objects. That is a bit more comprehensive then midi format and the object format above.

bumblebee;
Frog fatalism;
RumpelStiltskin;
A dark night in December;
480;
TRACK;
1;
NONAME;
176:7:100:0;
176:10:64:0;
176:91:127:0;
192:1:0;
144:56:79:0;
144:68:37:5777.158950000001;
128:68:5864.96395;
144:69:41:5864.963950000001;
144:68:38:5952.940950000001;
128:69:5952.940950000002;
128:68:6042.404866666668;
144:67:39:6042.404866666668;
128:67:6131.163783333334;
144:68:40:6131.163783333334;
128:68:6219.312783333335;
144:73:42:6219.312783333335;
128:73:6307.983950000002;
144:76:43:6307.983950000002;
128:76:6396.916950000002;
144:75:45:6396.916950000002;
128:75:6485.240033333334;
144:73:43:6485.240033333334;
128:73:6572.9592833333345;
144:75:45:6572.9592833333345;
128:75:6660.936283333334;
144:73:43:6660.936283333334;
128:73:6749.781533333335;
144:72:44:6749.781533333335;
144:73:46:6837.845283333334;
128:72:6837.845283333335;
128:73:6926.081033333334;
144:76:49:6926.081033333334;
128:76:7014.576533333334;
144:80:47:7014.576533333334;
128:80:7119.4275333333335;
144:68:45:7220.173033333334;
128:68:7309.025366666668;
144:69:49:7309.025366666668;
128:69:7397.2611166666675;
144:68:45:7397.2611166666675;
128:68:7485.068616666667;
144:67:46:7485.068616666668;
144:68:48:7573.564116666668;
128:67:7573.564116666669;
128:68:7661.714116666668;
144:73:50:7661.714116666668;
128:73:7749.348116666667;
144:76:51:7749.348116666668;
128:76:7837.670616666667;
144:75:54:7837.670616666667;
128:75:7926.516866666667;
144:73:51:7926.516866666667;
128:73:8015.803116666668;
144:75:53:8015.803116666668;
128:75:8104.386533333335;
144:73:51:8104.386533333335;
128:73:8192.191533333335;
144:72:52:8192.191533333335;
144:73:54:8280.602366666666;
128:72:8280.602366666668;
128:73:8370.065783333333;
144:76:57:8370.065783333335;
128:76:8458.8237;
144:80:55:8458.8237;
128:80:8563.316950000002;
144:69:55:8664.3952;
128:69:8754.724116666666;
144:73:55:8754.724116666666;
128:73:8844.496366666668;
144:75:58:8844.496366666668;
128:75:8933.811033333335;
144:78:61:8933.811033333335;
128:78:9023.308283333336;
144:81:64:9023.308283333336;
128:81:9112.530450000002;
144:85:67:9112.530450000002;
144:87:70:9201.481116666668;
128:85:9201.48111666667;
128:87:9290.160033333334;
144:95:74:9290.160033333335;
144:93:72:9377.879783333334;
128:95:9377.879783333336;
128:93:9465.343283333332;
144:92:71:9465.343283333332;
128:92:9553.406533333333;
144:90:70:9553.406533333335;
144:88:69:9641.902033333334;
128:90:9641.902033333336;
128:88:9730.397533333333;
144:87:68:9730.397533333333;
128:87:9817.691533333333;
144:90:67:9817.691533333333;
128:90:9905.927283333334;
144:85:66:9905.927283333334;
128:85:9994.422783333333;
144:84:68:9994.422783333333;
144:87:63:10082.313533333334;
128:84:10082.313533333336;
128:87:10170.206283333333;
144:81:63:10170.206283333335;
144:80:63:10258.701783333332;
128:81:10258.701783333334;
128:80:10346.850783333331;
144:78:60:10346.850783333331;
128:78:10434.570033333332;
144:81:58:10434.570033333332;
144:76:54:10522.289283333332;
128:81:10522.289283333334;
128:76:10610.008533333332;
144:75:54:10610.008533333332;
128:75:10697.727783333334;
144:78:53:10697.727783333334;
144:73:48:10785.957783333331;
128:78:10785.957783333333;
128:73:10874.547616666665;
144:72:48:10874.547616666667;
144:75:47:10963.406949999997;
128:72:10963.406949999999;
128:75:11052.812866666662;
144:69:45:11052.812866666663;
128:69:11143.891199999996;
144:68:42:11143.891199999996;
128:68:11236.905449999997;
144:71:42:11236.905449999997;
128:71:11331.831116666663;
144:69:41:11331.831116666663;
128:69:11534.55253333333;
144:68:37:11534.552533333332;
144:69:41:11622.44328333333;
128:68:11622.443283333332;
128:69:11710.42128333333;
144:68:38:11710.42128333333;
128:68:11799.707533333329;
144:67:39:11799.707533333329;
128:67:11889.25978333333;
144:68:40:11889.25978333333;
128:68:11978.194866666663;
144:73:42:11978.194866666665;
144:76:43:12066.257616666664;
128:73:12066.257616666666;
128:76:12154.234116666665;
144:75:45:12154.234116666665;
128:75:12243.079783333333;
144:73:43:12243.079783333333;
128:73:12332.277199999997;
144:75:45:12332.277199999997;
128:75:12421.035116666664;
144:73:43:12421.035116666664;
128:73:12509.097866666665;
144:72:44:12509.097866666665;
144:73:46:12597.333616666663;
128:72:12597.333616666665;
128:73:12686.00378333333;
144:76:49:12686.00378333333;
128:76:12774.76128333333;
144:80:47:12774.76128333333;
128:80:12881.05378333333;
144:68:45:12981.79928333333;
128:68:13070.55678333333;
144:70:49:13070.55678333333;
128:70:13159.226949999997;
144:68:45:13159.226949999997;
128:68:13247.81078333333;
144:67:46:13247.810783333332;
128:67:13336.919866666663;
144:68:48:13336.919866666663;
128:68:13425.415949999997;
144:73:50:13425.415949999999;
128:73:13513.565449999998;
144:76:51:13513.565449999998;
128:76:13602.762866666664;
144:75:54:13602.762866666664;
128:75:13692.049116666665;
144:73:51:13692.049116666665;
128:73:13780.719283333332;
144:75:53:13780.719283333332;
144:73:51:13868.95503333333;
128:75:13868.955033333332;
128:73:13957.017783333331;
144:72:52:13957.017783333331;
128:72:14045.951783333328;
144:73:54:14045.95178333333;
128:73:14134.974116666664;
144:76:57:14134.974116666664;
144:80:55:14223.556949999997;
128:76:14223.556949999998;
128:80:14329.849449999996;
144:75:64:14329.849449999998;
144:76:58:14430.271199999997;
128:75:14430.2712;
128:76:14520.600116666663;
144:75:61:14520.600116666665;
144:74:50:14610.372366666663;
128:75:14610.372366666665;
128:74:14699.68703333333;
144:75:56:14699.68703333333;
128:75:14789.18428333333;
144:83:68:14789.18428333333;
128:83:14878.406449999997;
144:82:62:14878.406449999997;
128:82:14967.357116666664;
144:80:65:14967.357116666664;
128:80:15056.03603333333;
144:79:69:15056.03603333333;
128:79:15143.760533333332;
144:88:73:15143.760533333332;
144:87:72:15231.82528333333;
128:88:15231.825283333332;
128:87:15320.320783333329;
144:85:72:15320.320783333329;
128:85:15408.72953333333;
144:83:75:15408.729533333331;
128:83:15496.193533333331;
144:82:69:15496.193533333331;
128:82:15584.516033333332;
144:80:68:15584.516033333332;
128:80:15673.011533333332;
144:79:68:15673.011533333332;
128:79:15761.507033333333;
144:82:72:15761.507033333333;
144:80:70:15850.00253333333;
128:82:15850.002533333332;
128:80:15937.89528333333;
144:83:64:15937.895283333331;
128:83:16025.615033333332;
144:74:57:16025.615033333332;
128:74:16114.023783333334;
144:76:65:16114.023783333334;
128:76:16202.519283333331;
144:75:57:16202.519283333331;
128:75:16289.90503333333;
144:80:63:16289.90503333333;
128:80:16376.947699999995;
144:70:57:16376.947699999995;
128:70:16464.666949999995;
144:73:61:16464.666949999995;
128:73:16552.896949999995;
144:71:59:16552.896949999995;
144:75:58:16641.486783333326;
128:71:16641.48678333333;
128:75:16730.34611666666;
144:67:56:16730.346116666664;
128:67:16819.75203333333;
144:70:60:16819.75203333333;
128:70:16911.259616666666;
144:68:51:16911.259616666666;
128:68:17005.175700000003;
144:67:55:17005.175700000003;
144:68:50:17101.94395;
128:67:17101.943950000004;
128:68:17203.37053333333;
144:68:72:17203.370533333335;
128:68:17308.221533333333;
144:80:58:17308.221533333333;
128:80:17411.89645;
144:72:59:17411.89645;
128:72:17514.880866666666;
144:73:59:17514.880866666666;
128:73:17617.18403333333;
144:66:71:17617.18403333333;
128:66:17718.702616666666;
144:78:60:17718.702616666666;
144:72:60:17819.772366666664;
128:78:17819.772366666668;
128:72:17920.673866666664;
144:73:61:17920.673866666664;
128:73:18021.469366666664;
144:65:75:18021.469366666664;
128:65:18122.052866666665;
144:77:62:18122.052866666665;
128:77:18222.742366666665;
144:72:63:18222.742366666665;
128:72:18323.643866666665;
144:73:63:18323.643866666665;
128:73:18424.7632;
144:66:74:18424.7632;
144:78:65:18525.991449999998;
128:66:18525.99145;
128:78:18627.866616666663;
144:72:64:18627.866616666666;
128:72:18730.961033333333;
144:73:64:18730.961033333333;
128:73:18835.296033333332;
144:61:77:18835.296033333332;
128:61:18938.504116666663;
144:73:65:18938.504116666663;
128:73:19039.409866666665;
144:66:65:19039.409866666665;
128:66:19140.311366666665;
144:69:65:19140.311366666665;
128:69:19241.21286666667;
144:63:75:19241.21286666667;
128:63:19342.11436666667;
144:75:65:19342.11436666667;
144:66:65:19443.015866666665;
128:75:19443.01586666667;
128:66:19543.811366666665;
144:69:65:19543.811366666665;
128:69:19644.394866666666;
144:64:79:19644.394866666666;
128:64:19745.190366666666;
144:76:66:19745.190366666666;
128:76:19846.20078333333;
144:68:66:19846.20078333333;
128:68:19947.42903333333;
144:71:66:19947.429033333334;
144:68:77:20048.97928333333;
128:71:20048.979283333334;
128:68:20150.745699999996;
144:80:67:20150.7457;
144:71:66:20253.280116666665;
128:80:20253.28011666667;
128:71:20356.82186666666;
144:76:65:20356.821866666665;
128:76:20460.699866666666;
144:68:81:20460.699866666666;
128:68:20562.250116666666;
144:80:65:20562.250116666666;
144:72:65:20663.800366666666;
128:80:20663.80036666667;
128:72:20765.24328333333;
144:73:65:20765.24328333333;
128:73:20866.47153333333;
144:66:78:20866.471533333333;
144:78:65:20967.69978333333;
128:66:20967.699783333333;
128:78:21068.710199999998;
144:72:65:21068.710199999998;
128:72:21169.611699999998;
144:73:65:21169.611699999998;
128:73:21270.407199999998;
144:65:79:21270.407199999998;
144:77:66:21370.990699999995;
128:65:21370.9907;
128:77:21471.680199999995;
144:72:66:21471.6802;
128:72:21572.5817;
144:73:66:21572.5817;
128:73:21673.701033333335;
144:66:77:21673.701033333335;
144:78:67:21774.92928333333;
128:66:21774.929283333335;
128:78:21876.804449999996;
144:72:66:21876.80445;
128:72:21979.898866666666;
144:73:65:21979.898866666666;
128:73:22084.233866666666;
144:65:81:22084.233866666666;
128:65:22187.100366666666;
144:77:65:22187.100366666666;
128:77:22289.966866666662;
144:71:65:22289.966866666662;
128:71:22392.723199999993;
144:75:65:22392.723199999997;
128:75:22495.935866666663;
144:66:78:22495.935866666663;
128:66:22601.31428333333;
144:78:65:22601.31428333333;
128:78:22708.237616666665;
144:71:65:22708.237616666665;
128:71:22818.008866666667;
144:75:65:22818.008866666667;
128:75:22933.247449999995;
144:69:79:22933.247449999995;
128:69:23038.27503333333;
144:81:66:23038.27503333333;
128:81:23144.003449999997;
144:71:66:23144.003449999997;
128:71:23250.444616666664;
144:76:66:23250.444616666664;
128:76:23357.6082;
144:68:77:23357.6082;
128:68:23465.37445;
144:80:67:23465.37445;
128:80:23573.631116666664;
144:71:66:23573.631116666664;
128:71:23682.261449999995;
144:76:65:23682.261449999995;
128:76:23790.654199999994;
144:68:52:23790.654199999994;
128:68:23892.204449999994;
144:80:57:23892.204449999994;
128:80:23993.754699999998;
144:72:47:23993.754699999998;
128:72:24095.197616666665;
144:73:47:24095.197616666665;
128:73:24196.425866666665;
144:66:49:24196.425866666665;
128:66:24297.654116666665;
144:78:54:24297.654116666665;
128:78:24398.66453333333;
144:72:48:24398.66453333333;
144:73:48:24499.566033333325;
128:72:24499.56603333333;
128:73:24600.36153333333;
144:65:51:24600.36153333333;
128:65:24700.94503333333;
144:77:56:24700.94503333333;
128:77:24801.63453333333;
144:72:50:24801.63453333333;
128:72:24902.53603333333;
144:73:50:24902.53603333333;
128:73:25003.65536666666;
144:66:53:25003.65536666666;
128:66:25104.88361666666;
144:78:58:25104.883616666662;
128:78:25206.758783333327;
144:72:51:25206.758783333327;
128:72:25309.853199999994;
144:73:51:25309.853199999994;
128:73:25414.188199999997;
144:61:55:25414.188199999997;
128:61:25517.396283333328;
144:73:60:25517.39628333333;
128:73:25618.30203333333;
144:66:52:25618.30203333333;
128:66:25719.20353333333;
144:69:53:25719.20353333333;
144:63:55:25820.10503333333;
128:69:25820.105033333333;
128:63:25921.00653333333;
144:75:62:25921.00653333333;
128:75:26021.90803333333;
144:66:54:26021.90803333333;
128:66:26122.703533333333;
144:69:54:26122.703533333333;
144:64:57:26223.28703333333;
128:69:26223.287033333334;
128:64:26324.082533333327;
144:76:65:26324.082533333327;
128:76:26425.092949999995;
144:68:56:26425.092949999995;
128:68:26526.321199999995;
144:71:56:26526.321199999995;
128:71:26627.871449999995;
144:68:60:26627.871449999995;
128:68:26729.637866666664;
144:80:68:26729.637866666664;
128:80:26832.17228333333;
144:71:57:26832.17228333333;
128:71:26935.714033333326;
144:76:58:26935.714033333326;
128:76:27038.697366666656;
144:68:62:27038.697366666656;
128:68:27141.12161666666;
144:80:68:27141.12161666666;
144:72:59:27243.21361666666;
128:80:27243.213616666664;
128:72:27344.980033333326;
144:73:59:27344.98003333333;
144:66:62:27446.530283333326;
128:73:27446.53028333333;
128:66:27547.758533333326;
144:78:70:27547.758533333326;
128:78:27648.660033333326;
144:72:61:27648.660033333326;
144:73:61:27749.243533333323;
128:72:27749.243533333327;
128:73:27849.504283333325;
144:75:64:27849.504283333325;
128:75:27950.19219999999;
144:87:73:27950.19219999999;
128:87:28051.20261666666;
144:78:62:28051.20261666666;
144:81:62:28152.430866666655;
128:78:28152.43086666666;
128:81:28253.981116666655;
144:73:66:28253.981116666655;
128:73:28355.747533333324;
144:85:74:28355.747533333324;
128:85:28458.28194999999;
144:78:62:28458.28194999999;
128:78:28561.823699999986;
144:81:62:28561.823699999986;
128:81:28665.254366666653;
144:73:64:28665.254366666657;
128:73:28767.790366666657;
144:85:73:28767.790366666657;
128:85:28869.991116666657;
144:75:61:28869.991116666657;
128:75:28971.974366666655;
144:78:61:28971.974366666655;
128:78:29073.740783333324;
144:72:64:29073.740783333324;

[toc] | [prev] | [next] | [standalone]


#38121

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-23 04:50 -0800
Message-ID<d7a252f7-f2e0-45cf-aacc-c5a137873897@googlegroups.com>
In reply to#38114
On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> I am oarsing a file following a format, even made some what an editor for it.
> However sometimes the values not expected "bad parsed" at some instance.
> But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> 
> Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> 
> I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> 
> I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> I still bomb out try to reparse it for my sequenser.
> 
> Seeing that i miss event 3289,3290 in list do not help me that much.
> I somehow must find out what they contain.

Remember that time when I told you to use JSON.parse()?

[toc] | [prev] | [next] | [standalone]


#38122

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 06:12 -0800
Message-ID<a182cf42-b8bf-48cf-9984-c7c30865015f@googlegroups.com>
In reply to#38121
Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > I am oarsing a file following a format, even made some what an editor for it.
> > However sometimes the values not expected "bad parsed" at some instance.
> > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > 
> > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > 
> > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > 
> > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > I still bomb out try to reparse it for my sequenser.
> > 
> > Seeing that i miss event 3289,3290 in list do not help me that much.
> > I somehow must find out what they contain.
> 
> Remember that time when I told you to use JSON.parse()?

It is kind of weird as soon as someone posts some nonensense here i come up with a "workaround", so in a way you guys are fantastic LoL

Simply look each track for array elements which time equal NaN and remove them, it seem hell easier then actually find what is going wrong with them.

I think that will be my solutions for now, because when they are gone i hopefully will be able to sort the tracks.

[toc] | [prev] | [next] | [standalone]


#38123

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 06:33 -0800
Message-ID<dbc6e7bd-f5cd-4c71-81f0-eeac9c53b7d1@googlegroups.com>
In reply to#38121
Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > I am oarsing a file following a format, even made some what an editor for it.
> > However sometimes the values not expected "bad parsed" at some instance.
> > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > 
> > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > 
> > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > 
> > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > I still bomb out try to reparse it for my sequenser.
> > 
> > Seeing that i miss event 3289,3290 in list do not help me that much.
> > I somehow must find out what they contain.
> 
> Remember that time when I told you to use JSON.parse()?

Thanks for help Michael :)

for(var i=0;i <maxtrack i++){
for (var j=0;j<track[i]midiMess.length;j++){
if (track[i].midiMess[j].time===false ||Number.isNaN(track[i].midiMess[j].time){
	 track[i].midiMess.splice(j, 1); 
}
}			
}

[toc] | [prev] | [next] | [standalone]


#38124

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 06:55 -0800
Message-ID<4d4533cb-fd89-4d89-80e2-1d8c947a4615@googlegroups.com>
In reply to#38121
Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > I am oarsing a file following a format, even made some what an editor for it.
> > However sometimes the values not expected "bad parsed" at some instance.
> > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > 
> > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > 
> > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > 
> > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > I still bomb out try to reparse it for my sequenser.
> > 
> > Seeing that i miss event 3289,3290 in list do not help me that much.
> > I somehow must find out what they contain.
> 
> Remember that time when I told you to use JSON.parse()?

Your a genius Michael it works, thanks!

[toc] | [prev] | [next] | [standalone]


#38127

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-23 11:48 -0800
Message-ID<358946e6-68d2-4b21-af10-9fdcc4e3a4d8@googlegroups.com>
In reply to#38124
On Thursday, January 23, 2020 at 8:55:40 AM UTC-6, Jonas Thörnvall wrote:
> Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> > On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > > I am oarsing a file following a format, even made some what an editor for it.
> > > However sometimes the values not expected "bad parsed" at some instance.
> > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > 
> > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > 
> > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > 
> > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > I still bomb out try to reparse it for my sequenser.
> > > 
> > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > I somehow must find out what they contain.
> > 
> > Remember that time when I told you to use JSON.parse()?
> 
> Your a genius Michael it works, thanks!

So I've heard, but not relevant here.

What does reparseMidi() look like now?

[toc] | [prev] | [next] | [standalone]


#38128

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 14:54 -0800
Message-ID<83be6bc0-68fe-477d-ada7-bbf26bdb5c17@googlegroups.com>
In reply to#38127
Den torsdag 23 januari 2020 kl. 20:48:19 UTC+1 skrev Michael Haufe (TNO):
> On Thursday, January 23, 2020 at 8:55:40 AM UTC-6, Jonas Thörnvall wrote:
> > Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> > > On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > > > I am oarsing a file following a format, even made some what an editor for it.
> > > > However sometimes the values not expected "bad parsed" at some instance.
> > > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > > 
> > > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > > 
> > > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > > 
> > > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > > I still bomb out try to reparse it for my sequenser.
> > > > 
> > > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > > I somehow must find out what they contain.
> > > 
> > > Remember that time when I told you to use JSON.parse()?
> > 
> > Your a genius Michael it works, thanks!
> 
> So I've heard, but not relevant here.
> 
> What does reparseMidi() look like now?

Well actually the parsing is still riddled with bugs and really only work "perfect" with single track, single instrument like classical piano pieces or Bach organs. Of course i should write a real parser myself but the bitfiddling so f***ing boring, and take so much time.

The changes was minimal... I do not think i will work more on midi parsing unless someone have suggestion for howto improve it. Can't say for sure that all bugs come from my reparsing "but probably do", that is another aspect of it all.

Here is the minimal changes to file.

// THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE
function reparseMidi(){
	console.log("reparseMidi");
	document.getElementById("keystream").value="";
	track=[];
	makeTrack();
	document.getElementById("keystream").value=importedMidi;
	myChannels = importedMidi.split("channel");
	parseInfo();
	for (var i=1;i<myChannels.length;i++){
		//EXTRACT EACH CHANNEL
		console.log("****** NEW CHANNEL *********");
		channelStart=myChannels[i].indexOf(":");
		channelEnd=myChannels[i].indexOf(",");
		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
		importChannel=parseInt(importChannel);
		activetrack=importChannel+1;
		document.getElementById("track").value=activetrack;
		console.log("ActiveTrack= "+activetrack);
		
		//There can be more "channel posts/objects" then one, on same channel
		//alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
		parseCC(i);
		parsePitchBend(i);
		parsePrograms(i);
		parseNotes(i);
		track[activetrack].midiMess.sort(dynamicSort("time"));
	    
	}	
	maxtrack=16;
	
	for(var i=0;i<maxtrack; i++){
		for (var j=0;j<track[i].midiMess.length;j++){
			if	(track[i].midiMess[j].time===false || Number.isNaN(track[i].midiMess[j].time)){
			   track[i].midiMess.splice(j, 2); 
			}
        }			
	}
	
	for (var i=0;i <maxtrack; i++){
		track[activetrack].midiMess.sort(dynamicSort("time"));
	}
	downMixALLEventList();
	getNoteTicks(activetrack);
	console.log("****** Finished import *********");
	//Set to track 1 and close menu
	document.getElementById("track").value=1;
	changeTrack();
	MA();
}

[toc] | [prev] | [next] | [standalone]


#38129

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 14:58 -0800
Message-ID<ed1d58a3-bff4-4d72-aca5-80af43b4b5ce@googlegroups.com>
In reply to#38128
Den torsdag 23 januari 2020 kl. 23:54:42 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 20:48:19 UTC+1 skrev Michael Haufe (TNO):
> > On Thursday, January 23, 2020 at 8:55:40 AM UTC-6, Jonas Thörnvall wrote:
> > > Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> > > > On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > > > > I am oarsing a file following a format, even made some what an editor for it.
> > > > > However sometimes the values not expected "bad parsed" at some instance.
> > > > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > > > 
> > > > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > > > 
> > > > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > > > 
> > > > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > > > I still bomb out try to reparse it for my sequenser.
> > > > > 
> > > > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > > > I somehow must find out what they contain.
> > > > 
> > > > Remember that time when I told you to use JSON.parse()?
> > > 
> > > Your a genius Michael it works, thanks!
> > 
> > So I've heard, but not relevant here.
> > 
> > What does reparseMidi() look like now?
> 
> Well actually the parsing is still riddled with bugs and really only work "perfect" with single track, single instrument like classical piano pieces or Bach organs. Of course i should write a real parser myself but the bitfiddling so f***ing boring, and take so much time.
> 
> The changes was minimal... I do not think i will work more on midi parsing unless someone have suggestion for howto improve it. Can't say for sure that all bugs come from my reparsing "but probably do", that is another aspect of it all.
> 
> Here is the minimal changes to file.
> 
> // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE
> function reparseMidi(){
> 	console.log("reparseMidi");
> 	document.getElementById("keystream").value="";
> 	track=[];
> 	makeTrack();
> 	document.getElementById("keystream").value=importedMidi;
> 	myChannels = importedMidi.split("channel");
> 	parseInfo();
> 	for (var i=1;i<myChannels.length;i++){
> 		//EXTRACT EACH CHANNEL
> 		console.log("****** NEW CHANNEL *********");
> 		channelStart=myChannels[i].indexOf(":");
> 		channelEnd=myChannels[i].indexOf(",");
> 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> 		importChannel=parseInt(importChannel);
> 		activetrack=importChannel+1;
> 		document.getElementById("track").value=activetrack;
> 		console.log("ActiveTrack= "+activetrack);
> 		
> 		//There can be more "channel posts/objects" then one, on same channel
> 		//alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> 		parseCC(i);
> 		parsePitchBend(i);
> 		parsePrograms(i);
> 		parseNotes(i);
> 		track[activetrack].midiMess.sort(dynamicSort("time"));
> 	    
> 	}	
> 	maxtrack=16;
> 	
> 	for(var i=0;i<maxtrack; i++){
> 		for (var j=0;j<track[i].midiMess.length;j++){
> 			if	(track[i].midiMess[j].time===false || Number.isNaN(track[i].midiMess[j].time)){
> 			   track[i].midiMess.splice(j, 2); 
> 			}
>         }			
> 	}
> 	
> 	for (var i=0;i <maxtrack; i++){
> 		track[activetrack].midiMess.sort(dynamicSort("time"));
> 	}
> 	downMixALLEventList();
> 	getNoteTicks(activetrack);
> 	console.log("****** Finished import *********");
> 	//Set to track 1 and close menu
> 	document.getElementById("track").value=1;
> 	changeTrack();
> 	MA();
> }

I was thinking though give the possibility to split each instrument to separate track possibly 4 lines of codes. Now i just do track 1-16 for midichannel 1-16 because that is what is needed, but for editing purpose one probably should put each instrument on single channel.

[toc] | [prev] | [next] | [standalone]


#38130

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 15:00 -0800
Message-ID<d36ba0d3-e67b-45f8-9e2e-39f64cef907e@googlegroups.com>
In reply to#38129
Den torsdag 23 januari 2020 kl. 23:58:12 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 23:54:42 UTC+1 skrev Jonas Thörnvall:
> > Den torsdag 23 januari 2020 kl. 20:48:19 UTC+1 skrev Michael Haufe (TNO):
> > > On Thursday, January 23, 2020 at 8:55:40 AM UTC-6, Jonas Thörnvall wrote:
> > > > Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> > > > > On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > > > > > I am oarsing a file following a format, even made some what an editor for it.
> > > > > > However sometimes the values not expected "bad parsed" at some instance.
> > > > > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > > > > 
> > > > > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > > > > 
> > > > > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > > > > 
> > > > > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > > > > I still bomb out try to reparse it for my sequenser.
> > > > > > 
> > > > > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > > > > I somehow must find out what they contain.
> > > > > 
> > > > > Remember that time when I told you to use JSON.parse()?
> > > > 
> > > > Your a genius Michael it works, thanks!
> > > 
> > > So I've heard, but not relevant here.
> > > 
> > > What does reparseMidi() look like now?
> > 
> > Well actually the parsing is still riddled with bugs and really only work "perfect" with single track, single instrument like classical piano pieces or Bach organs. Of course i should write a real parser myself but the bitfiddling so f***ing boring, and take so much time.
> > 
> > The changes was minimal... I do not think i will work more on midi parsing unless someone have suggestion for howto improve it. Can't say for sure that all bugs come from my reparsing "but probably do", that is another aspect of it all.
> > 
> > Here is the minimal changes to file.
> > 
> > // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE
> > function reparseMidi(){
> > 	console.log("reparseMidi");
> > 	document.getElementById("keystream").value="";
> > 	track=[];
> > 	makeTrack();
> > 	document.getElementById("keystream").value=importedMidi;
> > 	myChannels = importedMidi.split("channel");
> > 	parseInfo();
> > 	for (var i=1;i<myChannels.length;i++){
> > 		//EXTRACT EACH CHANNEL
> > 		console.log("****** NEW CHANNEL *********");
> > 		channelStart=myChannels[i].indexOf(":");
> > 		channelEnd=myChannels[i].indexOf(",");
> > 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> > 		importChannel=parseInt(importChannel);
> > 		activetrack=importChannel+1;
> > 		document.getElementById("track").value=activetrack;
> > 		console.log("ActiveTrack= "+activetrack);
> > 		
> > 		//There can be more "channel posts/objects" then one, on same channel
> > 		//alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> > 		parseCC(i);
> > 		parsePitchBend(i);
> > 		parsePrograms(i);
> > 		parseNotes(i);
> > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > 	    
> > 	}	
> > 	maxtrack=16;
> > 	
> > 	for(var i=0;i<maxtrack; i++){
> > 		for (var j=0;j<track[i].midiMess.length;j++){
> > 			if	(track[i].midiMess[j].time===false || Number.isNaN(track[i].midiMess[j].time)){
> > 			   track[i].midiMess.splice(j, 2); 
> > 			}
> >         }			
> > 	}
> > 	
> > 	for (var i=0;i <maxtrack; i++){
> > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > 	}
> > 	downMixALLEventList();
> > 	getNoteTicks(activetrack);
> > 	console.log("****** Finished import *********");
> > 	//Set to track 1 and close menu
> > 	document.getElementById("track").value=1;
> > 	changeTrack();
> > 	MA();
> > }
> 
> I was thinking though give the possibility to split each instrument to separate track possibly 4 lines of codes. Now i just do track 1-16 for midichannel 1-16 because that is what is needed, but for editing purpose one probably should put each instrument on single channel.

But the pitchbend i probably do some day.

[toc] | [prev] | [next] | [standalone]


#38132

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-23 15:20 -0800
Message-ID<9e0607ec-2d01-4069-b574-23e44570d6f5@googlegroups.com>
In reply to#38130
Den fredag 24 januari 2020 kl. 00:00:34 UTC+1 skrev Jonas Thörnvall:
> Den torsdag 23 januari 2020 kl. 23:58:12 UTC+1 skrev Jonas Thörnvall:
> > Den torsdag 23 januari 2020 kl. 23:54:42 UTC+1 skrev Jonas Thörnvall:
> > > Den torsdag 23 januari 2020 kl. 20:48:19 UTC+1 skrev Michael Haufe (TNO):
> > > > On Thursday, January 23, 2020 at 8:55:40 AM UTC-6, Jonas Thörnvall wrote:
> > > > > Den torsdag 23 januari 2020 kl. 13:50:49 UTC+1 skrev Michael Haufe (TNO):
> > > > > > On Wednesday, January 22, 2020 at 11:25:57 PM UTC-6, Jonas Thörnvall wrote:
> > > > > > > I am oarsing a file following a format, even made some what an editor for it.
> > > > > > > However sometimes the values not expected "bad parsed" at some instance.
> > > > > > > But it seem to screw up my listing of the values so i can not even see what the values it goes wrong is, although i see the "events/array element" missing.
> > > > > > > 
> > > > > > > Unfortunately for me what ever value that is there prevents me from sorting, the eventlist on time. And since there is several instruments pretty much layed out sequential aftereachother on same channel.
> > > > > > > 
> > > > > > > I noticed this because a guy had layed out left and right hand as separate "instruments". So basicly all things played with left hand comes after the ones played with right hand and since there seem to be NaN values in the event list the sort seem to bug out?
> > > > > > > 
> > > > > > > I really must say i do hate to parse midi even that the thing i parse from have neatly tied up the 70-style bit structure with labeled objects.
> > > > > > > I still bomb out try to reparse it for my sequenser.
> > > > > > > 
> > > > > > > Seeing that i miss event 3289,3290 in list do not help me that much.
> > > > > > > I somehow must find out what they contain.
> > > > > > 
> > > > > > Remember that time when I told you to use JSON.parse()?
> > > > > 
> > > > > Your a genius Michael it works, thanks!
> > > > 
> > > > So I've heard, but not relevant here.
> > > > 
> > > > What does reparseMidi() look like now?
> > > 
> > > Well actually the parsing is still riddled with bugs and really only work "perfect" with single track, single instrument like classical piano pieces or Bach organs. Of course i should write a real parser myself but the bitfiddling so f***ing boring, and take so much time.
> > > 
> > > The changes was minimal... I do not think i will work more on midi parsing unless someone have suggestion for howto improve it. Can't say for sure that all bugs come from my reparsing "but probably do", that is another aspect of it all.
> > > 
> > > Here is the minimal changes to file.
> > > 
> > > // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE
> > > function reparseMidi(){
> > > 	console.log("reparseMidi");
> > > 	document.getElementById("keystream").value="";
> > > 	track=[];
> > > 	makeTrack();
> > > 	document.getElementById("keystream").value=importedMidi;
> > > 	myChannels = importedMidi.split("channel");
> > > 	parseInfo();
> > > 	for (var i=1;i<myChannels.length;i++){
> > > 		//EXTRACT EACH CHANNEL
> > > 		console.log("****** NEW CHANNEL *********");
> > > 		channelStart=myChannels[i].indexOf(":");
> > > 		channelEnd=myChannels[i].indexOf(",");
> > > 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> > > 		importChannel=parseInt(importChannel);
> > > 		activetrack=importChannel+1;
> > > 		document.getElementById("track").value=activetrack;
> > > 		console.log("ActiveTrack= "+activetrack);
> > > 		
> > > 		//There can be more "channel posts/objects" then one, on same channel
> > > 		//alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> > > 		parseCC(i);
> > > 		parsePitchBend(i);
> > > 		parsePrograms(i);
> > > 		parseNotes(i);
> > > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > > 	    
> > > 	}	
> > > 	maxtrack=16;
> > > 	
> > > 	for(var i=0;i<maxtrack; i++){
> > > 		for (var j=0;j<track[i].midiMess.length;j++){
> > > 			if	(track[i].midiMess[j].time===false || Number.isNaN(track[i].midiMess[j].time)){
> > > 			   track[i].midiMess.splice(j, 2); 
> > > 			}
> > >         }			
> > > 	}
> > > 	
> > > 	for (var i=0;i <maxtrack; i++){
> > > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > > 	}
> > > 	downMixALLEventList();
> > > 	getNoteTicks(activetrack);
> > > 	console.log("****** Finished import *********");
> > > 	//Set to track 1 and close menu
> > > 	document.getElementById("track").value=1;
> > > 	changeTrack();
> > > 	MA();
> > > }
> > 
> > I was thinking though give the possibility to split each instrument to separate track possibly 4 lines of codes. Now i just do track 1-16 for midichannel 1-16 because that is what is needed, but for editing purpose one probably should put each instrument on single channel.
> 
> But the pitchbend i probably do some day.

It is a great project unfortunately the programmer is horrific and sloppy LoL
I have all the ideas and none of the knowledge LoL

[toc] | [prev] | [next] | [standalone]


#38133

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-23 17:59 -0800
Message-ID<434a7817-280f-48fb-8b13-571698268526@googlegroups.com>
In reply to#38128
On Thursday, January 23, 2020 at 4:54:42 PM UTC-6, Jonas Thörnvall wrote:
> Den torsdag 23 januari 2020 kl. 20:48:19 UTC+1 skrev Michael Haufe (TNO):
> [...]
> > What does reparseMidi() look like now?
> 
> Well actually the parsing is still riddled with bugs and really only work "perfect" with single track, single instrument like classical piano pieces or Bach organs. Of course i should write a real parser myself but the bitfiddling so f***ing boring, and take so much time.
> 
> The changes was minimal... I do not think i will work more on midi parsing unless someone have suggestion for howto improve it. Can't say for sure that all bugs come from my reparsing "but probably do", that is another aspect of it all.
> 
> Here is the minimal changes to file.
> 
> // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE
> function reparseMidi(){
> 	console.log("reparseMidi");
> 	document.getElementById("keystream").value="";
> 	track=[];
> 	makeTrack();
> 	document.getElementById("keystream").value=importedMidi;
> 	myChannels = importedMidi.split("channel");
> 	parseInfo();
> 	for (var i=1;i<myChannels.length;i++){
> 		//EXTRACT EACH CHANNEL
> 		console.log("****** NEW CHANNEL *********");
> 		channelStart=myChannels[i].indexOf(":");
> 		channelEnd=myChannels[i].indexOf(",");
> 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> 		importChannel=parseInt(importChannel);
> 		activetrack=importChannel+1;
> 		document.getElementById("track").value=activetrack;
> 		console.log("ActiveTrack= "+activetrack);
> 		
> 		//There can be more "channel posts/objects" then one, on same channel
> 		//alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> 		parseCC(i);
> 		parsePitchBend(i);
> 		parsePrograms(i);
> 		parseNotes(i);
> 		track[activetrack].midiMess.sort(dynamicSort("time"));
> 	    
> 	}	
> 	maxtrack=16;
> 	
> 	for(var i=0;i<maxtrack; i++){
> 		for (var j=0;j<track[i].midiMess.length;j++){
> 			if	(track[i].midiMess[j].time===false || Number.isNaN(track[i].midiMess[j].time)){
> 			   track[i].midiMess.splice(j, 2); 
> 			}
>         }			
> 	}
> 	
> 	for (var i=0;i <maxtrack; i++){
> 		track[activetrack].midiMess.sort(dynamicSort("time"));
> 	}
> 	downMixALLEventList();
> 	getNoteTicks(activetrack);
> 	console.log("****** Finished import *********");
> 	//Set to track 1 and close menu
> 	document.getElementById("track").value=1;
> 	changeTrack();
> 	MA();
> }


Why not just do:

```
var parsedMidi = JSON.parse(importedMidi)
```

[toc] | [prev] | [next] | [standalone]


#38134

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-24 01:03 -0800
Message-ID<9a9b5a80-76e0-4d3c-a23d-3ffaf1a965c3@googlegroups.com>
In reply to#38133
Den fredag 24 januari 2020 kl. 02:59:32 UTC+1 skrev Michael Haufe (TNO):
> On Thursday, January 23, 2020 at 4:54:42 PM UTC-6, Jonas Thörnvall wrote:
> > Den torsdag 23 januari 2020 kl. 20:48:19 UTC+1 skrev Michael Haufe (TNO):
> > [...]
> > > What does reparseMidi() look like now?
> > 
> > Well actually the parsing is still riddled with bugs and really only work "perfect" with single track, single instrument like classical piano pieces or Bach organs. Of course i should write a real parser myself but the bitfiddling so f***ing boring, and take so much time.
> > 
> > The changes was minimal... I do not think i will work more on midi parsing unless someone have suggestion for howto improve it. Can't say for sure that all bugs come from my reparsing "but probably do", that is another aspect of it all.
> > 
> > Here is the minimal changes to file.
> > 
> > // THIS IS THE MAIN FUNCTION FIRST CALLED WHEN PARSING A MIDI FILE
> > function reparseMidi(){
> > 	console.log("reparseMidi");
> > 	document.getElementById("keystream").value="";
> > 	track=[];
> > 	makeTrack();
> > 	document.getElementById("keystream").value=importedMidi;
> > 	myChannels = importedMidi.split("channel");
> > 	parseInfo();
> > 	for (var i=1;i<myChannels.length;i++){
> > 		//EXTRACT EACH CHANNEL
> > 		console.log("****** NEW CHANNEL *********");
> > 		channelStart=myChannels[i].indexOf(":");
> > 		channelEnd=myChannels[i].indexOf(",");
> > 		importChannel=myChannels[i].substring(channelStart+1,channelEnd);
> > 		importChannel=parseInt(importChannel);
> > 		activetrack=importChannel+1;
> > 		document.getElementById("track").value=activetrack;
> > 		console.log("ActiveTrack= "+activetrack);
> > 		
> > 		//There can be more "channel posts/objects" then one, on same channel
> > 		//alert("Number of parts="+myChannels.length+" This channel="+activetrack+" ChPart ="+myChannels[i]);
> > 		parseCC(i);
> > 		parsePitchBend(i);
> > 		parsePrograms(i);
> > 		parseNotes(i);
> > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > 	    
> > 	}	
> > 	maxtrack=16;
> > 	
> > 	for(var i=0;i<maxtrack; i++){
> > 		for (var j=0;j<track[i].midiMess.length;j++){
> > 			if	(track[i].midiMess[j].time===false || Number.isNaN(track[i].midiMess[j].time)){
> > 			   track[i].midiMess.splice(j, 2); 
> > 			}
> >         }			
> > 	}
> > 	
> > 	for (var i=0;i <maxtrack; i++){
> > 		track[activetrack].midiMess.sort(dynamicSort("time"));
> > 	}
> > 	downMixALLEventList();
> > 	getNoteTicks(activetrack);
> > 	console.log("****** Finished import *********");
> > 	//Set to track 1 and close menu
> > 	document.getElementById("track").value=1;
> > 	changeTrack();
> > 	MA();
> > }
> 
> 
> Why not just do:
> 
> ```
> var parsedMidi = JSON.parse(importedMidi)
> ```

And exactly what would that achieve?

[toc] | [prev] | [next] | [standalone]


#38136

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-24 05:38 -0800
Message-ID<302d2238-2db6-44eb-ac9c-521684172d39@googlegroups.com>
In reply to#38134
On Friday, January 24, 2020 at 3:03:52 AM UTC-6, Jonas Thörnvall wrote:
> Den fredag 24 januari 2020 kl. 02:59:32 UTC+1 skrev Michael Haufe (TNO):
> > [...]
> > 
> > Why not just do:
> > 
> > ```
> > var parsedMidi = JSON.parse(importedMidi)
> > ```
> 
> And exactly what would that achieve?

If `importedMidi` is the string representing what you showed us in your second post then it would achieve a complete parse and you can throw away the rest of your code as redundant.

You shouldn't have to do any parsing at all yourself.

[toc] | [prev] | [next] | [standalone]


#38137

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2020-01-24 11:23 -0800
Message-ID<ec16fe70-99f0-4cc7-9c68-b1effde95067@googlegroups.com>
In reply to#38136
Den fredag 24 januari 2020 kl. 14:39:01 UTC+1 skrev Michael Haufe (TNO):
> On Friday, January 24, 2020 at 3:03:52 AM UTC-6, Jonas Thörnvall wrote:
> > Den fredag 24 januari 2020 kl. 02:59:32 UTC+1 skrev Michael Haufe (TNO):
> > > [...]
> > > 
> > > Why not just do:
> > > 
> > > ```
> > > var parsedMidi = JSON.parse(importedMidi)
> > > ```
> > 
> > And exactly what would that achieve?
> 
> If `importedMidi` is the string representing what you showed us in your second post then it would achieve a complete parse and you can throw away the rest of your code as redundant.
> 
> You shouldn't have to do any parsing at all yourself.

Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???

[toc] | [prev] | [next] | [standalone]


#38138

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-24 17:12 -0800
Message-ID<39b26557-2147-4007-86b4-5fbe25c7d660@googlegroups.com>
In reply to#38137
On Friday, January 24, 2020 at 1:23:17 PM UTC-6, Jonas Thörnvall wrote:

> Yeah that require the importedMidi to be a JSON object i guess, but what is actually parsedMidi???


The bigger question is where did you use my JSON.parse() suggestion?

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web