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

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

Issue 18182009: WaveTable name has changed to PeriodicWave (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix global constructors test Created 7 years, 6 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 | « Source/modules/webaudio/OscillatorNode.h ('k') | Source/modules/webaudio/OscillatorNode.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/OscillatorNode.cpp
diff --git a/Source/modules/webaudio/OscillatorNode.cpp b/Source/modules/webaudio/OscillatorNode.cpp
index 9c0edabf2dfc15344e5fd0880b814244077e6e4d..a3d12a8e75fb41c42d24a799d3cc64e667359e4c 100644
--- a/Source/modules/webaudio/OscillatorNode.cpp
+++ b/Source/modules/webaudio/OscillatorNode.cpp
@@ -33,7 +33,7 @@
#include "core/platform/audio/VectorMath.h"
#include "modules/webaudio/AudioContext.h"
#include "modules/webaudio/AudioNodeOutput.h"
-#include "modules/webaudio/WaveTable.h"
+#include "modules/webaudio/PeriodicWave.h"
#include <algorithm>
#include "wtf/MathExtras.h"
@@ -43,10 +43,10 @@ namespace WebCore {
using namespace VectorMath;
-WaveTable* OscillatorNode::s_waveTableSine = 0;
-WaveTable* OscillatorNode::s_waveTableSquare = 0;
-WaveTable* OscillatorNode::s_waveTableSawtooth = 0;
-WaveTable* OscillatorNode::s_waveTableTriangle = 0;
+PeriodicWave* OscillatorNode::s_periodicWaveSine = 0;
+PeriodicWave* OscillatorNode::s_periodicWaveSquare = 0;
+PeriodicWave* OscillatorNode::s_periodicWaveSawtooth = 0;
+PeriodicWave* OscillatorNode::s_periodicWaveTriangle = 0;
PassRefPtr<OscillatorNode> OscillatorNode::create(AudioContext* context, float sampleRate)
{
@@ -118,38 +118,38 @@ void OscillatorNode::setType(const String& type)
bool OscillatorNode::setType(unsigned type)
{
- WaveTable* waveTable = 0;
+ PeriodicWave* periodicWave = 0;
float sampleRate = this->sampleRate();
switch (type) {
case SINE:
- if (!s_waveTableSine)
- s_waveTableSine = WaveTable::createSine(sampleRate).leakRef();
- waveTable = s_waveTableSine;
+ if (!s_periodicWaveSine)
+ s_periodicWaveSine = PeriodicWave::createSine(sampleRate).leakRef();
+ periodicWave = s_periodicWaveSine;
break;
case SQUARE:
- if (!s_waveTableSquare)
- s_waveTableSquare = WaveTable::createSquare(sampleRate).leakRef();
- waveTable = s_waveTableSquare;
+ if (!s_periodicWaveSquare)
+ s_periodicWaveSquare = PeriodicWave::createSquare(sampleRate).leakRef();
+ periodicWave = s_periodicWaveSquare;
break;
case SAWTOOTH:
- if (!s_waveTableSawtooth)
- s_waveTableSawtooth = WaveTable::createSawtooth(sampleRate).leakRef();
- waveTable = s_waveTableSawtooth;
+ if (!s_periodicWaveSawtooth)
+ s_periodicWaveSawtooth = PeriodicWave::createSawtooth(sampleRate).leakRef();
+ periodicWave = s_periodicWaveSawtooth;
break;
case TRIANGLE:
- if (!s_waveTableTriangle)
- s_waveTableTriangle = WaveTable::createTriangle(sampleRate).leakRef();
- waveTable = s_waveTableTriangle;
+ if (!s_periodicWaveTriangle)
+ s_periodicWaveTriangle = PeriodicWave::createTriangle(sampleRate).leakRef();
+ periodicWave = s_periodicWaveTriangle;
break;
case CUSTOM:
default:
- // Return error for invalid types, including CUSTOM since setWaveTable() method must be
+ // Return error for invalid types, including CUSTOM since setPeriodicWave() method must be
// called explicitly.
return false;
}
- setWaveTable(waveTable);
+ setPeriodicWave(periodicWave);
m_type = type;
return true;
}
@@ -171,7 +171,7 @@ bool OscillatorNode::calculateSampleAccuratePhaseIncrements(size_t framesToProce
bool hasFrequencyChanges = false;
float* phaseIncrements = m_phaseIncrements.data();
- float finalScale = m_waveTable->rateScale();
+ float finalScale = m_periodicWave->rateScale();
if (m_frequency->hasSampleAccurateValues()) {
hasSampleAccurateValues = true;
@@ -241,8 +241,8 @@ void OscillatorNode::process(size_t framesToProcess)
return;
}
- // We must access m_waveTable only inside the lock.
- if (!m_waveTable.get()) {
+ // We must access m_periodicWave only inside the lock.
+ if (!m_periodicWave.get()) {
outputBus->zero();
return;
}
@@ -257,8 +257,8 @@ void OscillatorNode::process(size_t framesToProcess)
return;
}
- unsigned waveTableSize = m_waveTable->waveTableSize();
- double invWaveTableSize = 1.0 / waveTableSize;
+ unsigned periodicWaveSize = m_periodicWave->periodicWaveSize();
+ double invPeriodicWaveSize = 1.0 / periodicWaveSize;
float* destP = outputBus->channel(0)->mutableData();
@@ -267,7 +267,7 @@ void OscillatorNode::process(size_t framesToProcess)
// We keep virtualReadIndex double-precision since we're accumulating values.
double virtualReadIndex = m_virtualReadIndex;
- float rateScale = m_waveTable->rateScale();
+ float rateScale = m_periodicWave->rateScale();
float invRateScale = 1 / rateScale;
bool hasSampleAccurateValues = calculateSampleAccuratePhaseIncrements(framesToProcess);
@@ -281,13 +281,13 @@ void OscillatorNode::process(size_t framesToProcess)
float detune = m_detune->smoothedValue();
float detuneScale = powf(2, detune / 1200);
frequency *= detuneScale;
- m_waveTable->waveDataForFundamentalFrequency(frequency, lowerWaveData, higherWaveData, tableInterpolationFactor);
+ m_periodicWave->waveDataForFundamentalFrequency(frequency, lowerWaveData, higherWaveData, tableInterpolationFactor);
}
float incr = frequency * rateScale;
float* phaseIncrements = m_phaseIncrements.data();
- unsigned readIndexMask = waveTableSize - 1;
+ unsigned readIndexMask = periodicWaveSize - 1;
// Start rendering at the correct offset.
destP += quantumFrameOffset;
@@ -305,7 +305,7 @@ void OscillatorNode::process(size_t framesToProcess)
incr = *phaseIncrements++;
frequency = invRateScale * incr;
- m_waveTable->waveDataForFundamentalFrequency(frequency, lowerWaveData, higherWaveData, tableInterpolationFactor);
+ m_periodicWave->waveDataForFundamentalFrequency(frequency, lowerWaveData, higherWaveData, tableInterpolationFactor);
}
float sample1Lower = lowerWaveData[readIndex];
@@ -323,9 +323,9 @@ void OscillatorNode::process(size_t framesToProcess)
*destP++ = sample;
- // Increment virtual read index and wrap virtualReadIndex into the range 0 -> waveTableSize.
+ // Increment virtual read index and wrap virtualReadIndex into the range 0 -> periodicWaveSize.
virtualReadIndex += incr;
- virtualReadIndex -= floor(virtualReadIndex * invWaveTableSize) * waveTableSize;
+ virtualReadIndex -= floor(virtualReadIndex * invPeriodicWaveSize) * periodicWaveSize;
}
m_virtualReadIndex = virtualReadIndex;
@@ -338,19 +338,19 @@ void OscillatorNode::reset()
m_virtualReadIndex = 0;
}
-void OscillatorNode::setWaveTable(WaveTable* waveTable)
+void OscillatorNode::setPeriodicWave(PeriodicWave* periodicWave)
{
ASSERT(isMainThread());
// This synchronizes with process().
MutexLocker processLocker(m_processLock);
- m_waveTable = waveTable;
+ m_periodicWave = periodicWave;
m_type = CUSTOM;
}
bool OscillatorNode::propagatesSilence() const
{
- return !isPlayingOrScheduled() || hasFinished() || !m_waveTable.get();
+ return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get();
}
} // namespace WebCore
« no previous file with comments | « Source/modules/webaudio/OscillatorNode.h ('k') | Source/modules/webaudio/OscillatorNode.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698