X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=blobdiff_plain;f=Source%2FWebCore%2Fwebaudio%2FBiquadProcessor.cpp;h=12243c0c99be1cc7753ec2a9f7952839f8699625;hp=192755a5b8ef9935fabc64290e7641d6e2588978;hb=3b4548f1fbceaa085733b83a25384d7dc8156a71;hpb=0d29b3ffdc13e2c1373f89db7ac99732b2bf5037;ds=sidebyside diff --git a/Source/WebCore/webaudio/BiquadProcessor.cpp b/Source/WebCore/webaudio/BiquadProcessor.cpp index 192755a5b8ef..12243c0c99be 100644 --- a/Source/WebCore/webaudio/BiquadProcessor.cpp +++ b/Source/WebCore/webaudio/BiquadProcessor.cpp @@ -90,14 +90,10 @@ PassOwnPtr BiquadProcessor::createKernel() return adoptPtr(new BiquadDSPKernel(this)); } -void BiquadProcessor::process(AudioBus* source, AudioBus* destination, size_t framesToProcess) +void BiquadProcessor::checkForDirtyCoefficients() { - if (!isInitialized()) { - destination->zero(); - return; - } - - // Deal with smoothing / de-zippering. Start out assuming filter parameters are not changing. + // Deal with smoothing / de-zippering. Start out assuming filter parameters are not changing. + // The BiquadDSPKernel objects rely on this value to see if they need to re-compute their internal filter coefficients. m_filterCoefficientsDirty = false; @@ -109,14 +105,24 @@ void BiquadProcessor::process(AudioBus* source, AudioBus* destination, size_t fr m_filterCoefficientsDirty = true; m_hasJustReset = false; } else { - // Smooth all of the filter parameters. If they haven't yet converged to their target value then mark coefficients as dirty. + // Smooth all of the filter parameters. If they haven't yet converged to their target value then mark coefficients as dirty. bool isStable1 = m_parameter1->smooth(); bool isStable2 = m_parameter2->smooth(); bool isStable3 = m_parameter3->smooth(); if (!(isStable1 && isStable2 && isStable3)) m_filterCoefficientsDirty = true; } +} + +void BiquadProcessor::process(AudioBus* source, AudioBus* destination, size_t framesToProcess) +{ + if (!isInitialized()) { + destination->zero(); + return; + } + checkForDirtyCoefficients(); + // For each channel of our input, process using the corresponding BiquadDSPKernel into the output channel. for (unsigned i = 0; i < m_kernels.size(); ++i) m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->data(), framesToProcess); @@ -130,6 +136,20 @@ void BiquadProcessor::setType(FilterType type) } } +void BiquadProcessor::getFrequencyResponse(int nFrequencies, + const float* frequencyHz, + float* magResponse, + float* phaseResponse) +{ + // Compute the frequency response on a separate temporary kernel + // to avoid interfering with the processing running in the audio + // thread on the main kernels. + + OwnPtr responseKernel = adoptPtr(new BiquadDSPKernel(this)); + + responseKernel->getFrequencyResponse(nFrequencies, frequencyHz, magResponse, phaseResponse); +} + } // namespace WebCore #endif // ENABLE(WEB_AUDIO)