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


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

Bad timing

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2018-04-29 17:27 -0700
Last post2018-04-30 06:20 -0700
Articles 2 on this page of 22 — 5 participants

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


Contents

  Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 17:27 -0700
    Re: Bad timing JJ <jj4public@vfemail.net> - 2018-04-30 10:43 +0700
      Re: Bad timing Julio Di Egidio <julio@diegidio.name> - 2018-04-30 00:24 -0700
        Re: Bad timing "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-04-30 13:01 -0700
          Re: Bad timing Julio Di Egidio <julio@diegidio.name> - 2018-04-30 17:04 -0700
            Re: Bad timing Julio Di Egidio <julio@diegidio.name> - 2018-05-01 04:33 -0700
          Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 18:24 -0700
            Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 18:32 -0700
              Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 18:44 -0700
                Re: Bad timing "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-05-01 10:29 +0200
                  Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 14:48 -0700
                  Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 14:54 -0700
                    Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 22:12 -0700
                    Re: Bad timing "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-05-02 11:29 +0200
                      Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-03 23:35 -0700
                        Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-03 23:38 -0700
                          Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-03 23:53 -0700
                            Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-04 00:49 -0700
                  Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 23:11 -0700
      Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 00:43 -0700
        Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 00:47 -0700
          Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 06:20 -0700

Page 2 of 2 — ← Prev page 1 [2]


#34946

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-30 00:47 -0700
Message-ID<2ea1821b-75a4-46f7-b19f-b13ee4b89a7f@googlegroups.com>
In reply to#34945
Den måndag 30 april 2018 kl. 09:43:21 UTC+2 skrev Jonas Thörnvall:
> Den måndag 30 april 2018 kl. 05:43:13 UTC+2 skrev JJ:
> > On Sun, 29 Apr 2018 17:27:27 -0700 (PDT), Jonas Thörnvall wrote:
> > > Is there a reason for the function below to have bad timing? 
> > > The copyEv hold microseconds.
> > > 
> > > function doPlayup() {
> > >     if (copyEv.length-1) {
> > >       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); 
> > >     } 
> > > }
> > 
> > You should do that in a worker thread instead of the main thread, because
> > the main thread does many thing (e.g. DOM events, page rendering, etc.)
> > which may cause queued timer (including event) handler executions to be
> > postponed.
> 
> 
> 
> Well i never experience any timing issues when i just echo the the signal to port "play live". It is just one condition, one shift and one counter add.
> 
> Of course there is a possibility that the timing issues comes from the recording path i have no external sequenser, so it is hard to check.
> 
> function record(message){
>  clock=clock+rs;
>  midievent++;
>    track[tracknr].midiMess.push({time:clock,data0:message.data[0],data1:message.data[1],data2:message.data[2]});
>   x++; 
>  console.log("Track="+tracknr);
> }

Maybe it is the concole.log causing it, i will remove it.

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


#34947

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-04-30 06:20 -0700
Message-ID<06449225-8f3c-4587-80fa-e8c8bf37c4fe@googlegroups.com>
In reply to#34946
Den måndag 30 april 2018 kl. 09:47:48 UTC+2 skrev Jonas Thörnvall:
> Den måndag 30 april 2018 kl. 09:43:21 UTC+2 skrev Jonas Thörnvall:
> > Den måndag 30 april 2018 kl. 05:43:13 UTC+2 skrev JJ:
> > > On Sun, 29 Apr 2018 17:27:27 -0700 (PDT), Jonas Thörnvall wrote:
> > > > Is there a reason for the function below to have bad timing? 
> > > > The copyEv hold microseconds.
> > > > 
> > > > function doPlayup() {
> > > >     if (copyEv.length-1) {
> > > >       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); 
> > > >     } 
> > > > }
> > > 
> > > You should do that in a worker thread instead of the main thread, because
> > > the main thread does many thing (e.g. DOM events, page rendering, etc.)
> > > which may cause queued timer (including event) handler executions to be
> > > postponed.
> > 
> > 
> > 
> > Well i never experience any timing issues when i just echo the the signal to port "play live". It is just one condition, one shift and one counter add.
> > 
> > Of course there is a possibility that the timing issues comes from the recording path i have no external sequenser, so it is hard to check.
> > 
> > function record(message){
> >  clock=clock+rs;
> >  midievent++;
> >    track[tracknr].midiMess.push({time:clock,data0:message.data[0],data1:message.data[1],data2:message.data[2]});
> >   x++; 
> >  console.log("Track="+tracknr);
> > }
> 
> Maybe it is the concole.log causing it, i will remove it.

I think it could be in the recording part, but the extra code for record vs just echo the note to port is so small, it is hard to see how it actually could effect anything.

function onMIDIMessage (message) {
  clock=performance.now()-Rstarttime;
  playbackPort(message);
  record(message);
  if (echo){MidiMessage(message);}
}

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

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


csiph-web