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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 NotSupportedError, | 104 NotSupportedError, |
105 "The buffer sample rate of " + String::number(buffer->sampleRate()) | 105 "The buffer sample rate of " + String::number(buffer->sampleRate()) |
106 + " does not match the context rate of " + String::number(context()-
>sampleRate()) | 106 + " does not match the context rate of " + String::number(context()-
>sampleRate()) |
107 + " Hz."); | 107 + " Hz."); |
108 return; | 108 return; |
109 } | 109 } |
110 | 110 |
111 unsigned numberOfChannels = buffer->numberOfChannels(); | 111 unsigned numberOfChannels = buffer->numberOfChannels(); |
112 size_t bufferLength = buffer->length(); | 112 size_t bufferLength = buffer->length(); |
113 | 113 |
114 // The current implementation supports up to four channel impulse responses,
which are interpreted as true-stereo (see Reverb class). | 114 // The current implementation supports only 1-, 2-, or 4-channel impulse res
ponses, with the |
115 bool isBufferGood = numberOfChannels > 0 && numberOfChannels <= 4 && bufferL
ength; | 115 // 4-channel response being interpreted as true-stereo (see Reverb class). |
116 ASSERT(isBufferGood); | 116 bool isChannelCountGood = numberOfChannels == 1 || numberOfChannels == 2 ||
numberOfChannels == 4; |
117 if (!isBufferGood) | 117 |
| 118 if (!isChannelCountGood) { |
| 119 exceptionState.throwDOMException( |
| 120 NotSupportedError, |
| 121 "The buffer must have 1, 2, or 4 channels, not " + String::number(nu
mberOfChannels)); |
118 return; | 122 return; |
| 123 } |
119 | 124 |
120 // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and no
t a memcpy(). | 125 // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and no
t a memcpy(). |
121 // This memory is simply used in the Reverb constructor and no reference to
it is kept for later use in that class. | 126 // This memory is simply used in the Reverb constructor and no reference to
it is kept for later use in that class. |
122 RefPtr<AudioBus> bufferBus = AudioBus::create(numberOfChannels, bufferLength
, false); | 127 RefPtr<AudioBus> bufferBus = AudioBus::create(numberOfChannels, bufferLength
, false); |
123 for (unsigned i = 0; i < numberOfChannels; ++i) | 128 for (unsigned i = 0; i < numberOfChannels; ++i) |
124 bufferBus->setChannelMemory(i, buffer->getChannelData(i)->data(), buffer
Length); | 129 bufferBus->setChannelMemory(i, buffer->getChannelData(i)->data(), buffer
Length); |
125 | 130 |
126 bufferBus->setSampleRate(buffer->sampleRate()); | 131 bufferBus->setSampleRate(buffer->sampleRate()); |
127 | 132 |
128 // Create the reverb with the given impulse response. | 133 // Create the reverb with the given impulse response. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 201 } |
197 | 202 |
198 void ConvolverNode::setNormalize(bool normalize) | 203 void ConvolverNode::setNormalize(bool normalize) |
199 { | 204 { |
200 convolverHandler().setNormalize(normalize); | 205 convolverHandler().setNormalize(normalize); |
201 } | 206 } |
202 | 207 |
203 } // namespace blink | 208 } // namespace blink |
204 | 209 |
205 #endif // ENABLE(WEB_AUDIO) | 210 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |