Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35250
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2018-06-20 10:37 -0700 |
| References | <81af6402-843a-4d3a-a888-81d9776e6bbe@googlegroups.com> <1740bf3f-993a-4546-8e60-1f246499e39e@googlegroups.com> <13th7ihqnys6m.1py2jfza3m6y2.dlg@40tude.net> <a93219a4-aa9c-48f3-92e5-3e1f8d2ea371@googlegroups.com> |
| Message-ID | <77006b91-c121-4d94-9ae0-ff2fcaf56409@googlegroups.com> (permalink) |
| Subject | Re: Pair matching algorithm "hard?" |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
Den onsdag 20 juni 2018 kl. 19:28:09 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 20 juni 2018 kl. 15:31:28 UTC+2 skrev JJ:
> > On Wed, 20 Jun 2018 03:31:03 -0700 (PDT), Jonas Thörnvall wrote:
> >
> > > Den onsdag 20 juni 2018 kl. 12:26:26 UTC+2 skrev Jonas Thörnvall:
> > >> I have a two valued pair. One value is data let say characters. The other value denotes if it a start or end value. A value can not restart until it ended.
> > >>
> > >> I have written an algorithm that match up the start and ends, but i think i got it overly complicated. In reality the start and end values also carry time, but it is not necessary for the actual algorithm. So it is a stepthru algorithm, you can think of the values as an array arr[].ch and arr[].temporal
> > >>
> > >> C start
> > >> Z start
> > >> C end
> > >> B start
> > >> Z end
> > >> B end
> > >> C start
> > >> K start
> > >> R start
> > >> R end
> > >> K end
> > >> C end
> > >
> > > Does this look alright?
> > >
> > > function listTrackEvents(z){
> > > eventlist="";
> > > for (var i=0;i<track[z].midiMess.length;i++){
> > > //Generate textstring eventlist
> > > if(track[z].midiMess[i].data0=="128"){ }
> > > else if(track[z].midiMess[i].data0=="144"){
> > > notenumber=track[z].midiMess[i].data1;
> > > note=getNote(notenumber);
> > > eventlist+=note;
> > > eventlist+=" t="+track[z].midiMess[i].time.toFixed(3)+"\n";
> > > j=i+1;
> > > while(track[z].midiMess[j].data1!=notenumber){
> > > j++;
> > > }
> > > duration=track[z].midiMess[j].time-track[z].midiMess[i].time;
> > > eventlist+=" Duration "+duration+"\n";
> > > eventlist+=" Vel "+track[z].midiMess[i].data2+"\n";
> > > }
> > > }
> > > document.getElementById("events").value=eventlist;
> > > }
> >
> > You forgot to take account of the MIDI channel.
> >
> > Use an "note" cache for all 16 MIDI channels. e.g.
> >
> > var noteCache = [
> > {}, {}, {}, {}, {}, {}, {}, {},
> > {}, {}, {}, {}, {}, {}, {}, {}
> > ];
> >
> > When encountering a Channel event, store the event's channel number to e.g.
> > `channelNum` variable.
> >
> > When encountering a NoteOn event, store it in the cache. e.g.
> >
> > if (message.event === msgNoteOn) {
> > noteCache[channelNum][message.noteNumber] = message.time;
> > }
> >
> > When encountering a NoteOff event, check it from the "note" cache. If found,
> > calculate the duration, then remove it from the cache. e.g.
> >
> > if (message.event === msgNoteOff) {
> > if (message.noteNumber in noteCache[channelNum]) {
> > duration = message.time - noteCache[channelNum][message.noteNumber];
> > delete noteCache[channelNum][message.noteNumber];
> > }
> > }
>
> Regarding the note cache, you seem to assume my program function is for "multichannel **recording**" but is just for listing the recorded events in the editor, regarding multichannel recording i am not quite there yet, but i see your point. I would like to make this sequenser a webmidi thingy in the end. And then each user must be able to assign a channel to play.
A SF2 host working direct out of browser or a VSTI host in javascript would be nice.
I see there is a SF2 host in javascript, but it requires installation by the user. For sure one must be able to make a SF2 host right out of the browser.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 03:26 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 03:31 -0700
Re: Pair matching algorithm "hard?" Wally W. <ww84wa@aim.com> - 2018-06-20 08:45 -0400
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 10:16 -0700
Re: Pair matching algorithm "hard?" JJ <jj4public@vfemail.net> - 2018-06-20 20:31 +0700
Re: Pair matching algorithm "hard?" JJ <jj4public@vfemail.net> - 2018-06-20 20:37 +0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 10:22 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 10:55 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 11:26 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 13:12 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 13:15 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 13:20 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 13:26 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-24 09:17 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-24 09:27 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 10:19 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 10:28 -0700
Re: Pair matching algorithm "hard?" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-06-20 10:37 -0700
csiph-web