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


Groups > comp.lang.javascript > #34928

Re: Playup Event list hangs

Newsgroups comp.lang.javascript
Date 2018-04-26 02:27 -0700
References <0e350c91-26c3-4ee3-838c-8873745b92f6@googlegroups.com> <8bf8f6e1-2894-4ee3-9b32-1cc95b5626a9@googlegroups.com>
Message-ID <f7c2be73-ed23-4d0c-bfa2-02da018c8548@googlegroups.com> (permalink)
Subject Re: Playup Event list hangs
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


Den torsdag 26 april 2018 kl. 10:57:15 UTC+2 skrev Jonas Thörnvall:
> Den torsdag 26 april 2018 kl. 10:47:14 UTC+2 skrev Jonas Thörnvall:
> > I have a list of timings where each time refer to playup of a midinotes.
> > See noteOnMessage below.
> > 
> > waitEv is a list of "wait times" between events, it is already precalculated i checked it is correct. I keep waitlists "timings" in sync with the events by simply step forward y++.
> > 
> > I probably do not understand how the recursive call i tried to implement work, because it hangs after second event/note is played?
> > 
> > function doPlayup(y) {
> >     if (waitEv.length) {
> >         var waittime = waitEv.shift();
> >         console.log("Waiting: " + waittime);
> >         noteOnMessage = [track[tracknr].midiMess[y].data0, track[tracknr].midiMess[y].data1, track[tracknr].midiMess[y].data2]; 
> >         output.send(noteOnMessage); 
> >         document.getElementById("keystream").value=waitEv[y];
> >         y++; 
> >         setTimeout(doPlayup, waittime);
> >     } 
> > }
> 
> Waiting: 1520
> play.js:45 Waiting: 342
> play.js:46 Uncaught TypeError: Cannot read property 'data0' of undefineddoPlayup @ play.js:46
> 
> Example of the actual events below, used to calculate waitime above
> 
> ON  t=1520.000
> F3 Vel 5
> OFF  t=1862.000
> F3 Vel 1
> ON  t=2378.000
> G3 Vel 22
> OFF  t=2565.000
> G3 Vel 5
> ON  t=3507.000
> A3 Vel 13
> OFF  t=3696.000
> A3 Vel 6
> ON  t=5610.000
> G3 Vel 7
> OFF  t=5724.000
> G3 Vel 16
> ON  t=6367.000
> F3 Vel 4
> OFF  t=6546.000
> F3 Vel 1

I think i may have solved it not that beautiful though.

var y=-1;
doPlayup(y);

function doPlayup(y) {
    
    if (waitEv.length) {
        var waittime = waitEv.shift();
        if (y>-1) 
        {
        noteOnMessage = [track[tracknr].midiMess[y].data0, track[tracknr].midiMess[y].data1, track[tracknr].midiMess[y].data2]; 
        output.send(noteOnMessage); 
        }
        y++; 
        setTimeout(doPlayup, waittime); 
    } 
 
}

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-26 01:47 -0700
  Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-26 01:57 -0700
    Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-26 02:27 -0700
  Re: Playup Event list hangs "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-26 11:02 +0200
    Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-26 03:23 -0700
      Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-27 07:13 -0700
        Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-27 07:25 -0700
          Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-27 07:30 -0700
            Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 12:59 -0700
              Re: Playup Event list hangs "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-04-29 22:14 +0200
                Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 15:45 -0700
                Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 15:47 -0700
                Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 16:39 -0700
                Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 16:57 -0700
                Re: Playup Event list hangs Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 17:06 -0700

csiph-web