Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37493 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2019-10-03 04:11 -0700 |
| Last post | 2019-10-05 15:44 -0700 |
| Articles | 9 — 4 participants |
Back to article view | Back to comp.lang.javascript
setTimeout( ), with startpoint at t0 Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-10-03 04:11 -0700
Re: setTimeout( ), with startpoint at t0 JJ <jj4public@vfemail.net> - 2019-10-03 19:41 +0700
Re: setTimeout( ), with startpoint at t0 Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-10-03 08:34 -0700
Re: setTimeout( ), with startpoint at t0 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-10-03 21:53 +0200
Re: setTimeout( ), with startpoint at t0 Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-10-03 14:58 -0700
Re: setTimeout( ), with startpoint at t0 Arno Welzel <usenet@arnowelzel.de> - 2019-10-04 13:50 +0200
Re: setTimeout( ), with startpoint at t0 Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-10-04 07:33 -0700
Re: setTimeout( ), with startpoint at t0 Arno Welzel <usenet@arnowelzel.de> - 2019-10-05 13:58 +0200
Re: setTimeout( ), with startpoint at t0 Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-10-05 15:44 -0700
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-10-03 04:11 -0700 |
| Subject | setTimeout( ), with startpoint at t0 |
| Message-ID | <6ff17c5f-0702-4fef-8f1d-51c44a54fad6@googlegroups.com> |
stopRec=setTimeout(STARTREC,interval); Basicly i want first call immediatly at t0, but this first call will happen after interval? I tried this. stopRec=setTimeout(STARTREC,0*interval); But i am not sure it works like i think? Jonas T
[toc] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2019-10-03 19:41 +0700 |
| Message-ID | <1p7dto6a1nwy0$.1qju8k84zm1j5$.dlg@40tude.net> |
| In reply to | #37493 |
On Thu, 3 Oct 2019 04:11:51 -0700 (PDT), Jonas Thörnvall wrote: > stopRec=setTimeout(STARTREC,interval); > > Basicly i want first call immediatly at t0, but this first call will happen after interval? > > I tried this. > stopRec=setTimeout(STARTREC,0*interval); > But i am not sure it works like i think? > > Jonas T setTimeout and setInterval merely create timer events. None of them immediately execute the timer callbacks. If you use zero time duration, the callback is basically queued into the execution flow and will only be executed after the current execution flow ends, where the JavaScript engine goes into idle state.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-10-03 08:34 -0700 |
| Message-ID | <af7db9d2-270c-4275-a45c-13eb966309b9@googlegroups.com> |
| In reply to | #37494 |
Den torsdag 3 oktober 2019 kl. 14:41:44 UTC+2 skrev JJ: > On Thu, 3 Oct 2019 04:11:51 -0700 (PDT), Jonas Thörnvall wrote: > > stopRec=setTimeout(STARTREC,interval); > > > > Basicly i want first call immediatly at t0, but this first call will happen after interval? > > > > I tried this. > > stopRec=setTimeout(STARTREC,0*interval); > > But i am not sure it works like i think? > > > > Jonas T > > setTimeout and setInterval merely create timer events. None of them > immediately execute the timer callbacks. > > If you use zero time duration, the callback is basically queued into the > execution flow and will only be executed after the current execution flow > ends, where the JavaScript engine goes into idle state. It is a bit weird though if you write, 8*interval "just the first call will take 8 times interval"?
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-10-03 21:53 +0200 |
| Message-ID | <XnsAADDDEBBDA9EAeejj99@194.109.6.166> |
| In reply to | #37495 |
<jonas.thornvall@gmail.com> wrote on 03 Oct 2019 in comp.lang.javascript:
> It is a bit weird though if you write, 8*interval "just the first call
> will take 8 times interval"?
If you think so, don't do it!
=======
Seems to me you are mixing setTimeout() and setInterval() ideas.
setTimeout() strictly has no "interval-time", as it fires only once at most.
If you construct an repeated happening starting at time zero,
the called function should set the setTimeout() again.
========= Using setTimeout():
=========
let timeoutPointer;
const timeoutFunction = () => {
doWhatYouWantItToDo();
timeoutPointer = setTimeout(timeoutFunction,100);
};
timeoutFunction();
==========
A problem could arize here, as doWhatYouWantItToDo() time spend is added to
the repeat time each time. Timing of multiple repeates is inexact in total,
the time between individual repeates is rather exact.
========= Using setInterval():
=========
let intervalPointer;
const intervalFunction = () => {
doWhatYouWantItToDo();
};
intervalPointer = setInterval(intervalFunction,100);
intervalFunction(); /* FIRST TIME ONLY */
==========
A problem could arize here, as doWhatYouWantItToDo() time spend overruns the
repeat time, and you could even have 2 versions in the queue running
directly after eachother. Timing of multiple repeates is rather exact,
individual firings in the queue could be far of.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-10-03 14:58 -0700 |
| Message-ID | <d75aaf42-6a0a-4968-996d-ef38ec7894eb@googlegroups.com> |
| In reply to | #37496 |
Den torsdag 3 oktober 2019 kl. 21:53:47 UTC+2 skrev Evertjan.:
> <jonas.thornvall@gmail.com> wrote on 03 Oct 2019 in comp.lang.javascript:
>
> > It is a bit weird though if you write, 8*interval "just the first call
> > will take 8 times interval"?
>
> If you think so, don't do it!
>
> =======
>
> Seems to me you are mixing setTimeout() and setInterval() ideas.
>
> setTimeout() strictly has no "interval-time", as it fires only once at most.
>
> If you construct an repeated happening starting at time zero,
> the called function should set the setTimeout() again.
>
> ========= Using setTimeout():
>
> =========
> let timeoutPointer;
> const timeoutFunction = () => {
> doWhatYouWantItToDo();
> timeoutPointer = setTimeout(timeoutFunction,100);
> };
> timeoutFunction();
> ==========
>
> A problem could arize here, as doWhatYouWantItToDo() time spend is added to
> the repeat time each time. Timing of multiple repeates is inexact in total,
> the time between individual repeates is rather exact.
>
> ========= Using setInterval():
>
> =========
> let intervalPointer;
> const intervalFunction = () => {
> doWhatYouWantItToDo();
> };
> intervalPointer = setInterval(intervalFunction,100);
> intervalFunction(); /* FIRST TIME ONLY */
> ==========
>
> A problem could arize here, as doWhatYouWantItToDo() time spend overruns the
> repeat time, and you could even have 2 versions in the queue running
> directly after eachother. Timing of multiple repeates is rather exact,
> individual firings in the queue could be far of.
>
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
Yeah you are correct Evertjan i mixed it up, "a timeout called a interval", and i got confused about what was going on.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2019-10-04 13:50 +0200 |
| Message-ID | <gvoq07Fgr63U1@mid.individual.net> |
| In reply to | #37493 |
On 03.10.19 13:11, Jonas Thörnvall wrote: > stopRec=setTimeout(STARTREC,interval); > > Basicly i want first call immediatly at t0, but this first call will happen after interval? What is "t0"? What is "STARTREC"? > I tried this. > stopRec=setTimeout(STARTREC,0*interval); > But i am not sure it works like i think? See <https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout> -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-10-04 07:33 -0700 |
| Message-ID | <2270c2cc-48a6-48eb-b7bd-113ccfbb7186@googlegroups.com> |
| In reply to | #37498 |
Den fredag 4 oktober 2019 kl. 13:50:36 UTC+2 skrev Arno Welzel: > On 03.10.19 13:11, Jonas Thörnvall wrote: > > > stopRec=setTimeout(STARTREC,interval); > > > > Basicly i want first call immediatly at t0, but this first call will happen after interval? > > What is "t0"? What is "STARTREC"? > > > I tried this. > > stopRec=setTimeout(STARTREC,0*interval); > > But i am not sure it works like i think? > > See > <https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout> > > > -- > Arno Welzel > https://arnowelzel.de Well t0 is Time zero 0 ms, what startRec is, is not interesting. If you want to find out look here. https://midisequenser.000webhostapp.com/ I made a corrector for recording latency today. If you have a music keyboard try it, but maybe there is no. On my computers there is none or rather negative for some reason seems impossible. But if you have you can correct "the music you play up, vs the midi you play in".
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2019-10-05 13:58 +0200 |
| Message-ID | <gvreqqF37pjU1@mid.individual.net> |
| In reply to | #37499 |
Jonas Thörnvall: > Den fredag 4 oktober 2019 kl. 13:50:36 UTC+2 skrev Arno Welzel: >> On 03.10.19 13:11, Jonas Thörnvall wrote: >> >>> stopRec=setTimeout(STARTREC,interval); >>> >>> Basicly i want first call immediatly at t0, but this first call will happen after interval? >> >> What is "t0"? What is "STARTREC"? >> >>> I tried this. >>> stopRec=setTimeout(STARTREC,0*interval); >>> But i am not sure it works like i think? >> >> See >> <https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout> >> >> >> -- >> Arno Welzel >> https://arnowelzel.de > > Well t0 is Time zero 0 ms, what startRec is, is not interesting. If you want to find out look here. Why do you even use setTimeout() then and not just call STARTREC directly? -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-10-05 15:44 -0700 |
| Message-ID | <fb3ecd03-9ca0-4b68-8a70-7676d833c0ab@googlegroups.com> |
| In reply to | #37501 |
Den lördag 5 oktober 2019 kl. 13:58:25 UTC+2 skrev Arno Welzel:
> Jonas Thörnvall:
>
> > Den fredag 4 oktober 2019 kl. 13:50:36 UTC+2 skrev Arno Welzel:
> >> On 03.10.19 13:11, Jonas Thörnvall wrote:
> >>
> >>> stopRec=setTimeout(STARTREC,interval);
> >>>
> >>> Basicly i want first call immediatly at t0, but this first call will happen after interval?
> >>
> >> What is "t0"? What is "STARTREC"?
> >>
> >>> I tried this.
> >>> stopRec=setTimeout(STARTREC,0*interval);
> >>> But i am not sure it works like i think?
> >>
> >> See
> >> <https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout>
> >>
> >>
> >> --
> >> Arno Welzel
> >> https://arnowelzel.de
> >
> > Well t0 is Time zero 0 ms, what startRec is, is not interesting. If you want to find out look here.
>
> Why do you even use setTimeout() then and not just call STARTREC directly?
>
>
> --
> Arno Welzel
> https://arnowelzel.de
Well i think it is leftover from when recording and play was separate, and i still use the clearTimeout to stop a scrollbar animation and the playup of metronome.
if (tottime>re){ clearTimeout(stopRec);STOPREC();}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web