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


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

Playup Event list hangs

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2018-04-26 01:47 -0700
Last post2018-04-29 17:06 -0700
Articles 15 — 2 participants

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


Contents

  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

#34925 — Playup Event list hangs

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-26 01:47 -0700
SubjectPlayup Event list hangs
Message-ID<0e350c91-26c3-4ee3-838c-8873745b92f6@googlegroups.com>
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);
    } 
}

[toc] | [next] | [standalone]


#34926

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-26 01:57 -0700
Message-ID<8bf8f6e1-2894-4ee3-9b32-1cc95b5626a9@googlegroups.com>
In reply to#34925
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

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


#34928

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-26 02:27 -0700
Message-ID<f7c2be73-ed23-4d0c-bfa2-02da018c8548@googlegroups.com>
In reply to#34926
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); 
    } 
 
}

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


#34927

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2018-04-26 11:02 +0200
Message-ID<XnsA8D07059C8B9Beejj99@194.109.6.166>
In reply to#34925
=?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)

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


#34929

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-26 03:23 -0700
Message-ID<38e0bd1d-f418-418a-8d33-1a0ac2a868ad@googlegroups.com>
In reply to#34927
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); 
    } 
}

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


#34930

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-27 07:13 -0700
Message-ID<ba71434b-e5b7-440c-a810-14dd2e91fb94@googlegroups.com>
In reply to#34929
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?

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


#34931

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-27 07:25 -0700
Message-ID<6f3a10c7-0658-4f07-9031-970dd3ea9203@googlegroups.com>
In reply to#34930
Den fredag 27 april 2018 kl. 16:13:57 UTC+2 skrev Jonas Thörnvall:
> 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?

Or maybe running it in a loop isn't possible it will lock up all other activities going on, like recording?

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


#34932

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-27 07:30 -0700
Message-ID<97194be1-bc77-48bd-9392-9812bae37035@googlegroups.com>
In reply to#34931
Den fredag 27 april 2018 kl. 16:25:12 UTC+2 skrev Jonas Thörnvall:
> Den fredag 27 april 2018 kl. 16:13:57 UTC+2 skrev Jonas Thörnvall:
> > 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?
> 
> Or maybe running it in a loop isn't possible it will lock up all other activities going on, like recording?

I was hoping that this new play function would make it possible to record another track while i playup one.

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


#34934

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-29 12:59 -0700
Message-ID<1d7df4ab-1840-4bd0-984a-51eea7720031@googlegroups.com>
In reply to#34932
Den fredag 27 april 2018 kl. 16:30:48 UTC+2 skrev Jonas Thörnvall:
> Den fredag 27 april 2018 kl. 16:25:12 UTC+2 skrev Jonas Thörnvall:
> > Den fredag 27 april 2018 kl. 16:13:57 UTC+2 skrev Jonas Thörnvall:
> > > 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?
> > 
> > Or maybe running it in a loop isn't possible it will lock up all other activities going on, like recording?
> 
> I was hoping that this new play function would make it possible to record another track while i playup one.

Maybe my explanation was to brief to be understood, and noone see the problem?
But can't you agree that patching extra events, and call function with a negative parameter/argument value isn't that beautiful?

Probably there is a rather simple solution to my problem, but since i used to "for, while and do loops" i really can't see it?

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


#34935

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2018-04-29 22:14 +0200
Message-ID<XnsA8D3E2421F92eejj99@194.109.6.166>
In reply to#34934
<jonas.thornvall@gmail.com> wrote on 29
Apr 2018 in comp.lang.javascript: 

> Maybe my explanation was to brief to be understood, and noone see the
> problem? But can't you agree that patching extra events, and call
> function with a negative parameter/argument value isn't that beautiful? 
> 
> Probably there is a rather simple solution to my problem, but since i
> used to "for, while and do loops" i really can't see it? 

Perhaps no one follows your virtually endless monologues.

While I could maybe answer a clearcut JS-Q, I am not your shrink.

So don't show your convoluted code, 
but construct up a simple code that *only* exhibits the problem.

Probably *then* you don't need us anymore.

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

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


#34937

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-29 15:45 -0700
Message-ID<7c8ccec7-9f8b-4fcc-96d7-d252cac263d3@googlegroups.com>
In reply to#34935
Den söndag 29 april 2018 kl. 22:14:56 UTC+2 skrev Evertjan.:
> <jonas.thornvall@gmail.com> wrote on 29
> Apr 2018 in comp.lang.javascript: 
> 
> > Maybe my explanation was to brief to be understood, and noone see the
> > problem? But can't you agree that patching extra events, and call
> > function with a negative parameter/argument value isn't that beautiful? 
> > 
> > Probably there is a rather simple solution to my problem, but since i
> > used to "for, while and do loops" i really can't see it? 
> 
> Perhaps no one follows your virtually endless monologues.
> 
> While I could maybe answer a clearcut JS-Q, I am not your shrink.
> 
> So don't show your convoluted code, 
> but construct up a simple code that *only* exhibits the problem.
> 
> Probably *then* you don't need us anymore.
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Well my waitlist was not generated correct, but now it is.
But the playup timing still shit despite microseconds?

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


