Closed Bug 1248731 Opened 8 years ago Closed 8 years ago

Web Audio - oscillator playback inconsistent at small time intervals

Categories

(Core :: Web Audio, defect)

44 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1228207

People

(Reporter: jus7jusjus, Unassigned)

References

(Depends on 2 open bugs)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36

Steps to reproduce:

I created a simple JavaScript metronome using the Web Audio API. It plays a sine wave for .01s in order to simulate an audio "click", then repeats every 500ms.

1. In Firefox, navigate to http://codepen.io/schwenky/pen/rxRJwE?editors=0011
2. Press the "start" button
3. Listen to the playback of the metronome
4. Press the "stop" button
5. Repeat steps 1-4 in Chrome, Safari and Opera
6. Take note of the differences in sound between Firefox and the other 3 browsers


Actual results:

In Firefox, the playback is inconsistent and the timbre of the oscillator changes. 
In Chrome 48, Safari 9 and Opera 35, playback is consistent. 


Expected results:

The sound of the oscillator should be the same every time start() is fired, similar to the results in the other browsers.

As a test, try increasing the length of the oscillator by editing line 12 of the JavaScript panel, and changing ".01" to ".05". Then play the metronome in Firefox and notice that it's much more consistent.
Component: Untriaged → Web Audio
Product: Firefox → Core
Depends on: 956574, 1228207
karl, is this a dup of bug 1228207?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(karlt)
While not a exact dupe, there is probably not much point keeping this bug open separately.  With specified rendering blocks 3 ms in size, the minimum we could hope for in maximum scheduling delay would be 3 ms, whatever we do.  That is going to noticeable on a 10 ms sample.

What might work best here is using an offline context to pre-render to a 10ms AudioBuffer.  With AudioBufferSourceNode, the whole sample is always played.  Scheduling delays the whole sample, instead of just the start time.

Bug 1228207 covers coming up with a better solution that doesn't require pre-rendering of samples or envelopes.
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: needinfo?(karlt)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.