Source/WebCore: Add Oscillator/WaveTable implementation and tests
[WebKit-https.git] / Source / WebCore / Modules / webaudio / AudioContext.cpp
index 18c5ad8..f123fd9 100644 (file)
 #include "JavaScriptAudioNode.h"
 #include "OfflineAudioCompletionEvent.h"
 #include "OfflineAudioDestinationNode.h"
+#include "Oscillator.h"
 #include "PlatformString.h"
 #include "RealtimeAnalyserNode.h"
-#include "WaveShaperNode.h"
 #include "ScriptCallStack.h"
+#include "WaveShaperNode.h"
+#include "WaveTable.h"
 
 #if ENABLE(VIDEO)
 #include "HTMLMediaElement.h"
@@ -453,6 +455,26 @@ PassRefPtr<AudioChannelMerger> AudioContext::createChannelMerger()
     return AudioChannelMerger::create(this, m_destinationNode->sampleRate());
 }
 
+PassRefPtr<Oscillator> AudioContext::createOscillator()
+{
+    ASSERT(isMainThread());
+    lazyInitialize();
+    return Oscillator::create(this, m_destinationNode->sampleRate());
+}
+
+PassRefPtr<WaveTable> AudioContext::createWaveTable(Float32Array* real, Float32Array* imag, ExceptionCode& ec)
+{
+    ASSERT(isMainThread());
+    
+    if (!real || !imag || (real->length() != imag->length())) {
+        ec = SYNTAX_ERR;
+        return 0;
+    }
+    
+    lazyInitialize();
+    return WaveTable::create(sampleRate(), real, imag);
+}
+
 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node)
 {
     ASSERT(isAudioThread());