Title: [125957] trunk/Source/WebCore
- Revision
- 125957
- Author
- [email protected]
- Date
- 2012-08-17 17:42:26 -0700 (Fri, 17 Aug 2012)
Log Message
AudioParam must support k-rate processing with audio-rate connections
https://bugs.webkit.org/show_bug.cgi?id=94385
Reviewed by Kenneth Russell.
Fully implement AudioParam *final* value calculation according to spec:
https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioParam
In particular, this covers the case where the parameter is k-rate, and we also
have audio-rate connections to the AudioParam.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::finalValue):
(WebCore):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
* Modules/webaudio/AudioParam.h:
(AudioParam):
* Modules/webaudio/DelayDSPKernel.cpp:
(WebCore::DelayDSPKernel::process):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (125956 => 125957)
--- trunk/Source/WebCore/ChangeLog 2012-08-18 00:36:06 UTC (rev 125956)
+++ trunk/Source/WebCore/ChangeLog 2012-08-18 00:42:26 UTC (rev 125957)
@@ -1,3 +1,26 @@
+2012-08-17 Chris Rogers <[email protected]>
+
+ AudioParam must support k-rate processing with audio-rate connections
+ https://bugs.webkit.org/show_bug.cgi?id=94385
+
+ Reviewed by Kenneth Russell.
+
+ Fully implement AudioParam *final* value calculation according to spec:
+ https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioParam
+
+ In particular, this covers the case where the parameter is k-rate, and we also
+ have audio-rate connections to the AudioParam.
+
+ * Modules/webaudio/AudioParam.cpp:
+ (WebCore::AudioParam::finalValue):
+ (WebCore):
+ (WebCore::AudioParam::calculateSampleAccurateValues):
+ (WebCore::AudioParam::calculateFinalValues):
+ * Modules/webaudio/AudioParam.h:
+ (AudioParam):
+ * Modules/webaudio/DelayDSPKernel.cpp:
+ (WebCore::DelayDSPKernel::process):
+
2012-08-17 Alice Cheng <[email protected]>
Preserve styling elements in DeleteSelectionCommand
Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp (125956 => 125957)
--- trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp 2012-08-18 00:36:06 UTC (rev 125956)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp 2012-08-18 00:42:26 UTC (rev 125957)
@@ -94,6 +94,13 @@
return false;
}
+float AudioParam::finalValue()
+{
+ float value;
+ calculateFinalValues(&value, 1, false);
+ return value;
+}
+
void AudioParam::calculateSampleAccurateValues(float* values, unsigned numberOfValues)
{
bool isSafe = context() && context()->isAudioThread() && values && numberOfValues;
@@ -101,31 +108,30 @@
if (!isSafe)
return;
- if (numberOfRenderingConnections())
- calculateAudioRateSignalValues(values, numberOfValues);
- else
- calculateTimelineValues(values, numberOfValues);
+ calculateFinalValues(values, numberOfValues, true);
}
-void AudioParam::calculateAudioRateSignalValues(float* values, unsigned numberOfValues)
+void AudioParam::calculateFinalValues(float* values, unsigned numberOfValues, bool sampleAccurate)
{
- bool isGood = numberOfRenderingConnections() && numberOfValues;
+ bool isGood = context() && context()->isAudioThread() && values && numberOfValues;
ASSERT(isGood);
if (!isGood)
return;
// The calculated result will be the "intrinsic" value summed with all audio-rate connections.
- if (m_timeline.hasValues()) {
- // Calculate regular timeline values, if we have any.
+ if (sampleAccurate) {
+ // Calculate sample-accurate (a-rate) intrinsic values.
calculateTimelineValues(values, numberOfValues);
} else {
- // Otherwise set values array to our constant value.
- float value = m_value; // Cache in local.
+ // Calculate control-rate (k-rate) intrinsic value.
+ bool hasValue;
+ float timelineValue = m_timeline.valueForContextTime(context(), narrowPrecisionToFloat(m_value), hasValue);
- // FIXME: can be optimized if we create a new VectorMath function.
- for (unsigned i = 0; i < numberOfValues; ++i)
- values[i] = value;
+ if (hasValue)
+ m_value = timelineValue;
+
+ values[0] = narrowPrecisionToFloat(m_value);
}
// Now sum all of the audio-rate connections together (unity-gain summing junction).
@@ -138,7 +144,7 @@
ASSERT(output);
// Render audio from this output.
- AudioBus* connectionBus = output->pull(0, numberOfValues);
+ AudioBus* connectionBus = output->pull(0, AudioNode::ProcessingSizeInFrames);
// Sum, with unity-gain.
summingBus.sumFrom(*connectionBus);
Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.h (125956 => 125957)
--- trunk/Source/WebCore/Modules/webaudio/AudioParam.h 2012-08-18 00:36:06 UTC (rev 125956)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.h 2012-08-18 00:42:26 UTC (rev 125957)
@@ -56,9 +56,14 @@
virtual bool canUpdateState() OVERRIDE { return true; }
virtual void didUpdate() OVERRIDE { }
+ // Intrinsic value.
float value();
void setValue(float);
+ // Final value for k-rate parameters, otherwise use calculateSampleAccurateValues() for a-rate.
+ // Must be called in the audio thread.
+ float finalValue();
+
String name() const { return m_name; }
float minValue() const { return static_cast<float>(m_minValue); }
@@ -112,7 +117,8 @@
}
private:
- void calculateAudioRateSignalValues(float* values, unsigned numberOfValues);
+ // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web Audio specification.
+ void calculateFinalValues(float* values, unsigned numberOfValues, bool sampleAccurate);
void calculateTimelineValues(float* values, unsigned numberOfValues);
String m_name;
Modified: trunk/Source/WebCore/Modules/webaudio/DelayDSPKernel.cpp (125956 => 125957)
--- trunk/Source/WebCore/Modules/webaudio/DelayDSPKernel.cpp 2012-08-18 00:36:06 UTC (rev 125956)
+++ trunk/Source/WebCore/Modules/webaudio/DelayDSPKernel.cpp 2012-08-18 00:42:26 UTC (rev 125957)
@@ -99,7 +99,7 @@
return;
float sampleRate = this->sampleRate();
- double delayTime = delayProcessor() ? delayProcessor()->delayTime()->value() : m_desiredDelayFrames / sampleRate;
+ double delayTime = delayProcessor() ? delayProcessor()->delayTime()->finalValue() : m_desiredDelayFrames / sampleRate;
// Make sure the delay time is in a valid range.
delayTime = min(maxDelayTime(), delayTime);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes