Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Making my own midinote sheduler? Date: Fri, 12 Mar 2021 15:03:16 +0100 Lines: 36 Message-ID: References: <8e156cd8-8f07-4fea-98bd-20dceb96c3afn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net 4VGOZaAJ8eOB4cMbwckDIA07uQ3oWiMzhX27Z8jQVOABUa6BVR Cancel-Lock: sha1:/ZuwDX2BU0aVAKmM4hFGabUGreU= In-Reply-To: <8e156cd8-8f07-4fea-98bd-20dceb96c3afn@googlegroups.com> Xref: csiph.com comp.lang.javascript:39626 Jonas Thörnvall: > function STARTPLAY2(){ > evTiming=copyEv[0]; > if (keepGoing) { > if (copyEv.length) { > //console.log(performance.now()-oldPerformance); > if(performance.now()-oldPerformance>evTiming){ > oldPerformance=window.performance.now(); > outportarr[outportindex].send(noteMessage.shift(),window.performance.now() + copyEv.shift()); > } > } > STARTPLAY2() > } > } > > This is my idea, but i do not want to use setTimeout or setInterval fo fire the recursion. Is there any other process i can use. If 16 ms between two events is fast enough, use window.requestAnimationFrame(). Also see: Example for the use to run an animation: The only downside is, that one frame is not always exactly 16 ms as this depends on the refresh rate of the display. On displays with 100 or 120 frames per second you only get 10 or 8+1/3 ms. -- Arno Welzel https://arnowelzel.de