last day (15 days later) » 

12:04 AM
0
A: How to remedy web audio time relationship w/ setTimeout if still bad on FireFox

cwilsowindow.setTimeout() is in MILLISECONDS, not seconds. You need to setTimeout( scheduleFutureNode, 100).

 
When I changed it to reflect your answer it makes the timing worse and extends the bad timing to chrome.
 
Your code snippet above doesn't have enough context to tell what's going on; the general approach should work on Firefox, of course (the metronome demo does). Your code project isn't available at the referenced URL anymore.
 
Sorry about that. I fixed it and the code is now viewable in the url.I'll go ahead and create a jsfiddle as well albeit it will be a bit bloated and non working since it uses audio buffers. Thanks for taking the time. jsfiddle.net/r85qjntz/2
 
Ah. Yeah, the problem is that you're not passing the start time (the "time" parameter to your playFutureNote() method in to your checkIfRecordedAndPlay() method calls (and then in to your .play() calls on the sounds).
Remember, what you're trying to do is pre-SCHEDULE the starts of those buffers; they're supposed to actually START at some point in the future (over the next 100ms or so). Your current code just gets called every 100ms (or would, if you changed the param as above), and then sets up any sound start()s for the proper time in the next 100ms. Your current code checks for any starts that should occur in the next 100ms, and then IMMEDIATELY start()s that sound.
I think the reason it was working in Chrome before is that we probably aren't throttling your sub-millisecond calls into setTimeout; so you're calling your callback a TON - (every millisecond, or however often it can) - so the sounds are start()ed at "roughly" consistent intervals. In Firefox, they're probably throttling, so the intervals aren't consistently lining up with the note starts.
 
I tried to decipher what you just said and modify the code accordingly but it simply breaks everything. Is there an example you could post what I could change to make it work correctly ?
I put the 'time' argument in checkIfRecordedAndPlay and then I modified my buffer sound loader to have an argument that sets the start time and I placed the 'time' argument in the invoked sound function
Actually I did my best to understand what you said and it works in chrome but completely breaks in firefox
...and when I change the millisecond value to 100 the timing in chrome still goes bad
 
12:23 AM
________________________________
 
12:39 AM
Latest attempt: jsfiddle.net/74axq2Lt/1
still not working
 
 
17 hours later…
5:56 PM
As a side note this code is the template I used to make my code. It is a striped down version of your metronome. When I change its setInterval to 100 the timing is affected by small changes in browser size and window redraws. github.com/wktdev/Web-audio-note-scheduling-template/blob/… so I'm wondering if my initial pattern for coding this was wrong altogether. I'm very confused about all of this now as I thought I understood how this worked
 
 
2 hours later…
8:21 PM
In your metronome example it's been updated since I last looked at it and it now includes a web worker, I don't understand how web workers work and it's making it difficult to understand the new example. I'm curious if this 'worker' script is necessary for better timing or if it's just for messaging purposes.
If its just there for messaging purposes it makes the example harder to understand because I can't figure out how to decouple the scheduler function from it
 

  last day (15 days later) »