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


Groups > comp.lang.javascript > #34947

Re: Bad timing

Newsgroups comp.lang.javascript
Date 2018-04-30 06:20 -0700
References <a26c44bd-b0d4-4b35-90cb-419d73f9f42c@googlegroups.com> <4qa10u801489.jvohomgjs5av$.dlg@40tude.net> <01218288-76d8-4db0-bded-fe9e831653c3@googlegroups.com> <2ea1821b-75a4-46f7-b19f-b13ee4b89a7f@googlegroups.com>
Message-ID <06449225-8f3c-4587-80fa-e8c8bf37c4fe@googlegroups.com> (permalink)
Subject Re: Bad timing
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


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);}
}

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


Thread

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

csiph-web