OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #ifndef BiquadProcessor_h | 25 #ifndef BiquadProcessor_h |
26 #define BiquadProcessor_h | 26 #define BiquadProcessor_h |
27 | 27 |
28 #include "modules/webaudio/AudioNode.h" | 28 #include "modules/webaudio/AudioNode.h" |
29 #include "modules/webaudio/AudioParam.h" | 29 #include "modules/webaudio/AudioParam.h" |
30 #include "platform/audio/AudioDSPKernel.h" | 30 #include "platform/audio/AudioDSPKernel.h" |
31 #include "platform/audio/AudioDSPKernelProcessor.h" | 31 #include "platform/audio/AudioDSPKernelProcessor.h" |
32 #include "platform/audio/Biquad.h" | 32 #include "platform/audio/Biquad.h" |
33 #include "wtf/RefPtr.h" | 33 #include "wtf/RefPtr.h" |
| 34 #include <memory> |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 // BiquadProcessor is an AudioDSPKernelProcessor which uses Biquad objects to im
plement several common filters. | 38 // BiquadProcessor is an AudioDSPKernelProcessor which uses Biquad objects to im
plement several common filters. |
38 | 39 |
39 class BiquadProcessor final : public AudioDSPKernelProcessor { | 40 class BiquadProcessor final : public AudioDSPKernelProcessor { |
40 public: | 41 public: |
41 // This values are used in histograms and should not be renumbered or delete
d. | 42 // This values are used in histograms and should not be renumbered or delete
d. |
42 enum FilterType { | 43 enum FilterType { |
43 LowPass = 0, | 44 LowPass = 0, |
44 HighPass = 1, | 45 HighPass = 1, |
45 BandPass = 2, | 46 BandPass = 2, |
46 LowShelf = 3, | 47 LowShelf = 3, |
47 HighShelf = 4, | 48 HighShelf = 4, |
48 Peaking = 5, | 49 Peaking = 5, |
49 Notch = 6, | 50 Notch = 6, |
50 Allpass = 7 | 51 Allpass = 7 |
51 }; | 52 }; |
52 | 53 |
53 BiquadProcessor(float sampleRate, size_t numberOfChannels, AudioParamHandler
& frequency, AudioParamHandler& q, AudioParamHandler& gain, AudioParamHandler& d
etune); | 54 BiquadProcessor(float sampleRate, size_t numberOfChannels, AudioParamHandler
& frequency, AudioParamHandler& q, AudioParamHandler& gain, AudioParamHandler& d
etune); |
54 ~BiquadProcessor() override; | 55 ~BiquadProcessor() override; |
55 | 56 |
56 PassOwnPtr<AudioDSPKernel> createKernel() override; | 57 std::unique_ptr<AudioDSPKernel> createKernel() override; |
57 | 58 |
58 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; | 59 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; |
59 | 60 |
60 // Get the magnitude and phase response of the filter at the given | 61 // Get the magnitude and phase response of the filter at the given |
61 // set of frequencies (in Hz). The phase response is in radians. | 62 // set of frequencies (in Hz). The phase response is in radians. |
62 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); | 63 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); |
63 | 64 |
64 void checkForDirtyCoefficients(); | 65 void checkForDirtyCoefficients(); |
65 | 66 |
66 bool filterCoefficientsDirty() const { return m_filterCoefficientsDirty; } | 67 bool filterCoefficientsDirty() const { return m_filterCoefficientsDirty; } |
(...skipping 18 matching lines...) Expand all Loading... |
85 // so DSP kernels know when to re-compute coefficients | 86 // so DSP kernels know when to re-compute coefficients |
86 bool m_filterCoefficientsDirty; | 87 bool m_filterCoefficientsDirty; |
87 | 88 |
88 // Set to true if any of the filter parameters are sample-accurate. | 89 // Set to true if any of the filter parameters are sample-accurate. |
89 bool m_hasSampleAccurateValues; | 90 bool m_hasSampleAccurateValues; |
90 }; | 91 }; |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
93 | 94 |
94 #endif // BiquadProcessor_h | 95 #endif // BiquadProcessor_h |
OLD | NEW |