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


Groups > comp.lang.javascript > #34927

Re: Playup Event list hangs

Newsgroups comp.lang.javascript
Subject Re: Playup Event list hangs
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <0e350c91-26c3-4ee3-838c-8873745b92f6@googlegroups.com>
Date 2018-04-26 11:02 +0200
Message-ID <XnsA8D07059C8B9Beejj99@194.109.6.166> (permalink)

Show all headers | View raw


=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 26
Apr 2018 in comp.lang.javascript: 

> 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? 

Methinks you do not understand proper debugging,
as viewing the value of y in each recursion would have given it away.
 
> 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);
>     } 
>}

Your function is not recursive in the sense of scope,
as the setTimeout() does not conduct the nonglobal y value.

perhaps it would 'work' like this:

let y=17;
doPlayup();

function doPlayup() {
.....
};

but then, global variables are prone to misconceptions.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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