Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "bindings/core/v8/ExceptionState.h" | 25 #include "bindings/core/v8/ExceptionState.h" |
| 26 #include "core/dom/ExceptionCode.h" | 26 #include "core/dom/ExceptionCode.h" |
| 27 #include "modules/webaudio/AudioBuffer.h" | 27 #include "modules/webaudio/AudioBuffer.h" |
| 28 #include "modules/webaudio/AudioNodeInput.h" | 28 #include "modules/webaudio/AudioNodeInput.h" |
| 29 #include "modules/webaudio/AudioNodeOutput.h" | 29 #include "modules/webaudio/AudioNodeOutput.h" |
| 30 #include "modules/webaudio/ConvolverNode.h" | 30 #include "modules/webaudio/ConvolverNode.h" |
| 31 #include "modules/webaudio/ConvolverOptions.h" | |
| 31 #include "platform/audio/Reverb.h" | 32 #include "platform/audio/Reverb.h" |
| 32 #include "wtf/PtrUtil.h" | 33 #include "wtf/PtrUtil.h" |
| 33 #include <memory> | 34 #include <memory> |
| 34 | 35 |
| 35 // Note about empirical tuning: | 36 // Note about empirical tuning: |
| 36 // The maximum FFT size affects reverb performance and accuracy. | 37 // The maximum FFT size affects reverb performance and accuracy. |
| 37 // If the reverb is single-threaded and processes entirely in the real-time audi o thread, | 38 // If the reverb is single-threaded and processes entirely in the real-time audi o thread, |
| 38 // it's important not to make this too high. In this case 8192 is a good value. | 39 // it's important not to make this too high. In this case 8192 is a good value. |
| 39 // But, the Reverb object is multi-threaded, so we want this as high as possible without losing too much accuracy. | 40 // But, the Reverb object is multi-threaded, so we want this as high as possible without losing too much accuracy. |
| 40 // Very large FFTs will have worse phase errors. Given these constraints 32768 i s a good compromise. | 41 // Very large FFTs will have worse phase errors. Given these constraints 32768 i s a good compromise. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 DCHECK(isMainThread()); | 179 DCHECK(isMainThread()); |
| 179 | 180 |
| 180 if (context.isContextClosed()) { | 181 if (context.isContextClosed()) { |
| 181 context.throwExceptionForClosedState(exceptionState); | 182 context.throwExceptionForClosedState(exceptionState); |
| 182 return nullptr; | 183 return nullptr; |
| 183 } | 184 } |
| 184 | 185 |
| 185 return new ConvolverNode(context); | 186 return new ConvolverNode(context); |
| 186 } | 187 } |
| 187 | 188 |
| 189 ConvolverNode* ConvolverNode::create(BaseAudioContext* context, const ConvolverO ptions& options, ExceptionState& exceptionState) | |
| 190 { | |
| 191 ConvolverNode* node = create(*context, exceptionState); | |
| 192 | |
| 193 if (!node) | |
| 194 return node; | |
|
hongchan
2016/09/12 18:56:32
return nullptr;
| |
| 195 | |
| 196 node->handleChannelOptions(options, exceptionState); | |
| 197 | |
| 198 // It is important to set normalize first because setting the buffer will | |
| 199 // examing the normalize attribute to see if normalization needs to be done. | |
| 200 node->setNormalize(!options.disableNormalization()); | |
| 201 if (options.hasBuffer()) | |
| 202 node->setBuffer(options.buffer(), exceptionState); | |
| 203 return node; | |
| 204 } | |
| 205 | |
| 188 ConvolverHandler& ConvolverNode::convolverHandler() const | 206 ConvolverHandler& ConvolverNode::convolverHandler() const |
| 189 { | 207 { |
| 190 return static_cast<ConvolverHandler&>(handler()); | 208 return static_cast<ConvolverHandler&>(handler()); |
| 191 } | 209 } |
| 192 | 210 |
| 193 AudioBuffer* ConvolverNode::buffer() const | 211 AudioBuffer* ConvolverNode::buffer() const |
| 194 { | 212 { |
| 195 return convolverHandler().buffer(); | 213 return convolverHandler().buffer(); |
| 196 } | 214 } |
| 197 | 215 |
| 198 void ConvolverNode::setBuffer(AudioBuffer* newBuffer, ExceptionState& exceptionS tate) | 216 void ConvolverNode::setBuffer(AudioBuffer* newBuffer, ExceptionState& exceptionS tate) |
| 199 { | 217 { |
| 200 convolverHandler().setBuffer(newBuffer, exceptionState); | 218 convolverHandler().setBuffer(newBuffer, exceptionState); |
| 201 } | 219 } |
| 202 | 220 |
| 203 bool ConvolverNode::normalize() const | 221 bool ConvolverNode::normalize() const |
| 204 { | 222 { |
| 205 return convolverHandler().normalize(); | 223 return convolverHandler().normalize(); |
| 206 } | 224 } |
| 207 | 225 |
| 208 void ConvolverNode::setNormalize(bool normalize) | 226 void ConvolverNode::setNormalize(bool normalize) |
| 209 { | 227 { |
| 210 convolverHandler().setNormalize(normalize); | 228 convolverHandler().setNormalize(normalize); |
| 211 } | 229 } |
| 212 | 230 |
| 213 } // namespace blink | 231 } // namespace blink |
| 214 | 232 |
| OLD | NEW |