#34938

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-29 15:47 -0700
Message-ID<93637300-edc4-4b5a-a304-4ccb02ede0a1@googlegroups.com>
In reply to#34937
Den måndag 30 april 2018 kl. 00:45:23 UTC+2 skrev Jonas Thörnvall:
> Den söndag 29 april 2018 kl. 22:14:56 UTC+2 skrev Evertjan.:
> > <jonas.thornvall@gmail.com> wrote on 29
> > Apr 2018 in comp.lang.javascript: 
> > 
> > > Maybe my explanation was to brief to be understood, and noone see the
> > > problem? But can't you agree that patching extra events, and call
> > > function with a negative parameter/argument value isn't that beautiful? 
> > > 
> > > Probably there is a rather simple solution to my problem, but since i
> > > used to "for, while and do loops" i really can't see it? 
> > 
> > Perhaps no one follows your virtually endless monologues.
> > 
> > While I could maybe answer a clearcut JS-Q, I am not your shrink.
> > 
> > So don't show your convoluted code, 
> > but construct up a simple code that *only* exhibits the problem.
> > 
> > Probably *then* you don't need us anymore.
> > 
> > -- 
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
> 
> Well my waitlist was not generated correct, but now it is.
> But the playup timing still shit despite microseconds?

function startplay(){ 
  compstring="";
  lastelement=track[tracknr].midiMess.length; 
  //Check if anything to play
  if(lastelement!=0){
     tracknr=0;
     playmidi=true;
     mode="Play";
     document.getElementById("status").value=mode;  
  
     //metInit();
     //countticks=setInterval(countInTimer,interval);

     playevents=waitEv;
     document.getElementById("keystream").value=playevents;
     pyp=-1;
     doPlayup();
  }
  pyp=-1;
} 

function doPlayup() {
  if (waitEv.length) {
      var waittime = waitEv.shift();
      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); 
    } 
    //else {  clearInterval(countticks); }
}

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


#34939

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-29 16:39 -0700
Message-ID<c9b41f7c-4133-4423-acf8-d0b20cdd8d83@googlegroups.com>
In reply to#34938
Den måndag 30 april 2018 kl. 00:47:17 UTC+2 skrev Jonas Thörnvall:
> Den måndag 30 april 2018 kl. 00:45:23 UTC+2 skrev Jonas Thörnvall:
> > Den söndag 29 april 2018 kl. 22:14:56 UTC+2 skrev Evertjan.:
> > > <jonas.thornvall@gmail.com> wrote on 29
> > > Apr 2018 in comp.lang.javascript: 
> > > 
> > > > Maybe my explanation was to brief to be understood, and noone see the
> > > > problem? But can't you agree that patching extra events, and call
> > > > function with a negative parameter/argument value isn't that beautiful? 
> > > > 
> > > > Probably there is a rather simple solution to my problem, but since i
> > > > used to "for, while and do loops" i really can't see it? 
> > > 
> > > Perhaps no one follows your virtually endless monologues.
> > > 
> > > While I could maybe answer a clearcut JS-Q, I am not your shrink.
> > > 
> > > So don't show your convoluted code, 
> > > but construct up a simple code that *only* exhibits the problem.
> > > 
> > > Probably *then* you don't need us anymore.
> > > 
> > > -- 
> > > Evertjan.
> > > The Netherlands.
> > > (Please change the x'es to dots in my emailaddress)
> > 
> > Well my waitlist was not generated correct, but now it is.
> > But the playup timing still shit despite microseconds?
> 
> function startplay(){ 
>   compstring="";
>   lastelement=track[tracknr].midiMess.length; 
>   //Check if anything to play
>   if(lastelement!=0){
>      tracknr=0;
>      playmidi=true;
>      mode="Play";
>      document.getElementById("status").value=mode;  
>   
>      //metInit();
>      //countticks=setInterval(countInTimer,interval);
> 
>      playevents=waitEv;
>      document.getElementById("keystream").value=playevents;
>      pyp=-1;
>      doPlayup();
>   }
>   pyp=-1;
> } 
> 
> function doPlayup() {
>   if (waitEv.length) {
>       var waittime = waitEv.shift();
>       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); 
>     } 
>     //else {  clearInterval(countticks); }
> }

To be honest i am clueless howto approach the problem.


