Changeset 88074 in webkit
- Timestamp:
- Jun 3, 2011 4:03:04 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88072 r88074 1 2011-06-03 Chris Rogers <crogers@google.com> 2 3 Reviewed by Kenneth Russell. 4 5 Allow existing AudioParams to use scheduled parameter changes 6 https://bugs.webkit.org/show_bug.cgi?id=62046 7 8 No new tests since audio API is not yet implemented. 9 10 * platform/audio/AudioBus.cpp: 11 (WebCore::AudioBus::processWithGainFrom): 12 (WebCore::AudioBus::copyWithSampleAccurateGainValuesFrom): 13 * platform/audio/AudioBus.h: 14 * webaudio/AudioBufferSourceNode.cpp: 15 (WebCore::AudioBufferSourceNode::AudioBufferSourceNode): 16 * webaudio/AudioGainNode.cpp: 17 (WebCore::AudioGainNode::AudioGainNode): 18 (WebCore::AudioGainNode::process): 19 * webaudio/AudioGainNode.h: 20 * webaudio/HighPass2FilterNode.cpp: 21 (WebCore::HighPass2FilterNode::HighPass2FilterNode): 22 * webaudio/LowPass2FilterNode.cpp: 23 (WebCore::LowPass2FilterNode::LowPass2FilterNode): 24 1 25 2011-06-03 Chris Rogers <crogers@google.com> 2 26 -
trunk/Source/WebCore/platform/audio/AudioBus.cpp
r86217 r88074 337 337 // Make sure we're summing from same type of bus. 338 338 // We *are* able to sum from mono -> stereo 339 if (sourceBus.numberOfChannels() != 1 && !topologyMatches(sourceBus)) 339 if (sourceBus.numberOfChannels() != 1 && !topologyMatches(sourceBus)) { 340 ASSERT_NOT_REACHED(); 340 341 return; 342 } 341 343 342 344 // Dispatch for different channel layouts … … 351 353 ASSERT_NOT_REACHED(); 352 354 break; 355 } 356 } 357 358 void AudioBus::copyWithSampleAccurateGainValuesFrom(const AudioBus &sourceBus, float* gainValues, unsigned numberOfGainValues) 359 { 360 // Make sure we're processing from the same type of bus. 361 // We *are* able to process from mono -> stereo 362 if (sourceBus.numberOfChannels() != 1 && !topologyMatches(sourceBus)) { 363 ASSERT_NOT_REACHED(); 364 return; 365 } 366 367 if (!gainValues || numberOfGainValues > sourceBus.length()) { 368 ASSERT_NOT_REACHED(); 369 return; 370 } 371 372 // FIXME: this can potentially use SIMD optimizations with vector libraries. 373 // We handle both the 1 -> N and N -> N case here. 374 const float* source = sourceBus.channel(0)->data(); 375 for (unsigned channelIndex = 0; channelIndex < numberOfChannels(); ++channelIndex) { 376 if (sourceBus.numberOfChannels() == numberOfChannels()) 377 source = sourceBus.channel(channelIndex)->data(); 378 float* destination = channel(channelIndex)->data(); 379 for (unsigned i = 0; i < numberOfGainValues; ++i) 380 destination[i] = source[i] * gainValues[i]; 353 381 } 354 382 } -
trunk/Source/WebCore/platform/audio/AudioBus.h
r81931 r88074 125 125 void sumWithGainFrom(const AudioBus &sourceBus, double* lastMixGain, double targetGain); 126 126 127 // Copies the sourceBus by scaling with sample-accurate gain values. 128 void copyWithSampleAccurateGainValuesFrom(const AudioBus &sourceBus, float* gainValues, unsigned numberOfGainValues); 129 127 130 // Returns maximum absolute value across all channels (useful for normalization). 128 131 float maxAbsValue() const; -
trunk/Source/WebCore/webaudio/AudioBufferSourceNode.cpp
r87013 r88074 67 67 m_gain = AudioGain::create("gain", 1.0, 0.0, 1.0); 68 68 m_playbackRate = AudioParam::create("playbackRate", 1.0, 0.0, AudioResampler::MaxRate); 69 70 m_gain->setContext(context); 71 m_playbackRate->setContext(context); 69 72 70 73 // Default to mono. A call to setBuffer() will set the number of output channels to that of the buffer. -
trunk/Source/WebCore/webaudio/AudioGainNode.cpp
r71200 r88074 38 38 : AudioNode(context, sampleRate) 39 39 , m_lastGain(1.0) 40 , m_sampleAccurateGainValues(AudioNode::ProcessingSizeInFrames) // FIXME: can probably share temp buffer in context 40 41 { 41 42 m_gain = AudioGain::create("gain", 1.0, 0.0, 1.0); 43 m_gain->setContext(context); 42 44 43 45 addInput(adoptPtr(new AudioNodeInput(this))); … … 49 51 } 50 52 51 void AudioGainNode::process(size_t /*framesToProcess*/)53 void AudioGainNode::process(size_t framesToProcess) 52 54 { 53 // FIXME: there is a nice optimization to avoid processing here, and let the gain change55 // FIXME: for some cases there is a nice optimization to avoid processing here, and let the gain change 54 56 // happen in the summing junction input of the AudioNode we're connected to. 55 57 // Then we can avoid all of the following: … … 65 67 AudioBus* inputBus = input(0)->bus(); 66 68 67 // Apply the gain with de-zippering into the output bus. 68 outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain()->value()); 69 if (gain()->hasTimelineValues()) { 70 // Apply sample-accurate gain scaling for precise envelopes, grain windows, etc. 71 ASSERT(framesToProcess <= m_sampleAccurateGainValues.size()); 72 if (framesToProcess <= m_sampleAccurateGainValues.size()) { 73 float* gainValues = m_sampleAccurateGainValues.data(); 74 gain()->calculateSampleAccurateValues(gainValues, framesToProcess); 75 outputBus->copyWithSampleAccurateGainValuesFrom(*inputBus, gainValues, framesToProcess); 76 } 77 } else { 78 // Apply the gain with de-zippering into the output bus. 79 outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain()->value()); 80 } 69 81 } 70 82 -
trunk/Source/WebCore/webaudio/AudioGainNode.h
r71149 r88074 61 61 RefPtr<AudioGain> m_gain; 62 62 63 AudioFloatArray m_sampleAccurateGainValues; 64 63 65 // This synchronizes live channel count changes which require an uninitialization / re-initialization. 64 66 // FIXME: this can go away when we implement optimization for mixing with gain directly in summing junction of AudioNodeInput. -
trunk/Source/WebCore/webaudio/HighPass2FilterNode.cpp
r69088 r88074 35 35 { 36 36 m_processor = adoptPtr(new BiquadProcessor(BiquadProcessor::HighPass2, sampleRate, 1, false)); 37 biquadProcessor()->parameter1()->setContext(context); 38 biquadProcessor()->parameter2()->setContext(context); 39 biquadProcessor()->parameter3()->setContext(context); 37 40 setType(NodeTypeHighPass2Filter); 38 41 } -
trunk/Source/WebCore/webaudio/LowPass2FilterNode.cpp
r69087 r88074 35 35 { 36 36 m_processor = adoptPtr(new BiquadProcessor(BiquadProcessor::LowPass2, sampleRate, 1, false)); 37 biquadProcessor()->parameter1()->setContext(context); 38 biquadProcessor()->parameter2()->setContext(context); 39 biquadProcessor()->parameter3()->setContext(context); 37 40 setType(NodeTypeLowPass2Filter); 38 41 }
Note: See TracChangeset
for help on using the changeset viewer.