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> |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class IIRDSPKernel; | 16 class IIRDSPKernel; |
16 | 17 |
17 class IIRProcessor final : public AudioDSPKernelProcessor { | 18 class IIRProcessor final : public AudioDSPKernelProcessor { |
18 public: | 19 public: |
19 IIRProcessor(float sampleRate, size_t numberOfChannels, | 20 IIRProcessor(float sampleRate, size_t numberOfChannels, |
20 const Vector<double>& feedforwardCoef, const Vector<double>& feedbackCoe
f); | 21 const Vector<double>& feedforwardCoef, const Vector<double>& feedbackCoe
f); |
21 ~IIRProcessor() override; | 22 ~IIRProcessor() override; |
22 | 23 |
23 PassOwnPtr<AudioDSPKernel> createKernel() override; | 24 std::unique_ptr<AudioDSPKernel> createKernel() override; |
24 | 25 |
25 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; | 26 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; |
26 | 27 |
27 // Get the magnitude and phase response of the filter at the given | 28 // Get the magnitude and phase response of the filter at the given |
28 // set of frequencies (in Hz). The phase response is in radians. | 29 // set of frequencies (in Hz). The phase response is in radians. |
29 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); | 30 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); |
30 | 31 |
31 AudioDoubleArray* feedback() { return &m_feedback; } | 32 AudioDoubleArray* feedback() { return &m_feedback; } |
32 AudioDoubleArray* feedforward() { return &m_feedforward; } | 33 AudioDoubleArray* feedforward() { return &m_feedforward; } |
33 | 34 |
34 private: | 35 private: |
35 // The feedback and feedforward filter coefficients for the IIR filter. | 36 // The feedback and feedforward filter coefficients for the IIR filter. |
36 AudioDoubleArray m_feedback; | 37 AudioDoubleArray m_feedback; |
37 AudioDoubleArray m_feedforward; | 38 AudioDoubleArray m_feedforward; |
38 // This holds the IIR kernel for computing the frequency response. | 39 // This holds the IIR kernel for computing the frequency response. |
39 OwnPtr<IIRDSPKernel> m_responseKernel; | 40 std::unique_ptr<IIRDSPKernel> m_responseKernel; |
40 }; | 41 }; |
41 | 42 |
42 } // namespace blink | 43 } // namespace blink |
43 | 44 |
44 #endif // IIRProcessor_h | 45 #endif // IIRProcessor_h |
OLD | NEW |