Ignore:
Timestamp:
04/10/12 14:28:57 (2 years ago)
Author:
crogers@google.com
Message:

AudioParam must support connections from audio-rate signals
https://bugs.webkit.org/show_bug.cgi?id=83524

Source/WebCore:

Reviewed by Eric Carlson.

In the Web Audio API, it's possible to connect one AudioNode to another AudioNode.
Similary we should allow an AudioNode to connect to an AudioParam, thus controlling
a parameter with an audio-rate signal. This is important in many audio processing
applications.

Test: webaudio/audioparam-connect-audioratesignal.html

Simple method name change of AudioParam::hasTimelineValues() to AudioParam::hasSampleAccurateValues().

  • Modules/webaudio/AudioGainNode.cpp:

(WebCore::AudioGainNode::process):

  • Modules/webaudio/AudioNode.cpp:

(WebCore::AudioNode::connect): Add connect() method from AudioNode -> AudioParam.
(WebCore):
(WebCore::AudioNode::disconnect):
(WebCore::AudioNode::finishDeref):
Use AudioNodeOutput::disconnectAll() instead of AudioNodeOutput::disconnectAllInputs().

  • Modules/webaudio/AudioNode.h: Add connect() method from AudioNode -> AudioParam.

(WebCore):
(AudioNode):

  • Modules/webaudio/AudioNode.idl: Add connect() method from AudioNode -> AudioParam.

Implement support for an AudioNodeOutput to fanout to multiple AudioParams.

  • Modules/webaudio/AudioNodeOutput.cpp:

(WebCore::AudioNodeOutput::AudioNodeOutput):
(WebCore::AudioNodeOutput::updateRenderingState): Update rendering state related to AudioParams.
(WebCore::AudioNodeOutput::pull): pull() must now take into account fanout to AudioParams for in-place processing.
(WebCore::AudioNodeOutput::fanOutCount):
(WebCore):
(WebCore::AudioNodeOutput::paramFanOutCount): New method keeping track of number of connections to AudioParams.
(WebCore::AudioNodeOutput::renderingParamFanOutCount): New method keeping track of number of connections to AudioParams for rendering.
(WebCore::AudioNodeOutput::addParam): Add a connection to an AudioParam.
(WebCore::AudioNodeOutput::removeParam): Remove a connection to an AudioParam.
(WebCore::AudioNodeOutput::disconnectAllParams): Remove all connections to AudioParams.
(WebCore::AudioNodeOutput::disconnectAll): New method to disconnect all AudioNodeInputs and AudioParams.

  • Modules/webaudio/AudioNodeOutput.h:

(AudioNodeOutput):

Allow an AudioParam to accept a connection from an AudioNodeOutput, thus being controlled
by an audio-rate signal.

  • Modules/webaudio/AudioParam.cpp:

(WebCore::AudioParam::calculateSampleAccurateValues): Calculates sample-accurate values from timeline or an AudioNode.
(WebCore):
(WebCore::AudioParam::calculateAudioRateSignalValues): Calculates sample-accurate values from an AudioNode.
(WebCore::AudioParam::calculateTimelineValues): Calculates sample-accurate values scheduled on the timeline.
(WebCore::AudioParam::connect): Connect from an AudioNodeOutput for control from an audio-rate signal.
(WebCore::AudioParam::disconnect): Disconnect from an AudioNodeOutput.

  • Modules/webaudio/AudioParam.h:

(WebCore):
(WebCore::AudioParam::AudioParam):
(WebCore::AudioParam::hasSampleAccurateValues): Change name from hasTimelineValues() and return true
either if we have timeline values or if we've been connected from an AudioNode.
(AudioParam):

Simple method name change of AudioParam::hasTimelineValues() to AudioParam::hasSampleAccurateValues().

  • Modules/webaudio/Oscillator.cpp:

(WebCore::Oscillator::calculateSampleAccuratePhaseIncrements):
(WebCore::Oscillator::process):

LayoutTests:

Reviewed by Eric Carlson.

  • webaudio/audioparam-connect-audioratesignal-expected.txt: Added.
  • webaudio/audioparam-connect-audioratesignal.html: Added.
  • webaudio/resources/audio-testing.js:

(createLinearRampBuffer):
(createConstantBuffer):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp

    r113728 r113769  
    3232#include "AudioNodeInput.h" 
    3333#include "AudioNodeOutput.h" 
     34#include "AudioParam.h" 
    3435#include "ExceptionCode.h" 
    3536#include <wtf/Atomics.h> 
     
    150151} 
    151152 
     153void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionCode& ec) 
     154{ 
     155    ASSERT(isMainThread()); 
     156    AudioContext::AutoLocker locker(context()); 
     157 
     158    if (!param) { 
     159        ec = SYNTAX_ERR; 
     160        return; 
     161    } 
     162 
     163    if (outputIndex >= numberOfOutputs()) { 
     164        ec = INDEX_SIZE_ERR; 
     165        return; 
     166    } 
     167 
     168    if (context() != param->context()) { 
     169        ec = SYNTAX_ERR; 
     170        return; 
     171    } 
     172 
     173    AudioNodeOutput* output = this->output(outputIndex); 
     174    param->connect(output); 
     175} 
     176 
    152177void AudioNode::disconnect(unsigned outputIndex, ExceptionCode& ec) 
    153178{ 
     
    162187 
    163188    AudioNodeOutput* output = this->output(outputIndex); 
    164     output->disconnectAllInputs(); 
     189    output->disconnectAll(); 
    165190} 
    166191 
     
    338363                // All references are gone - we need to go away. 
    339364                for (unsigned i = 0; i < m_outputs.size(); ++i) 
    340                     output(i)->disconnectAllInputs(); // this will deref() nodes we're connected to... 
     365                    output(i)->disconnectAll(); // This will deref() nodes we're connected to. 
    341366 
    342367                // Mark for deletion at end of each render quantum or when context shuts down. 
Note: See TracChangeset for help on using the changeset viewer.