Diff
Modified: trunk/Source/WebCore/ChangeLog (91280 => 91281)
--- trunk/Source/WebCore/ChangeLog 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/ChangeLog 2011-07-19 18:59:35 UTC (rev 91281)
@@ -1,3 +1,45 @@
+2011-07-19 Chris Rogers <[email protected]>
+
+ Implement WaveShaperNode for Web Audio API
+ https://bugs.webkit.org/show_bug.cgi?id=64644
+
+ Reviewed by Kenneth Russell.
+
+ No new tests since audio API is not yet implemented.
+
+ * DerivedSources.make:
+ * WebCore.gypi:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSWaveShaperNodeCustom.cpp: Added.
+ (WebCore::JSWaveShaperNode::setCurve):
+ * webaudio/AudioContext.cpp:
+ (WebCore::AudioContext::createWaveShaper):
+ * webaudio/AudioContext.h:
+ * webaudio/AudioContext.idl:
+ * webaudio/AudioNode.h:
+ * webaudio/WaveShaperDSPKernel.cpp: Added.
+ (WebCore::WaveShaperDSPKernel::process):
+ * webaudio/WaveShaperDSPKernel.h: Added.
+ (WebCore::WaveShaperDSPKernel::WaveShaperDSPKernel):
+ (WebCore::WaveShaperDSPKernel::reset):
+ (WebCore::WaveShaperDSPKernel::waveShaperProcessor):
+ * webaudio/WaveShaperNode.cpp: Added.
+ (WebCore::WaveShaperNode::WaveShaperNode):
+ (WebCore::WaveShaperNode::setCurve):
+ (WebCore::WaveShaperNode::curve):
+ * webaudio/WaveShaperNode.h: Added.
+ (WebCore::WaveShaperNode::create):
+ (WebCore::WaveShaperNode::waveShaperProcessor):
+ * webaudio/WaveShaperNode.idl: Added.
+ * webaudio/WaveShaperProcessor.cpp: Added.
+ (WebCore::WaveShaperProcessor::WaveShaperProcessor):
+ (WebCore::WaveShaperProcessor::~WaveShaperProcessor):
+ (WebCore::WaveShaperProcessor::createKernel):
+ (WebCore::WaveShaperProcessor::setCurve):
+ (WebCore::WaveShaperProcessor::process):
+ * webaudio/WaveShaperProcessor.h: Added.
+ (WebCore::WaveShaperProcessor::curve):
+
2011-07-19 Robert Hogan <[email protected]>
REGRESSION: Incorrect layout at recline-online.com
Modified: trunk/Source/WebCore/DerivedSources.make (91280 => 91281)
--- trunk/Source/WebCore/DerivedSources.make 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/DerivedSources.make 2011-07-19 18:59:35 UTC (rev 91281)
@@ -78,6 +78,7 @@
LowPass2FilterNode \
OfflineAudioCompletionEvent \
RealtimeAnalyserNode \
+ WaveShaperNode \
BarInfo \
BeforeLoadEvent \
BeforeProcessEvent \
Modified: trunk/Source/WebCore/WebCore.gypi (91280 => 91281)
--- trunk/Source/WebCore/WebCore.gypi 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/WebCore.gypi 2011-07-19 18:59:35 UTC (rev 91281)
@@ -1448,6 +1448,7 @@
'webaudio/LowPass2FilterNode.idl',
'webaudio/OfflineAudioCompletionEvent.idl',
'webaudio/RealtimeAnalyserNode.idl',
+ 'webaudio/WaveShaperNode.idl',
'websockets/CloseEvent.idl',
'websockets/WebSocket.idl',
'workers/AbstractWorker.idl',
@@ -6056,6 +6057,12 @@
'webaudio/RealtimeAnalyser.h',
'webaudio/RealtimeAnalyserNode.cpp',
'webaudio/RealtimeAnalyserNode.h',
+ 'webaudio/WaveShaperDSPKernel.cpp',
+ 'webaudio/WaveShaperDSPKernel.h',
+ 'webaudio/WaveShaperNode.cpp',
+ 'webaudio/WaveShaperNode.h',
+ 'webaudio/WaveShaperProcessor.cpp',
+ 'webaudio/WaveShaperProcessor.h',
'websockets/CloseEvent.h',
'websockets/ThreadableWebSocketChannel.cpp',
'websockets/ThreadableWebSocketChannel.h',
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (91280 => 91281)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-07-19 18:59:35 UTC (rev 91281)
@@ -5860,6 +5860,15 @@
FD6ED2C8136B8E66003CF072 /* DynamicsCompressor.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6ED2C6136B8E66003CF072 /* DynamicsCompressor.h */; };
FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */; };
FD7868BA136B999200D403DF /* JSDynamicsCompressorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */; };
+ FD7F299113D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7F298A13D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp */; };
+ FD7F299213D4C0CB00AD9535 /* WaveShaperDSPKernel.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7F298B13D4C0CB00AD9535 /* WaveShaperDSPKernel.h */; };
+ FD7F299313D4C0CB00AD9535 /* WaveShaperNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7F298C13D4C0CB00AD9535 /* WaveShaperNode.cpp */; };
+ FD7F299413D4C0CB00AD9535 /* WaveShaperNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7F298D13D4C0CB00AD9535 /* WaveShaperNode.h */; };
+ FD7F299613D4C0CB00AD9535 /* WaveShaperProcessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7F298F13D4C0CB00AD9535 /* WaveShaperProcessor.cpp */; };
+ FD7F299713D4C0CB00AD9535 /* WaveShaperProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7F299013D4C0CB00AD9535 /* WaveShaperProcessor.h */; };
+ FD82D7F713D4C8BD004E4372 /* JSWaveShaperNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD82D7F513D4C8BD004E4372 /* JSWaveShaperNode.cpp */; };
+ FD82D7F813D4C8BD004E4372 /* JSWaveShaperNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD82D7F613D4C8BD004E4372 /* JSWaveShaperNode.h */; };
+ FD8E9BDF13D4CD2B0050DC72 /* JSWaveShaperNodeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD8E9BDE13D4CD2B0050DC72 /* JSWaveShaperNodeCustom.cpp */; };
FDA15E9D12B03EE1003A583A /* JSAudioBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDA15E8112B03EE1003A583A /* JSAudioBuffer.cpp */; };
FDA15E9E12B03EE1003A583A /* JSAudioBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA15E8212B03EE1003A583A /* JSAudioBuffer.h */; };
FDA15E9F12B03EE1003A583A /* JSAudioBufferSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDA15E8312B03EE1003A583A /* JSAudioBufferSourceNode.cpp */; };
@@ -12581,6 +12590,16 @@
FD6ED2C9136B8E9D003CF072 /* DynamicsCompressorNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DynamicsCompressorNode.idl; sourceTree = "<group>"; };
FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDynamicsCompressorNode.cpp; sourceTree = "<group>"; };
FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDynamicsCompressorNode.h; sourceTree = "<group>"; };
+ FD7F298A13D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaveShaperDSPKernel.cpp; sourceTree = "<group>"; };
+ FD7F298B13D4C0CB00AD9535 /* WaveShaperDSPKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WaveShaperDSPKernel.h; sourceTree = "<group>"; };
+ FD7F298C13D4C0CB00AD9535 /* WaveShaperNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaveShaperNode.cpp; sourceTree = "<group>"; };
+ FD7F298D13D4C0CB00AD9535 /* WaveShaperNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WaveShaperNode.h; sourceTree = "<group>"; };
+ FD7F298E13D4C0CB00AD9535 /* WaveShaperNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WaveShaperNode.idl; sourceTree = "<group>"; };
+ FD7F298F13D4C0CB00AD9535 /* WaveShaperProcessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaveShaperProcessor.cpp; sourceTree = "<group>"; };
+ FD7F299013D4C0CB00AD9535 /* WaveShaperProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WaveShaperProcessor.h; sourceTree = "<group>"; };
+ FD82D7F513D4C8BD004E4372 /* JSWaveShaperNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWaveShaperNode.cpp; sourceTree = "<group>"; };
+ FD82D7F613D4C8BD004E4372 /* JSWaveShaperNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWaveShaperNode.h; sourceTree = "<group>"; };
+ FD8E9BDE13D4CD2B0050DC72 /* JSWaveShaperNodeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWaveShaperNodeCustom.cpp; sourceTree = "<group>"; };
FDA15E8112B03EE1003A583A /* JSAudioBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioBuffer.cpp; sourceTree = "<group>"; };
FDA15E8212B03EE1003A583A /* JSAudioBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAudioBuffer.h; sourceTree = "<group>"; };
FDA15E8312B03EE1003A583A /* JSAudioBufferSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioBufferSourceNode.cpp; sourceTree = "<group>"; };
@@ -18535,6 +18554,7 @@
49EECF7710508D9C00099FAB /* JSUint16ArrayCustom.cpp */,
49EECF7610508D9C00099FAB /* JSUint32ArrayCustom.cpp */,
49EECF7510508D9C00099FAB /* JSUint8ArrayCustom.cpp */,
+ FD8E9BDE13D4CD2B0050DC72 /* JSWaveShaperNodeCustom.cpp */,
49EED14C1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp */,
319E68861327C911004AC91A /* JSWebKitAnimationCustom.cpp */,
3194623113022F65004BB3F8 /* JSWebKitAnimationListCustom.cpp */,
@@ -19973,6 +19993,13 @@
FD315FF312B0267600C1A359 /* RealtimeAnalyserNode.cpp */,
FD315FF412B0267600C1A359 /* RealtimeAnalyserNode.h */,
FD315FF512B0267600C1A359 /* RealtimeAnalyserNode.idl */,
+ FD7F298A13D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp */,
+ FD7F298B13D4C0CB00AD9535 /* WaveShaperDSPKernel.h */,
+ FD7F298C13D4C0CB00AD9535 /* WaveShaperNode.cpp */,
+ FD7F298D13D4C0CB00AD9535 /* WaveShaperNode.h */,
+ FD7F298E13D4C0CB00AD9535 /* WaveShaperNode.idl */,
+ FD7F298F13D4C0CB00AD9535 /* WaveShaperProcessor.cpp */,
+ FD7F299013D4C0CB00AD9535 /* WaveShaperProcessor.h */,
);
path = webaudio;
sourceTree = "<group>";
@@ -20110,6 +20137,8 @@
FDF6BAF7134A4C9800822920 /* JSOfflineAudioCompletionEvent.h */,
FDA15EC712B03F50003A583A /* JSRealtimeAnalyserNode.cpp */,
FDA15EC812B03F50003A583A /* JSRealtimeAnalyserNode.h */,
+ FD82D7F513D4C8BD004E4372 /* JSWaveShaperNode.cpp */,
+ FD82D7F613D4C8BD004E4372 /* JSWaveShaperNode.h */,
);
name = WebAudio;
sourceTree = "<group>";
@@ -23110,6 +23139,10 @@
FD537353137B651800008DCE /* ZeroPole.h in Headers */,
4945BFD413CF809000CC3B38 /* TransformState.h in Headers */,
4969B0F313D0B33F00DF3521 /* HitTestingTransformState.h in Headers */,
+ FD7F299213D4C0CB00AD9535 /* WaveShaperDSPKernel.h in Headers */,
+ FD7F299413D4C0CB00AD9535 /* WaveShaperNode.h in Headers */,
+ FD7F299713D4C0CB00AD9535 /* WaveShaperProcessor.h in Headers */,
+ FD82D7F813D4C8BD004E4372 /* JSWaveShaperNode.h in Headers */,
5913A24213D49EBA00F5B05C /* IdentifiersFactory.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -25882,6 +25915,11 @@
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
4945BFD313CF809000CC3B38 /* TransformState.cpp in Sources */,
4969B0F213D0B33F00DF3521 /* HitTestingTransformState.cpp in Sources */,
+ FD7F299113D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp in Sources */,
+ FD7F299313D4C0CB00AD9535 /* WaveShaperNode.cpp in Sources */,
+ FD7F299613D4C0CB00AD9535 /* WaveShaperProcessor.cpp in Sources */,
+ FD82D7F713D4C8BD004E4372 /* JSWaveShaperNode.cpp in Sources */,
+ FD8E9BDF13D4CD2B0050DC72 /* JSWaveShaperNodeCustom.cpp in Sources */,
5913A24113D49EBA00F5B05C /* IdentifiersFactory.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Added: trunk/Source/WebCore/bindings/js/JSWaveShaperNodeCustom.cpp (0 => 91281)
--- trunk/Source/WebCore/bindings/js/JSWaveShaperNodeCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSWaveShaperNodeCustom.cpp 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "WaveShaperNode.h"
+
+#include "Float32Array.h"
+#include "JSFloat32Array.h"
+#include "JSWaveShaperNode.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSWaveShaperNode::setCurve(ExecState*, JSValue value)
+{
+ WaveShaperNode* imp = static_cast<WaveShaperNode*>(impl());
+ imp->setCurve(toFloat32Array(value));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
Modified: trunk/Source/WebCore/webaudio/AudioContext.cpp (91280 => 91281)
--- trunk/Source/WebCore/webaudio/AudioContext.cpp 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/webaudio/AudioContext.cpp 2011-07-19 18:59:35 UTC (rev 91281)
@@ -56,6 +56,7 @@
#include "OfflineAudioDestinationNode.h"
#include "PlatformString.h"
#include "RealtimeAnalyserNode.h"
+#include "WaveShaperNode.h"
#include "ScriptCallStack.h"
#if DEBUG_AUDIONODE_REFERENCES
@@ -324,6 +325,13 @@
return BiquadFilterNode::create(this, m_destinationNode->sampleRate());
}
+PassRefPtr<WaveShaperNode> AudioContext::createWaveShaper()
+{
+ ASSERT(isMainThread());
+ lazyInitialize();
+ return WaveShaperNode::create(this);
+}
+
PassRefPtr<LowPass2FilterNode> AudioContext::createLowPass2Filter()
{
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/webaudio/AudioContext.h (91280 => 91281)
--- trunk/Source/WebCore/webaudio/AudioContext.h 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/webaudio/AudioContext.h 2011-07-19 18:59:35 UTC (rev 91281)
@@ -60,6 +60,7 @@
class ConvolverNode;
class DynamicsCompressorNode;
class RealtimeAnalyserNode;
+class WaveShaperNode;
class _javascript_AudioNode;
// AudioContext is the cornerstone of the web audio API and all AudioNodes are created from it.
@@ -107,6 +108,7 @@
PassRefPtr<AudioBufferSourceNode> createBufferSource();
PassRefPtr<AudioGainNode> createGainNode();
PassRefPtr<BiquadFilterNode> createBiquadFilter();
+ PassRefPtr<WaveShaperNode> createWaveShaper();
PassRefPtr<DelayNode> createDelayNode();
PassRefPtr<LowPass2FilterNode> createLowPass2Filter();
PassRefPtr<HighPass2FilterNode> createHighPass2Filter();
Modified: trunk/Source/WebCore/webaudio/AudioContext.idl (91280 => 91281)
--- trunk/Source/WebCore/webaudio/AudioContext.idl 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/webaudio/AudioContext.idl 2011-07-19 18:59:35 UTC (rev 91281)
@@ -64,6 +64,7 @@
AudioGainNode createGainNode();
DelayNode createDelayNode();
BiquadFilterNode createBiquadFilter();
+ WaveShaperNode createWaveShaper();
LowPass2FilterNode createLowPass2Filter();
HighPass2FilterNode createHighPass2Filter();
AudioPannerNode createPanner();
Modified: trunk/Source/WebCore/webaudio/AudioNode.h (91280 => 91281)
--- trunk/Source/WebCore/webaudio/AudioNode.h 2011-07-19 18:55:16 UTC (rev 91280)
+++ trunk/Source/WebCore/webaudio/AudioNode.h 2011-07-19 18:59:35 UTC (rev 91281)
@@ -69,6 +69,7 @@
NodeTypeChannelMerger,
NodeTypeAnalyser,
NodeTypeDynamicsCompressor,
+ NodeTypeWaveShaper,
NodeTypeEnd
};
Added: trunk/Source/WebCore/webaudio/WaveShaperDSPKernel.cpp (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperDSPKernel.cpp (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperDSPKernel.cpp 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "WaveShaperDSPKernel.h"
+
+#include "WaveShaperProcessor.h"
+#include <algorithm>
+
+using namespace std;
+
+namespace WebCore {
+
+void WaveShaperDSPKernel::process(const float* source, float* destination, size_t framesToProcess)
+{
+ ASSERT(source && destination && waveShaperProcessor());
+
+ Float32Array* curve = waveShaperProcessor()->curve();
+ if (!curve) {
+ // Act as "straight wire" pass-through if no curve is set.
+ memcpy(destination, source, sizeof(float) * framesToProcess);
+ return;
+ }
+
+ float* curveData = curve->data();
+ int curveLength = curve->length();
+
+ ASSERT(curveData);
+
+ if (!curveData || !curveLength) {
+ memcpy(destination, source, sizeof(float) * framesToProcess);
+ return;
+ }
+
+ // Apply waveshaping curve.
+ for (unsigned i = 0; i < framesToProcess; ++i) {
+ const float input = source[i];
+
+ // Calculate an index based on input -1 -> +1 with 0 being at the center of the curve data.
+ int index = curveLength * 0.5 * (input + 1);
+
+ // Clip index to the input range of the curve.
+ // This takes care of input outside of nominal range -1 -> +1
+ index = max(index, 0);
+ index = min(index, curveLength - 1);
+ destination[i] = curveData[index];
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
Added: trunk/Source/WebCore/webaudio/WaveShaperDSPKernel.h (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperDSPKernel.h (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperDSPKernel.h 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WaveShaperDSPKernel_h
+#define WaveShaperDSPKernel_h
+
+#include "AudioDSPKernel.h"
+#include "WaveShaperProcessor.h"
+
+namespace WebCore {
+
+class WaveShaperProcessor;
+
+// WaveShaperDSPKernel is an AudioDSPKernel and is responsible for non-linear distortion on one channel.
+
+class WaveShaperDSPKernel : public AudioDSPKernel {
+public:
+ WaveShaperDSPKernel(WaveShaperProcessor* processor)
+ : AudioDSPKernel(processor)
+ {
+ }
+
+ // AudioDSPKernel
+ virtual void process(const float* source, float* dest, size_t framesToProcess);
+ virtual void reset() { }
+
+protected:
+ WaveShaperProcessor* waveShaperProcessor() { return static_cast<WaveShaperProcessor*>(processor()); }
+};
+
+} // namespace WebCore
+
+#endif // WaveShaperDSPKernel_h
Added: trunk/Source/WebCore/webaudio/WaveShaperNode.cpp (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperNode.cpp (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperNode.cpp 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "WaveShaperNode.h"
+
+namespace WebCore {
+
+WaveShaperNode::WaveShaperNode(AudioContext* context)
+ : AudioBasicProcessorNode(context, context->sampleRate())
+{
+ m_processor = adoptPtr(new WaveShaperProcessor(context->sampleRate(), 1));
+ setType(NodeTypeWaveShaper);
+}
+
+void WaveShaperNode::setCurve(Float32Array* curve)
+{
+ ASSERT(isMainThread());
+ waveShaperProcessor()->setCurve(curve);
+}
+
+Float32Array* WaveShaperNode::curve()
+{
+ return waveShaperProcessor()->curve();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
Added: trunk/Source/WebCore/webaudio/WaveShaperNode.h (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperNode.h (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperNode.h 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WaveShaperNode_h
+#define WaveShaperNode_h
+
+#include "AudioBasicProcessorNode.h"
+#include "BiquadProcessor.h"
+#include "WaveShaperProcessor.h"
+
+namespace WebCore {
+
+class Float32Array;
+
+class WaveShaperNode : public AudioBasicProcessorNode {
+public:
+ static PassRefPtr<WaveShaperNode> create(AudioContext* context)
+ {
+ return adoptRef(new WaveShaperNode(context));
+ }
+
+ // setCurve() is called on the main thread.
+ void setCurve(Float32Array*);
+ Float32Array* curve();
+
+private:
+ WaveShaperNode(AudioContext*);
+
+ WaveShaperProcessor* waveShaperProcessor() { return static_cast<WaveShaperProcessor*>(processor()); }
+};
+
+} // namespace WebCore
+
+#endif // WaveShaperNode_h
Added: trunk/Source/WebCore/webaudio/WaveShaperNode.idl (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperNode.idl (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperNode.idl 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module audio {
+ interface [
+ Conditional=WEB_AUDIO,
+ GenerateToJS
+ ] WaveShaperNode : AudioNode {
+ attribute [JSCCustomSetter] Float32Array curve;
+ };
+}
Added: trunk/Source/WebCore/webaudio/WaveShaperProcessor.cpp (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperProcessor.cpp (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperProcessor.cpp 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "WaveShaperProcessor.h"
+
+#include "WaveShaperDSPKernel.h"
+
+namespace WebCore {
+
+WaveShaperProcessor::WaveShaperProcessor(double sampleRate, size_t numberOfChannels)
+ : AudioDSPKernelProcessor(sampleRate, numberOfChannels)
+{
+}
+
+WaveShaperProcessor::~WaveShaperProcessor()
+{
+ if (isInitialized())
+ uninitialize();
+}
+
+PassOwnPtr<AudioDSPKernel> WaveShaperProcessor::createKernel()
+{
+ return adoptPtr(new WaveShaperDSPKernel(this));
+}
+
+void WaveShaperProcessor::setCurve(Float32Array* curve)
+{
+ // This synchronizes with process().
+ MutexLocker processLocker(m_processLock);
+
+ m_curve = curve;
+}
+
+void WaveShaperProcessor::process(AudioBus* source, AudioBus* destination, size_t framesToProcess)
+{
+ if (!isInitialized()) {
+ destination->zero();
+ return;
+ }
+
+ // The audio thread can't block on this lock, so we call tryLock() instead.
+ // Careful - this is a tryLock() and not an autolocker, so we must unlock() before every return.
+ if (m_processLock.tryLock()) {
+ // For each channel of our input, process using the corresponding WaveShaperDSPKernel into the output channel.
+ for (unsigned i = 0; i < m_kernels.size(); ++i)
+ m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->data(), framesToProcess);
+
+ m_processLock.unlock();
+ } else {
+ // Too bad - the tryLock() failed. We must be in the middle of a setCurve() call.
+ destination->zero();
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
Added: trunk/Source/WebCore/webaudio/WaveShaperProcessor.h (0 => 91281)
--- trunk/Source/WebCore/webaudio/WaveShaperProcessor.h (rev 0)
+++ trunk/Source/WebCore/webaudio/WaveShaperProcessor.h 2011-07-19 18:59:35 UTC (rev 91281)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WaveShaperProcessor_h
+#define WaveShaperProcessor_h
+
+#include "AudioDSPKernel.h"
+#include "AudioDSPKernelProcessor.h"
+#include "AudioNode.h"
+#include "Float32Array.h"
+#include <wtf/RefPtr.h>
+#include <wtf/Threading.h>
+
+namespace WebCore {
+
+// WaveShaperProcessor is an AudioDSPKernelProcessor which uses WaveShaperDSPKernel objects to implement non-linear distortion effects.
+
+class WaveShaperProcessor : public AudioDSPKernelProcessor {
+public:
+ WaveShaperProcessor(double sampleRate, size_t numberOfChannels);
+
+ virtual ~WaveShaperProcessor();
+
+ virtual PassOwnPtr<AudioDSPKernel> createKernel();
+
+ virtual void process(AudioBus* source, AudioBus* destination, size_t framesToProcess);
+
+ void setCurve(Float32Array*);
+ Float32Array* curve() { return m_curve.get(); }
+
+private:
+ // m_curve represents the non-linear shaping curve.
+ RefPtr<Float32Array> m_curve;
+
+ // This synchronizes process() with setCurve().
+ mutable Mutex m_processLock;
+};
+
+} // namespace WebCore
+
+#endif // WaveShaperProcessor_h