Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1119)

Unified Diff: third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp

Issue 2186813003: Sub-sample accurate start of OscillatorNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust thresholds for Mac 10.11 (retina) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/ConstantSourceNode.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
index ca484863958c8b70f9ba754a57702524fb52278e..25d724381734dea9e73c497c88add39840681ec2 100644
--- a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
@@ -239,9 +239,10 @@ void OscillatorHandler::process(size_t framesToProcess) {
size_t quantumFrameOffset;
size_t nonSilentFramesToProcess;
+ double startFrameOffset;
updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset,
- nonSilentFramesToProcess);
+ nonSilentFramesToProcess, startFrameOffset);
if (!nonSilentFramesToProcess) {
outputBus->zero();
@@ -286,6 +287,19 @@ void OscillatorHandler::process(size_t framesToProcess) {
destP += quantumFrameOffset;
int n = nonSilentFramesToProcess;
+ // If startFrameOffset is not 0, that means the oscillator doesn't actually
+ // start at quantumFrameOffset, but just past that time. Adjust destP and n
+ // to reflect that, and adjust virtualReadIndex to start the value at
+ // startFrameOffset.
+ if (startFrameOffset > 0) {
+ ++destP;
+ --n;
+ virtualReadIndex += (1 - startFrameOffset) * frequency * rateScale;
+ DCHECK(virtualReadIndex < periodicWaveSize);
+ } else if (startFrameOffset < 0) {
+ virtualReadIndex = -startFrameOffset * frequency * rateScale;
+ }
+
while (n--) {
unsigned readIndex = static_cast<unsigned>(virtualReadIndex);
unsigned readIndex2 = readIndex + 1;
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/ConstantSourceNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698