Improve oscillator waveforms at low frequency. |
||
Issue description
Consider the following two cases.
Case 1:
wav1 = new PeriodicWave(context, {imag: [0, 1]});
osc1 = new OscillatorNode(context, {frequency: 440, periodicWave: wav1});
osc1.connect(context);
osc1.start();
Case 2:
c = new Float32Array(8192);
c[440] = 1;
wav2 = new PeriodicWave(context, {imag: c, disableNormalization: true});
osc2 = new OscillatorNode(context, {frequency: 1, periodicWave: wav2});
osc2.connect(context);
osc2.start();
In both cases, the output of the oscillator should be a pure 440-Hz sine wave.
But this is not the case. The output from osc2 is distinctly not a pure sine-wave. It appears to have linear sections. (You can see this by running the above snippets at hoch.github.io/canopy.)
The problem is that the linear interpolation that is done is not very accurate for case 2. We should consider improving it.
,
Oct 19 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/54eca3bdef6c06bfa6641088d6273350c2f9f197 commit 54eca3bdef6c06bfa6641088d6273350c2f9f197 Author: Alice Boxhall <aboxhall@chromium.org> Date: Thu Oct 19 23:57:43 2017 Revert "Better interpolation of oscillator at low frequencies" This reverts commit 65d5003859b82feec4fbcdfa222364459388c9de. Reason for revert: Causing LayoutTest failures e.g. https://uberchromegw.corp.google.com/i/chromium.mac/builders/Mac10.10%20Tests/builds/25167 Original change's description: > Better interpolation of oscillator at low frequencies > > For low frequencies, use a 3-point or 5-point Lagrange interpolation > scheme to improve the accuracy of the oscillator instead of using > simple linear interpolation. > > For a typical context, the linear interpolator is used if the > frequency >= 3.2 Hz; the 3-point, for 3.2 > frequency > 1.7 Hz; and > the 5-point for all other cases. Thus, typical use-cases are not > impaired by this change. > > Some benchmark results from running an oscillator for 1000 seconds in an > offline context. This is the time measured from startRendering() > until the promise is delivered. The SNR is the measured SNR between > the test signal and a reference 440 Hz signal. The linear time was > the same before and after this CL. > > linear: > time: 1844.6 ms, stddev: 154.4 > SNR: 27.7 dB > > 3-point: > time: 2426.5 ms, stddev: 265.0 > SNR: 37.2 dB > > 5-point: > time: 2752.6 ms, stddev: 215.1 > SNR: 59.3 dB > > 7-point (for reference, not used now): > time: 3239.4 ms, stddev: 263.8 > SNR: 82.5 dB > > Bug: 773507 > Test: Oscillator/osc-440hz.html > Change-Id: Ib49fab4fb27738f4f02bd41f8adcc2e3b2dd2137 > Reviewed-on: https://chromium-review.googlesource.com/713576 > Commit-Queue: Raymond Toy <rtoy@chromium.org> > Reviewed-by: Hongchan Choi <hongchan@chromium.org> > Cr-Commit-Position: refs/heads/master@{#510133} TBR=rtoy@chromium.org,hongchan@chromium.org Change-Id: If59bb7f8169b077c35e5d735c6f6f19cc780d512 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 773507 Reviewed-on: https://chromium-review.googlesource.com/729719 Reviewed-by: Alice Boxhall <aboxhall@chromium.org> Commit-Queue: Alice Boxhall <aboxhall@chromium.org> Cr-Commit-Position: refs/heads/master@{#510257} [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data.html [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-modulation-expected.wav [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-modulation.html [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-modulation-expected.wav [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-modulation.html [delete] https://crrev.com/69e46ae5a0e16ed23e01ce2abc285d2e5c2d2ae7/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-440hz.html [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-sweep-snr-custom.html [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-sweep-snr-triangle.html [modify] https://crrev.com/54eca3bdef6c06bfa6641088d6273350c2f9f197/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
,
Oct 20 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/bcab1e863dbd5856d364e984cb72682721eca514 commit bcab1e863dbd5856d364e984cb72682721eca514 Author: Raymond Toy <rtoy@chromium.org> Date: Fri Oct 20 17:54:50 2017 Reland "Better interpolation of oscillator at low frequencies" This is a reland of 65d5003859b82feec4fbcdfa222364459388c9de Original change's description: > Better interpolation of oscillator at low frequencies > > For low frequencies, use a 3-point or 5-point Lagrange interpolation > scheme to improve the accuracy of the oscillator instead of using > simple linear interpolation. > > For a typical context, the linear interpolator is used if the > frequency >= 3.2 Hz; the 3-point, for 3.2 > frequency > 1.7 Hz; and > the 5-point for all other cases. Thus, typical use-cases are not > impaired by this change. > > Some benchmark results from running an oscillator for 1000 seconds in an > offline context. This is the time measured from startRendering() > until the promise is delivered. The SNR is the measured SNR between > the test signal and a reference 440 Hz signal. The linear time was > the same before and after this CL. > > linear: > time: 1844.6 ms, stddev: 154.4 > SNR: 27.7 dB > > 3-point: > time: 2426.5 ms, stddev: 265.0 > SNR: 37.2 dB > > 5-point: > time: 2752.6 ms, stddev: 215.1 > SNR: 59.3 dB > > 7-point (for reference, not used now): > time: 3239.4 ms, stddev: 263.8 > SNR: 82.5 dB > > Bug: 773507 > Test: Oscillator/osc-440hz.html > Change-Id: Ib49fab4fb27738f4f02bd41f8adcc2e3b2dd2137 > Reviewed-on: https://chromium-review.googlesource.com/713576 > Commit-Queue: Raymond Toy <rtoy@chromium.org> > Reviewed-by: Hongchan Choi <hongchan@chromium.org> > Cr-Commit-Position: refs/heads/master@{#510133} Bug: 773507 Test: Oscillator/osc-440hz.html Change-Id: I6882358e1fe49ee662ee2eccd25bce80e81e2829 Reviewed-on: https://chromium-review.googlesource.com/731027 Reviewed-by: Hongchan Choi <hongchan@chromium.org> Commit-Queue: Raymond Toy <rtoy@chromium.org> Cr-Commit-Position: refs/heads/master@{#510485} [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data.html [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-modulation-expected.wav [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-modulation.html [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-modulation-expected.wav [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-modulation.html [add] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-440hz.html [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-sweep-snr-custom.html [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-sweep-snr-triangle.html [modify] https://crrev.com/bcab1e863dbd5856d364e984cb72682721eca514/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
,
Oct 23 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by bugdroid1@chromium.org
, Oct 19 2017