| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IIRProcessor_h | 5 #ifndef IIRProcessor_h |
| 6 #define IIRProcessor_h | 6 #define IIRProcessor_h |
| 7 | 7 |
| 8 #include "modules/webaudio/AudioNode.h" | 8 #include "modules/webaudio/AudioNode.h" |
| 9 #include "platform/audio/AudioDSPKernel.h" | 9 #include "platform/audio/AudioDSPKernel.h" |
| 10 #include "platform/audio/AudioDSPKernelProcessor.h" | 10 #include "platform/audio/AudioDSPKernelProcessor.h" |
| 11 #include "platform/audio/IIRFilter.h" | 11 #include "platform/audio/IIRFilter.h" |
| 12 #include <memory> | |
| 13 | 12 |
| 14 namespace blink { | 13 namespace blink { |
| 15 | 14 |
| 16 class IIRDSPKernel; | 15 class IIRDSPKernel; |
| 17 | 16 |
| 18 class IIRProcessor final : public AudioDSPKernelProcessor { | 17 class IIRProcessor final : public AudioDSPKernelProcessor { |
| 19 public: | 18 public: |
| 20 IIRProcessor(float sampleRate, size_t numberOfChannels, | 19 IIRProcessor(float sampleRate, size_t numberOfChannels, |
| 21 const Vector<double>& feedforwardCoef, const Vector<double>& feedbackCoe
f); | 20 const Vector<double>& feedforwardCoef, const Vector<double>& feedbackCoe
f); |
| 22 ~IIRProcessor() override; | 21 ~IIRProcessor() override; |
| 23 | 22 |
| 24 std::unique_ptr<AudioDSPKernel> createKernel() override; | 23 PassOwnPtr<AudioDSPKernel> createKernel() override; |
| 25 | 24 |
| 26 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; | 25 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; |
| 27 | 26 |
| 28 // Get the magnitude and phase response of the filter at the given | 27 // Get the magnitude and phase response of the filter at the given |
| 29 // set of frequencies (in Hz). The phase response is in radians. | 28 // set of frequencies (in Hz). The phase response is in radians. |
| 30 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); | 29 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); |
| 31 | 30 |
| 32 AudioDoubleArray* feedback() { return &m_feedback; } | 31 AudioDoubleArray* feedback() { return &m_feedback; } |
| 33 AudioDoubleArray* feedforward() { return &m_feedforward; } | 32 AudioDoubleArray* feedforward() { return &m_feedforward; } |
| 34 | 33 |
| 35 private: | 34 private: |
| 36 // The feedback and feedforward filter coefficients for the IIR filter. | 35 // The feedback and feedforward filter coefficients for the IIR filter. |
| 37 AudioDoubleArray m_feedback; | 36 AudioDoubleArray m_feedback; |
| 38 AudioDoubleArray m_feedforward; | 37 AudioDoubleArray m_feedforward; |
| 39 // This holds the IIR kernel for computing the frequency response. | 38 // This holds the IIR kernel for computing the frequency response. |
| 40 std::unique_ptr<IIRDSPKernel> m_responseKernel; | 39 OwnPtr<IIRDSPKernel> m_responseKernel; |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 } // namespace blink | 42 } // namespace blink |
| 44 | 43 |
| 45 #endif // IIRProcessor_h | 44 #endif // IIRProcessor_h |
| OLD | NEW |