function startplay(){ 
  compstring="";
  lastelement=track[tracknr].midiMess.length; 
  //Check if anything to play
  if(lastelement!=0){
     tracknr=0;
     playmidi=true;
     mode="Play";
     document.getElementById("status").value=mode;  
     //metInit();
     //countticks=setInterval(countInTimer,interval);
     playevents=waitEv;
     document.getElementById("keystream").value=playevents;
     pyp=0
     copyEv = waitEv.slice();	; 
     if (copyEv.length) {
        var waittime = copyEv.shift();
        setTimeout(doPlayup, waittime); 
        pyp++;
     } 
  }
} 

function doPlayup() {
      noteOnMessage = [track[tracknr].midiMess[pyp].data0, track[tracknr].midiMess[pyp].data1, track[tracknr].midiMess[pyp].data2]; 
      output.send(noteOnMessage); 
}

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


#34940

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-29 16:57 -0700
Message-ID<d62a500d-aa6d-4070-9cee-b422e707b478@googlegroups.com>
In reply to#34939
Den måndag 30 april 2018 kl. 01:39:42 UTC+2 skrev Jonas Thörnvall:
> Den måndag 30 april 2018 kl. 00:47:17 UTC+2 skrev Jonas Thörnvall:
> > Den måndag 30 april 2018 kl. 00:45:23 UTC+2 skrev Jonas Thörnvall:
> > > Den söndag 29 april 2018 kl. 22:14:56 UTC+2 skrev Evertjan.:
> > > > <jonas.thornvall@gmail.com> wrote on 29
> > > > Apr 2018 in comp.lang.javascript: 
> > > > 
> > > > > Maybe my explanation was to brief to be understood, and noone see the
> > > > > problem? But can't you agree that patching extra events, and call
> > > > > function with a negative parameter/argument value isn't that beautiful? 
> > > > > 
> > > > > Probably there is a rather simple solution to my problem, but since i
> > > > > used to "for, while and do loops" i really can't see it? 
> > > > 
> > > > Perhaps no one follows your virtually endless monologues.
> > > > 
> > > > While I could maybe answer a clearcut JS-Q, I am not your shrink.
> > > > 
> > > > So don't show your convoluted code, 
> > > > but construct up a simple code that *only* exhibits the problem.
> > > > 
> > > > Probably *then* you don't need us anymore.
> > > > 
> > > > -- 
> > > > Evertjan.
> > > > The Netherlands.
> > > > (Please change the x'es to dots in my emailaddress)
> > > 
> > > Well my waitlist was not generated correct, but now it is.
> > > But the playup timing still shit despite microseconds?
> > 
> > function startplay(){ 
> >   compstring="";
> >   lastelement=track[tracknr].midiMess.length; 
> >   //Check if anything to play
> >   if(lastelement!=0){
> >      tracknr=0;
> >      playmidi=true;
> >      mode="Play";
> >      document.getElementById("status").value=mode;  
> >   
> >      //metInit();
> >      //countticks=setInterval(countInTimer,interval);
> > 
> >      playevents=waitEv;
> >      document.getElementById("keystream").value=playevents;
> >      pyp=-1;
> >      doPlayup();
> >   }
> >   pyp=-1;
> > } 
> > 
> > function doPlayup() {
> >   if (waitEv.length) {
> >       var waittime = waitEv.shift();
> >       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); 
> >     } 
> >     //else {  clearInterval(countticks); }
> > }
> 
> To be honest i am clueless howto approach the problem.
> 
> 
> function startplay(){ 
>   compstring="";
>   lastelement=track[tracknr].midiMess.length; 
>   //Check if anything to play
>   if(lastelement!=0){
>      tracknr=0;
>      playmidi=true;
>      mode="Play";
>      document.getElementById("status").value=mode;  
>      //metInit();
>      //countticks=setInterval(countInTimer,interval);
>      playevents=waitEv;
>      document.getElementById("keystream").value=playevents;
>      pyp=0
>      copyEv = waitEv.slice();	; 
>      if (copyEv.length) {
>         var waittime = copyEv.shift();
>         setTimeout(doPlayup, waittime); 
>         pyp++;
>      } 
>   }
> } 
> 
> function doPlayup() {
>       noteOnMessage = [track[tracknr].midiMess[pyp].data0, track[tracknr].midiMess[pyp].data1, track[tracknr].midiMess[pyp].data2]; 
>       output.send(noteOnMessage); 
> }

Javascript just can not have the bad timing that i hear, so what am i doing wrong.

function startplay(){ 
  compstring="";
  lastelement=track[tracknr].midiMess.length; 
  //Check if anything to play
  if(lastelement!=0){
     tracknr=0;
     playmidi=true;
     mode="Play";
     document.getElementById("status").value=mode;  
     playevents=waitEv;
     document.getElementById("keystream").value=playevents;
     pyp=-1;
     copyEv = waitEv.slice();
     doPlayup();
  }
} 


