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 #include "modules/webaudio/IIRFilterNode.h" | 5 #include "modules/webaudio/IIRFilterNode.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
10 #include "modules/webaudio/AudioBasicProcessorHandler.h" | 10 #include "modules/webaudio/AudioBasicProcessorHandler.h" |
11 #include "modules/webaudio/BaseAudioContext.h" | 11 #include "modules/webaudio/BaseAudioContext.h" |
12 #include "modules/webaudio/IIRFilterOptions.h" | 12 #include "modules/webaudio/IIRFilterOptions.h" |
13 #include "platform/Histogram.h" | 13 #include "platform/Histogram.h" |
14 #include "wtf/PtrUtil.h" | 14 #include "wtf/PtrUtil.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 IIRFilterNode::IIRFilterNode(BaseAudioContext& context, | 18 IIRFilterNode::IIRFilterNode(BaseAudioContext& context, |
19 const Vector<double> feedforwardCoef, | 19 const Vector<double> feedforwardCoef, |
20 const Vector<double> feedbackCoef) | 20 const Vector<double> feedbackCoef) |
21 : AudioNode(context) { | 21 : AudioNode(context) { |
22 setHandler(AudioBasicProcessorHandler::create( | 22 setHandler(AudioBasicProcessorHandler::create( |
23 AudioHandler::NodeTypeIIRFilter, *this, context.sampleRate(), | 23 AudioHandler::NodeTypeIIRFilter, *this, context.sampleRate(), |
24 wrapUnique(new IIRProcessor(context.sampleRate(), 1, feedforwardCoef, | 24 wrapUnique(new IIRProcessor(context.sampleRate(), 1, feedforwardCoef, |
25 feedbackCoef)))); | 25 feedbackCoef)))); |
26 | 26 |
27 // Histogram of the IIRFilter order. createIIRFilter ensures that the length
of |feedbackCoef| | 27 // Histogram of the IIRFilter order. createIIRFilter ensures that the length |
28 // is in the range [1, IIRFilter::kMaxOrder + 1]. The order is one less than
the length of this | 28 // of |feedbackCoef| is in the range [1, IIRFilter::kMaxOrder + 1]. The order |
29 // vector. | 29 // is one less than the length of this vector. |
30 DEFINE_STATIC_LOCAL(SparseHistogram, filterOrderHistogram, | 30 DEFINE_STATIC_LOCAL(SparseHistogram, filterOrderHistogram, |
31 ("WebAudio.IIRFilterNode.Order")); | 31 ("WebAudio.IIRFilterNode.Order")); |
32 | 32 |
33 filterOrderHistogram.sample(feedbackCoef.size() - 1); | 33 filterOrderHistogram.sample(feedbackCoef.size() - 1); |
34 } | 34 } |
35 | 35 |
36 IIRFilterNode* IIRFilterNode::create(BaseAudioContext& context, | 36 IIRFilterNode* IIRFilterNode::create(BaseAudioContext& context, |
37 const Vector<double> feedforwardCoef, | 37 const Vector<double> feedforwardCoef, |
38 const Vector<double> feedbackCoef, | 38 const Vector<double> feedbackCoef, |
39 ExceptionState& exceptionState) { | 39 ExceptionState& exceptionState) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 frequencyHzLength)); | 188 frequencyHzLength)); |
189 return; | 189 return; |
190 } | 190 } |
191 | 191 |
192 iirProcessor()->getFrequencyResponse(frequencyHzLength, frequencyHz->data(), | 192 iirProcessor()->getFrequencyResponse(frequencyHzLength, frequencyHz->data(), |
193 magResponse->data(), | 193 magResponse->data(), |
194 phaseResponse->data()); | 194 phaseResponse->data()); |
195 } | 195 } |
196 | 196 |
197 } // namespace blink | 197 } // namespace blink |
OLD | NEW |