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


Groups > comp.lang.javascript > #34930

Re: Playup Event list hangs

X-Received by 2002:a24:d903:: with SMTP id p3-v6mr551758itg.41.1524838428354; Fri, 27 Apr 2018 07:13:48 -0700 (PDT)
X-Received by 2002:a9d:703:: with SMTP id 3-v6mr160700ote.11.1524838428163; Fri, 27 Apr 2018 07:13:48 -0700 (PDT)
Path csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!k65-v6no390329ita.0!news-out.google.com!b185-v6ni552itb.0!nntp.google.com!k65-v6no390326ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.javascript
Date Fri, 27 Apr 2018 07:13:47 -0700 (PDT)
In-Reply-To <38e0bd1d-f418-418a-8d33-1a0ac2a868ad@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=84.217.164.223; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host 84.217.164.223
References <0e350c91-26c3-4ee3-838c-8873745b92f6@googlegroups.com> <XnsA8D07059C8B9Beejj99@194.109.6.166> <38e0bd1d-f418-418a-8d33-1a0ac2a868ad@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <ba71434b-e5b7-440c-a810-14dd2e91fb94@googlegroups.com> (permalink)
Subject Re: Playup Event list hangs
From Jonas Thörnvall <jonas.thornvall@gmail.com>
Injection-Date Fri, 27 Apr 2018 14:13:48 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
X-Received-Bytes 4389
X-Received-Body-CRC 3108777354
Xref csiph.com comp.lang.javascript:34930

Show key headers only | View raw


Den torsdag 26 april 2018 kl. 12:23:44 UTC+2 skrev Jonas Thörnvall:
> Den torsdag 26 april 2018 kl. 11:03:28 UTC+2 skrev Evertjan.:
> > =?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)
> 
> Thanks for the advice, Evertjan
> 
> I am not used to these types of self referencing functions.
> And i try to figure out howto get ***the last note*** played?
> But it does not behave the way i expect.
> 
>  pyp=-1;
>  doPlayup();
>  noteOnMessage = [track[tracknr].midiMess[pyp].data0,        track[tracknr].midiMess[pyp].data1, track[tracknr].midiMess[pyp].data2]; 
>  output.send(noteOnMessage);
> 
> function doPlayup() {
>     if (waitEv.length) {
>         var waittime = waitEv.shift();
>         console.log("Waiting: " + waittime);
>         if (pyp>-1) 
>         {
>         noteOnMessage = [track[tracknr].midiMess[pyp].data0, track[tracknr].midiMess[pyp].data1, track[tracknr].midiMess[pyp].data2]; 
>         output.send(noteOnMessage); 
>         }
>         pyp++; 
>         setTimeout(doPlayup, waittime); 
>     } 
> }

Well of course i could use the ugly method adding a last note patch message, put a tail on it. Maybe shift just is not a good use in this case? What kind of loop is preferable for this type of problem? 
And i am a bit curious how good programmers use shift in cases like this?

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