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> | |
35 | 34 |
36 namespace blink { | 35 namespace blink { |
37 | 36 |
38 // BiquadProcessor is an AudioDSPKernelProcessor which uses Biquad objects to im
plement several common filters. | 37 // BiquadProcessor is an AudioDSPKernelProcessor which uses Biquad objects to im
plement several common filters. |
39 | 38 |
40 class BiquadProcessor final : public AudioDSPKernelProcessor { | 39 class BiquadProcessor final : public AudioDSPKernelProcessor { |
41 public: | 40 public: |
42 // This values are used in histograms and should not be renumbered or delete
d. | 41 // This values are used in histograms and should not be renumbered or delete
d. |
43 enum FilterType { | 42 enum FilterType { |
44 LowPass = 0, | 43 LowPass = 0, |
45 HighPass = 1, | 44 HighPass = 1, |
46 BandPass = 2, | 45 BandPass = 2, |
47 LowShelf = 3, | 46 LowShelf = 3, |
48 HighShelf = 4, | 47 HighShelf = 4, |
49 Peaking = 5, | 48 Peaking = 5, |
50 Notch = 6, | 49 Notch = 6, |
51 Allpass = 7 | 50 Allpass = 7 |
52 }; | 51 }; |
53 | 52 |
54 BiquadProcessor(float sampleRate, size_t numberOfChannels, AudioParamHandler
& frequency, AudioParamHandler& q, AudioParamHandler& gain, AudioParamHandler& d
etune); | 53 BiquadProcessor(float sampleRate, size_t numberOfChannels, AudioParamHandler
& frequency, AudioParamHandler& q, AudioParamHandler& gain, AudioParamHandler& d
etune); |
55 ~BiquadProcessor() override; | 54 ~BiquadProcessor() override; |
56 | 55 |
57 std::unique_ptr<AudioDSPKernel> createKernel() override; | 56 PassOwnPtr<AudioDSPKernel> createKernel() override; |
58 | 57 |
59 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; | 58 void process(const AudioBus* source, AudioBus* destination, size_t framesToP
rocess) override; |
60 | 59 |
61 // Get the magnitude and phase response of the filter at the given | 60 // Get the magnitude and phase response of the filter at the given |
62 // set of frequencies (in Hz). The phase response is in radians. | 61 // set of frequencies (in Hz). The phase response is in radians. |
63 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); | 62 void getFrequencyResponse(int nFrequencies, const float* frequencyHz, float*
magResponse, float* phaseResponse); |
64 | 63 |
65 void checkForDirtyCoefficients(); | 64 void checkForDirtyCoefficients(); |
66 | 65 |
67 bool filterCoefficientsDirty() const { return m_filterCoefficientsDirty; } | 66 bool filterCoefficientsDirty() const { return m_filterCoefficientsDirty; } |
(...skipping 18 matching lines...) Expand all Loading... |
86 // so DSP kernels know when to re-compute coefficients | 85 // so DSP kernels know when to re-compute coefficients |
87 bool m_filterCoefficientsDirty; | 86 bool m_filterCoefficientsDirty; |
88 | 87 |
89 // Set to true if any of the filter parameters are sample-accurate. | 88 // Set to true if any of the filter parameters are sample-accurate. |
90 bool m_hasSampleAccurateValues; | 89 bool m_hasSampleAccurateValues; |
91 }; | 90 }; |
92 | 91 |
93 } // namespace blink | 92 } // namespace blink |
94 | 93 |
95 #endif // BiquadProcessor_h | 94 #endif // BiquadProcessor_h |
OLD | NEW |