Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/IIRFilterNode.cpp

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and prefix use counter names with WebAudio Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "platform/Histogram.h" 13 #include "platform/Histogram.h"
13 #include "wtf/PtrUtil.h" 14 #include "wtf/PtrUtil.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 IIRFilterNode::IIRFilterNode(BaseAudioContext& context, const Vector<double> fee dforwardCoef, const Vector<double> feedbackCoef) 18 IIRFilterNode::IIRFilterNode(BaseAudioContext& context, const Vector<double> fee dforwardCoef, const Vector<double> feedbackCoef)
18 : AudioNode(context) 19 : AudioNode(context)
19 { 20 {
20 setHandler(AudioBasicProcessorHandler::create( 21 setHandler(AudioBasicProcessorHandler::create(
21 AudioHandler::NodeTypeIIRFilter, *this, context.sampleRate(), 22 AudioHandler::NodeTypeIIRFilter, *this, context.sampleRate(),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 exceptionState.throwDOMException( 111 exceptionState.throwDOMException(
111 InvalidStateError, 112 InvalidStateError,
112 ExceptionMessages::notAFiniteNumber(c, name.ascii().data())); 113 ExceptionMessages::notAFiniteNumber(c, name.ascii().data()));
113 return nullptr; 114 return nullptr;
114 } 115 }
115 } 116 }
116 117
117 return new IIRFilterNode(context, feedforwardCoef, feedbackCoef); 118 return new IIRFilterNode(context, feedforwardCoef, feedbackCoef);
118 } 119 }
119 120
121 IIRFilterNode* IIRFilterNode::create(
122 BaseAudioContext* context,
123 const IIRFilterOptions& options,
124 ExceptionState& exceptionState)
125 {
126 if (!options.hasFeedforward()) {
127 exceptionState.throwDOMException(
128 NotFoundError,
129 "IIRFilterOptions: feedforward is required.");
130 return nullptr;
131 }
132
133 if (!options.hasFeedback()) {
134 exceptionState.throwDOMException(
135 NotFoundError,
136 "IIRFilterOptions: feedback is required.");
137 return nullptr;
138 }
139
140 IIRFilterNode* node = create(*context, options.feedforward(), options.feedba ck(), exceptionState);
141
142 if (!node)
143 return nullptr;
144
145 node->handleChannelOptions(options, exceptionState);
146
147 return node;
148 }
149
120 DEFINE_TRACE(IIRFilterNode) 150 DEFINE_TRACE(IIRFilterNode)
121 { 151 {
122 AudioNode::trace(visitor); 152 AudioNode::trace(visitor);
123 } 153 }
124 154
125 IIRProcessor* IIRFilterNode::iirProcessor() const 155 IIRProcessor* IIRFilterNode::iirProcessor() const
126 { 156 {
127 return static_cast<IIRProcessor*>(static_cast<AudioBasicProcessorHandler&>(h andler()).processor()); 157 return static_cast<IIRProcessor*>(static_cast<AudioBasicProcessorHandler&>(h andler()).processor());
128 } 158 }
129 159
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 "phaseResponse length", 199 "phaseResponse length",
170 phaseResponse->length(), 200 phaseResponse->length(),
171 frequencyHzLength)); 201 frequencyHzLength));
172 return; 202 return;
173 } 203 }
174 204
175 iirProcessor()->getFrequencyResponse(frequencyHzLength, frequencyHz->data(), magResponse->data(), phaseResponse->data()); 205 iirProcessor()->getFrequencyResponse(frequencyHzLength, frequencyHz->data(), magResponse->data(), phaseResponse->data());
176 } 206 }
177 207
178 } // namespace blink 208 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698