https://bugs.webkit.org/show_bug.cgi?id=85905
Reviewed by James Robinson.
No new tests. This is a low-level re-factoring and is covered by existing tests.
* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::AudioBufferSourceNode):
* Modules/webaudio/AudioGain.h:
(WebCore::AudioGain::create):
(WebCore::AudioGain::AudioGain):
* Modules/webaudio/AudioGainNode.cpp:
(WebCore::AudioGainNode::AudioGainNode):
* Modules/webaudio/AudioPannerNode.cpp:
(WebCore::AudioPannerNode::AudioPannerNode):
* Modules/webaudio/AudioParam.h:
(WebCore::AudioParam::create):
(AudioParam):
(WebCore::AudioParam::AudioParam):
* Modules/webaudio/BiquadFilterNode.cpp:
(WebCore::BiquadFilterNode::BiquadFilterNode):
* Modules/webaudio/BiquadProcessor.cpp:
(WebCore::BiquadProcessor::BiquadProcessor):
* Modules/webaudio/BiquadProcessor.h:
* Modules/webaudio/DelayNode.cpp:
(WebCore::DelayNode::DelayNode):
* Modules/webaudio/DelayProcessor.cpp:
(WebCore::DelayProcessor::DelayProcessor):
* Modules/webaudio/DelayProcessor.h:
(DelayProcessor):
* Modules/webaudio/DynamicsCompressorNode.cpp:
(WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
* Modules/webaudio/Oscillator.cpp:
(WebCore::Oscillator::Oscillator):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116485
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-05-08 Chris Rogers <crogers@google.com>
+
+ AudioParam should directly be given context in create() method
+ https://bugs.webkit.org/show_bug.cgi?id=85905
+
+ Reviewed by James Robinson.
+
+ No new tests. This is a low-level re-factoring and is covered by existing tests.
+
+ * Modules/webaudio/AudioBufferSourceNode.cpp:
+ (WebCore::AudioBufferSourceNode::AudioBufferSourceNode):
+ * Modules/webaudio/AudioGain.h:
+ (WebCore::AudioGain::create):
+ (WebCore::AudioGain::AudioGain):
+ * Modules/webaudio/AudioGainNode.cpp:
+ (WebCore::AudioGainNode::AudioGainNode):
+ * Modules/webaudio/AudioPannerNode.cpp:
+ (WebCore::AudioPannerNode::AudioPannerNode):
+ * Modules/webaudio/AudioParam.h:
+ (WebCore::AudioParam::create):
+ (AudioParam):
+ (WebCore::AudioParam::AudioParam):
+ * Modules/webaudio/BiquadFilterNode.cpp:
+ (WebCore::BiquadFilterNode::BiquadFilterNode):
+ * Modules/webaudio/BiquadProcessor.cpp:
+ (WebCore::BiquadProcessor::BiquadProcessor):
+ * Modules/webaudio/BiquadProcessor.h:
+ * Modules/webaudio/DelayNode.cpp:
+ (WebCore::DelayNode::DelayNode):
+ * Modules/webaudio/DelayProcessor.cpp:
+ (WebCore::DelayProcessor::DelayProcessor):
+ * Modules/webaudio/DelayProcessor.h:
+ (DelayProcessor):
+ * Modules/webaudio/DynamicsCompressorNode.cpp:
+ (WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
+ * Modules/webaudio/Oscillator.cpp:
+ (WebCore::Oscillator::Oscillator):
+
2012-05-08 Dana Jansens <danakj@chromium.org>
[chromium] Show borders for partial-draw-culled quads to visualize culling behaviour
{
setNodeType(NodeTypeAudioBufferSource);
- m_gain = AudioGain::create("gain", 1.0, 0.0, 1.0);
- m_playbackRate = AudioParam::create("playbackRate", 1.0, 0.0, MaxRate);
+ m_gain = AudioGain::create(context, "gain", 1.0, 0.0, 1.0);
+ m_playbackRate = AudioParam::create(context, "playbackRate", 1.0, 0.0, MaxRate);
- m_gain->setContext(context);
- m_playbackRate->setContext(context);
-
// Default to mono. A call to setBuffer() will set the number of output channels to that of the buffer.
addOutput(adoptPtr(new AudioNodeOutput(this, 1)));
class AudioGain : public AudioParam {
public:
- static PassRefPtr<AudioGain> create(const char* name, double defaultValue, double minValue, double maxValue)
+ static PassRefPtr<AudioGain> create(AudioContext* context, const char* name, double defaultValue, double minValue, double maxValue)
{
- return adoptRef(new AudioGain(name, defaultValue, minValue, maxValue));
+ return adoptRef(new AudioGain(context, name, defaultValue, minValue, maxValue));
}
private:
- AudioGain(const char* name, double defaultValue, double minValue, double maxValue)
- : AudioParam(name, defaultValue, minValue, maxValue)
+ AudioGain(AudioContext* context, const char* name, double defaultValue, double minValue, double maxValue)
+ : AudioParam(context, name, defaultValue, minValue, maxValue)
{
}
};
, m_lastGain(1.0)
, m_sampleAccurateGainValues(AudioNode::ProcessingSizeInFrames) // FIXME: can probably share temp buffer in context
{
- m_gain = AudioGain::create("gain", 1.0, 0.0, 1.0);
- m_gain->setContext(context);
+ m_gain = AudioGain::create(context, "gain", 1.0, 0.0, 1.0);
addInput(adoptPtr(new AudioNodeInput(this)));
addOutput(adoptPtr(new AudioNodeOutput(this, 1)));
addInput(adoptPtr(new AudioNodeInput(this)));
addOutput(adoptPtr(new AudioNodeOutput(this, 2)));
- m_distanceGain = AudioGain::create("distanceGain", 1.0, 0.0, 1.0);
- m_coneGain = AudioGain::create("coneGain", 1.0, 0.0, 1.0);
+ m_distanceGain = AudioGain::create(context, "distanceGain", 1.0, 0.0, 1.0);
+ m_coneGain = AudioGain::create(context, "coneGain", 1.0, 0.0, 1.0);
m_position = FloatPoint3D(0, 0, 0);
m_orientation = FloatPoint3D(1, 0, 0);
static const double DefaultSmoothingConstant;
static const double SnapThreshold;
- static PassRefPtr<AudioParam> create(const String& name, double defaultValue, double minValue, double maxValue, unsigned units = 0)
+ static PassRefPtr<AudioParam> create(AudioContext* context, const String& name, double defaultValue, double minValue, double maxValue, unsigned units = 0)
{
- return adoptRef(new AudioParam(name, defaultValue, minValue, maxValue, units));
+ return adoptRef(new AudioParam(context, name, defaultValue, minValue, maxValue, units));
}
- AudioParam(const String& name, double defaultValue, double minValue, double maxValue, unsigned units = 0)
- : m_name(name)
- , m_value(defaultValue)
- , m_defaultValue(defaultValue)
- , m_minValue(minValue)
- , m_maxValue(maxValue)
- , m_units(units)
- , m_smoothedValue(defaultValue)
- , m_smoothingConstant(DefaultSmoothingConstant)
- , m_audioRateSignal(0)
- {
- }
-
- void setContext(AudioContext* context) { m_context = context; }
AudioContext* context() { return m_context.get(); }
float value();
-
void setValue(float);
String name() const { return m_name; }
void connect(AudioNodeOutput*);
void disconnect(AudioNodeOutput*);
+protected:
+ AudioParam(AudioContext* context, const String& name, double defaultValue, double minValue, double maxValue, unsigned units = 0)
+ : m_context(context)
+ , m_name(name)
+ , m_value(defaultValue)
+ , m_defaultValue(defaultValue)
+ , m_minValue(minValue)
+ , m_maxValue(maxValue)
+ , m_units(units)
+ , m_smoothedValue(defaultValue)
+ , m_smoothingConstant(DefaultSmoothingConstant)
+ , m_audioRateSignal(0)
+ {
+ }
+
private:
void calculateAudioRateSignalValues(float* values, unsigned numberOfValues);
void calculateTimelineValues(float* values, unsigned numberOfValues);
: AudioBasicProcessorNode(context, sampleRate)
{
// Initially setup as lowpass filter.
- m_processor = adoptPtr(new BiquadProcessor(sampleRate, 1, false));
- biquadProcessor()->parameter1()->setContext(context);
- biquadProcessor()->parameter2()->setContext(context);
- biquadProcessor()->parameter3()->setContext(context);
+ m_processor = adoptPtr(new BiquadProcessor(context, sampleRate, 1, false));
setNodeType(NodeTypeBiquadFilter);
}
namespace WebCore {
-BiquadProcessor::BiquadProcessor(float sampleRate, size_t numberOfChannels, bool autoInitialize)
+BiquadProcessor::BiquadProcessor(AudioContext* context, float sampleRate, size_t numberOfChannels, bool autoInitialize)
: AudioDSPKernelProcessor(sampleRate, numberOfChannels)
, m_type(LowPass)
, m_parameter1(0)
double nyquist = 0.5 * this->sampleRate();
// Create parameters for BiquadFilterNode.
- m_parameter1 = AudioParam::create("frequency", 350.0, 10.0, nyquist);
- m_parameter2 = AudioParam::create("Q", 1, 0.0001, 1000.0);
- m_parameter3 = AudioParam::create("gain", 0.0, -40, 40);
+ m_parameter1 = AudioParam::create(context, "frequency", 350.0, 10.0, nyquist);
+ m_parameter2 = AudioParam::create(context, "Q", 1, 0.0001, 1000.0);
+ m_parameter3 = AudioParam::create(context, "gain", 0.0, -40, 40);
if (autoInitialize)
initialize();
Allpass = 7
};
- BiquadProcessor(float sampleRate, size_t numberOfChannels, bool autoInitialize);
+ BiquadProcessor(AudioContext*, float sampleRate, size_t numberOfChannels, bool autoInitialize);
virtual ~BiquadProcessor();
DelayNode::DelayNode(AudioContext* context, float sampleRate, double maxDelayTime)
: AudioBasicProcessorNode(context, sampleRate)
{
- m_processor = adoptPtr(new DelayProcessor(sampleRate, 1, maxDelayTime));
- delayTime()->setContext(context);
+ m_processor = adoptPtr(new DelayProcessor(context, sampleRate, 1, maxDelayTime));
setNodeType(NodeTypeDelay);
}
namespace WebCore {
-DelayProcessor::DelayProcessor(float sampleRate, unsigned numberOfChannels, double maxDelayTime)
+DelayProcessor::DelayProcessor(AudioContext* context, float sampleRate, unsigned numberOfChannels, double maxDelayTime)
: AudioDSPKernelProcessor(sampleRate, numberOfChannels)
, m_maxDelayTime(maxDelayTime)
{
- m_delayTime = AudioParam::create("delayTime", 0.0, 0.0, maxDelayTime);
+ m_delayTime = AudioParam::create(context, "delayTime", 0.0, 0.0, maxDelayTime);
}
DelayProcessor::~DelayProcessor()
class DelayProcessor : public AudioDSPKernelProcessor {
public:
- DelayProcessor(float sampleRate, unsigned numberOfChannels, double maxDelayTime);
+ DelayProcessor(AudioContext*, float sampleRate, unsigned numberOfChannels, double maxDelayTime);
virtual ~DelayProcessor();
virtual PassOwnPtr<AudioDSPKernel> createKernel();
setNodeType(NodeTypeDynamicsCompressor);
- m_threshold = AudioParam::create("threshold", -24, -100, 0);
- m_knee = AudioParam::create("knee", 30, 0, 40);
- m_ratio = AudioParam::create("ratio", 12, 1, 20);
- m_reduction = AudioParam::create("reduction", 0, -20, 0);
- m_attack = AudioParam::create("attack", 0.003, 0, 1);
- m_release = AudioParam::create("release", 0.250, 0, 1);
-
- m_threshold->setContext(context);
- m_knee->setContext(context);
- m_ratio->setContext(context);
- m_reduction->setContext(context);
- m_attack->setContext(context);
- m_release->setContext(context);
+ m_threshold = AudioParam::create(context, "threshold", -24, -100, 0);
+ m_knee = AudioParam::create(context, "knee", 30, 0, 40);
+ m_ratio = AudioParam::create(context, "ratio", 12, 1, 20);
+ m_reduction = AudioParam::create(context, "reduction", 0, -20, 0);
+ m_attack = AudioParam::create(context, "attack", 0.003, 0, 1);
+ m_release = AudioParam::create(context, "release", 0.250, 0, 1);
initialize();
}
setNodeType(NodeTypeOscillator);
// Use musical pitch standard A440 as a default.
- m_frequency = AudioParam::create("frequency", 440, 0, 100000);
+ m_frequency = AudioParam::create(context, "frequency", 440, 0, 100000);
// Default to no detuning.
- m_detune = AudioParam::create("detune", 0, -4800, 4800);
- m_frequency->setContext(context);
- m_detune->setContext(context);
+ m_detune = AudioParam::create(context, "detune", 0, -4800, 4800);
// Sets up default wavetable.
setType(m_type);