function doPlayup() {
    if (copyEv.length) {
      var waittime = copyEv.shift();
      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); 
    } 
}

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


#34941

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-29 17:06 -0700
Message-ID<f31bd7b3-193b-4fd9-843b-c693ad785b64@googlegroups.com>
In reply to#34940
Den måndag 30 april 2018 kl. 01:57:49 UTC+2 skrev Jonas Thörnvall:
> Den måndag 30 april 2018 kl. 01:39:42 UTC+2 skrev Jonas Thörnvall:
> > Den måndag 30 april 2018 kl. 00:47:17 UTC+2 skrev Jonas Thörnvall:
> > > Den måndag 30 april 2018 kl. 00:45:23 UTC+2 skrev Jonas Thörnvall:
> > > > Den söndag 29 april 2018 kl. 22:14:56 UTC+2 skrev Evertjan.:
> > > > > <jonas.thornvall@gmail.com> wrote on 29
> > > > > Apr 2018 in comp.lang.javascript: 
> > > > > 
> > > > > > Maybe my explanation was to brief to be understood, and noone see the
> > > > > > problem? But can't you agree that patching extra events, and call
> > > > > > function with a negative parameter/argument value isn't that beautiful? 
> > > > > > 
> > > > > > Probably there is a rather simple solution to my problem, but since i
> > > > > > used to "for, while and do loops" i really can't see it? 
> > > > > 
> > > > > Perhaps no one follows your virtually endless monologues.
> > > > > 
> > > > > While I could maybe answer a clearcut JS-Q, I am not your shrink.
> > > > > 
> > > > > So don't show your convoluted code, 
> > > > > but construct up a simple code that *only* exhibits the problem.
> > > > > 
> > > > > Probably *then* you don't need us anymore.
> > > > > 
> > > > > -- 
> > > > > Evertjan.
> > > > > The Netherlands.
> > > > > (Please change the x'es to dots in my emailaddress)
> > > > 
> > > > Well my waitlist was not generated correct, but now it is.
> > > > But the playup timing still shit despite microseconds?
> > > 
> > > function startplay(){ 
> > >   compstring="";
> > >   lastelement=track[tracknr].midiMess.length; 
> > >   //Check if anything to play
> > >   if(lastelement!=0){
> > >      tracknr=0;
> > >      playmidi=true;
> > >      mode="Play";
> > >      document.getElementById("status").value=mode;  
> > >   
> > >      //metInit();
> > >      //countticks=setInterval(countInTimer,interval);
> > > 
> > >      playevents=waitEv;
> > >      document.getElementById("keystream").value=playevents;
> > >      pyp=-1;
> > >      doPlayup();
> > >   }
> > >   pyp=-1;
> > > } 
> > > 
> > > function doPlayup() {
> > >   if (waitEv.length) {
> > >       var waittime = waitEv.shift();
> > >       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); 
> > >     } 
> > >     //else {  clearInterval(countticks); }
> > > }
> > 
> > To be honest i am clueless howto approach the problem.
> > 
> > 
> > function startplay(){ 
> >   compstring="";
> >   lastelement=track[tracknr].midiMess.length; 
> >   //Check if anything to play
> >   if(lastelement!=0){
> >      tracknr=0;
> >      playmidi=true;
> >      mode="Play";
> >      document.getElementById("status").value=mode;  
> >      //metInit();
> >      //countticks=setInterval(countInTimer,interval);
> >      playevents=waitEv;
> >      document.getElementById("keystream").value=playevents;
> >      pyp=0
> >      copyEv = waitEv.slice();	; 
> >      if (copyEv.length) {
> >         var waittime = copyEv.shift();
> >         setTimeout(doPlayup, waittime); 
> >         pyp++;
> >      } 
> >   }
> > } 
> > 
> > function doPlayup() {
> >       noteOnMessage = [track[tracknr].midiMess[pyp].data0, track[tracknr].midiMess[pyp].data1, track[tracknr].midiMess[pyp].data2]; 
> >       output.send(noteOnMessage); 
> > }
> 
> Javascript just can not have the bad timing that i hear, so what am i doing wrong.
> 
> function startplay(){ 
>   compstring="";
>   lastelement=track[tracknr].midiMess.length; 
>   //Check if anything to play
>   if(lastelement!=0){
>      tracknr=0;
>      playmidi=true;
>      mode="Play";
>      document.getElementById("status").value=mode;  
>      playevents=waitEv;
>      document.getElementById("keystream").value=playevents;
>      pyp=-1;
>      copyEv = waitEv.slice();
>      doPlayup();
>   }
> } 
> 
> 
> function doPlayup() {
>     if (copyEv.length) {
>       var waittime = copyEv.shift();
>       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); 
>     } 
> }

There must be something weird when the echo to a formfield in script have better timing then the playup.

[toc] | [prev] | [standalone]


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


csiph-web