| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 22 matching lines...) Expand all Loading... |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 WaveShaperNode::WaveShaperNode(AbstractAudioContext& context) | 35 WaveShaperNode::WaveShaperNode(AbstractAudioContext& context) |
| 36 : AudioNode(context) | 36 : AudioNode(context) |
| 37 { | 37 { |
| 38 setHandler(AudioBasicProcessorHandler::create(AudioHandler::NodeTypeWaveShap
er, *this, context.sampleRate(), adoptPtr(new WaveShaperProcessor(context.sample
Rate(), 1)))); | 38 setHandler(AudioBasicProcessorHandler::create(AudioHandler::NodeTypeWaveShap
er, *this, context.sampleRate(), adoptPtr(new WaveShaperProcessor(context.sample
Rate(), 1)))); |
| 39 | 39 |
| 40 handler().initialize(); | 40 handler().initialize(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 WaveShaperProcessor* WaveShaperNode::waveShaperProcessor() const | 43 WaveShaperProcessor* WaveShaperNode::getWaveShaperProcessor() const |
| 44 { | 44 { |
| 45 return static_cast<WaveShaperProcessor*>(static_cast<AudioBasicProcessorHand
ler&>(handler()).processor()); | 45 return static_cast<WaveShaperProcessor*>(static_cast<AudioBasicProcessorHand
ler&>(handler()).processor()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void WaveShaperNode::setCurve(DOMFloat32Array* curve, ExceptionState& exceptionS
tate) | 48 void WaveShaperNode::setCurve(DOMFloat32Array* curve, ExceptionState& exceptionS
tate) |
| 49 { | 49 { |
| 50 ASSERT(isMainThread()); | 50 ASSERT(isMainThread()); |
| 51 | 51 |
| 52 if (curve && curve->length() < 2) { | 52 if (curve && curve->length() < 2) { |
| 53 exceptionState.throwDOMException( | 53 exceptionState.throwDOMException( |
| 54 InvalidAccessError, | 54 InvalidAccessError, |
| 55 ExceptionMessages::indexExceedsMinimumBound<unsigned>( | 55 ExceptionMessages::indexExceedsMinimumBound<unsigned>( |
| 56 "curve length", | 56 "curve length", |
| 57 curve->length(), | 57 curve->length(), |
| 58 2)); | 58 2)); |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 | 61 |
| 62 waveShaperProcessor()->setCurve(curve); | 62 getWaveShaperProcessor()->setCurve(curve); |
| 63 } | 63 } |
| 64 | 64 |
| 65 DOMFloat32Array* WaveShaperNode::curve() | 65 DOMFloat32Array* WaveShaperNode::curve() |
| 66 { | 66 { |
| 67 return waveShaperProcessor()->curve(); | 67 return getWaveShaperProcessor()->curve(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void WaveShaperNode::setOversample(const String& type) | 70 void WaveShaperNode::setOversample(const String& type) |
| 71 { | 71 { |
| 72 ASSERT(isMainThread()); | 72 ASSERT(isMainThread()); |
| 73 | 73 |
| 74 // This is to synchronize with the changes made in | 74 // This is to synchronize with the changes made in |
| 75 // AudioBasicProcessorNode::checkNumberOfChannelsForInput() where we can | 75 // AudioBasicProcessorNode::checkNumberOfChannelsForInput() where we can |
| 76 // initialize() and uninitialize(). | 76 // initialize() and uninitialize(). |
| 77 AbstractAudioContext::AutoLocker contextLocker(context()); | 77 AbstractAudioContext::AutoLocker contextLocker(context()); |
| 78 | 78 |
| 79 if (type == "none") { | 79 if (type == "none") { |
| 80 waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSampleNone
); | 80 getWaveShaperProcessor()->setOversample(WaveShaperProcessor::OverSampleN
one); |
| 81 } else if (type == "2x") { | 81 } else if (type == "2x") { |
| 82 waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample2x); | 82 getWaveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample2
x); |
| 83 } else if (type == "4x") { | 83 } else if (type == "4x") { |
| 84 waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample4x); | 84 getWaveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample4
x); |
| 85 } else { | 85 } else { |
| 86 ASSERT_NOT_REACHED(); | 86 ASSERT_NOT_REACHED(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 String WaveShaperNode::oversample() const | 90 String WaveShaperNode::oversample() const |
| 91 { | 91 { |
| 92 switch (const_cast<WaveShaperNode*>(this)->waveShaperProcessor()->oversample
()) { | 92 switch (const_cast<WaveShaperNode*>(this)->getWaveShaperProcessor()->oversam
ple()) { |
| 93 case WaveShaperProcessor::OverSampleNone: | 93 case WaveShaperProcessor::OverSampleNone: |
| 94 return "none"; | 94 return "none"; |
| 95 case WaveShaperProcessor::OverSample2x: | 95 case WaveShaperProcessor::OverSample2x: |
| 96 return "2x"; | 96 return "2x"; |
| 97 case WaveShaperProcessor::OverSample4x: | 97 case WaveShaperProcessor::OverSample4x: |
| 98 return "4x"; | 98 return "4x"; |
| 99 default: | 99 default: |
| 100 ASSERT_NOT_REACHED(); | 100 ASSERT_NOT_REACHED(); |
| 101 return "none"; | 101 return "none"; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace blink | 105 } // namespace blink |
| 106 | 106 |
| OLD | NEW |