diff --git a/content/media/webaudio/AudioBufferSourceNode.h b/content/media/webaudio/AudioBufferSourceNode.h index 78eea018967a..5d7a0c20d8c7 100644 --- a/content/media/webaudio/AudioBufferSourceNode.h +++ b/content/media/webaudio/AudioBufferSourceNode.h @@ -54,7 +54,22 @@ public: void Start(JSContext* aCx, double aWhen, double aOffset, const Optional& aDuration, ErrorResult& aRv); + void NoteOn(JSContext* aCx, double aWhen, ErrorResult& aRv) + { + Start(aCx, aWhen, 0.0, Optional(), aRv); + } + void NoteGrainOn(JSContext* aCx, double aWhen, double aOffset, + double aDuration, ErrorResult& aRv) + { + Optional duration; + duration.Construct(aDuration); + Start(aCx, aWhen, aOffset, duration, aRv); + } void Stop(double aWhen, ErrorResult& aRv); + void NoteOff(double aWhen, ErrorResult& aRv) + { + Stop(aWhen, aRv); + } AudioBuffer* GetBuffer() const { diff --git a/content/media/webaudio/AudioContext.h b/content/media/webaudio/AudioContext.h index 7d1daa405e26..8b2c7ba9de42 100644 --- a/content/media/webaudio/AudioContext.h +++ b/content/media/webaudio/AudioContext.h @@ -106,9 +106,21 @@ public: already_AddRefed CreateGain(); + already_AddRefed + CreateGainNode() + { + return CreateGain(); + } + already_AddRefed CreateDelay(double aMaxDelayTime, ErrorResult& aRv); + already_AddRefed + CreateDelayNode(double aMaxDelayTime, ErrorResult& aRv) + { + return CreateDelay(aMaxDelayTime, aRv); + } + already_AddRefed CreatePanner(); diff --git a/content/media/webaudio/AudioParam.h b/content/media/webaudio/AudioParam.h index 7c68201422b5..2964e0fc5d5c 100644 --- a/content/media/webaudio/AudioParam.h +++ b/content/media/webaudio/AudioParam.h @@ -88,6 +88,10 @@ public: AudioParamTimeline::SetTargetAtTime(aTarget, aStartTime, aTimeConstant, aRv); mCallback(mNode); } + void SetTargetValueAtTime(float aTarget, double aStartTime, double aTimeConstant, ErrorResult& aRv) + { + SetTargetAtTime(aTarget, aStartTime, aTimeConstant, aRv); + } void CancelScheduledValues(double aStartTime) { AudioParamTimeline::CancelScheduledValues(aStartTime); diff --git a/content/media/webaudio/test/Makefile.in b/content/media/webaudio/test/Makefile.in index a2d383ada1fc..adc2553654f3 100644 --- a/content/media/webaudio/test/Makefile.in +++ b/content/media/webaudio/test/Makefile.in @@ -21,6 +21,7 @@ MOCHITEST_FILES := \ test_AudioBuffer.html \ test_AudioContext.html \ test_AudioListener.html \ + test_AudioParam.html \ test_badConnect.html \ test_biquadFilterNode.html \ test_currentTime.html \ diff --git a/content/media/webaudio/test/test_AudioParam.html b/content/media/webaudio/test/test_AudioParam.html new file mode 100644 index 000000000000..e6e546b2ad8e --- /dev/null +++ b/content/media/webaudio/test/test_AudioParam.html @@ -0,0 +1,40 @@ + + + + Test AudioParam + + + + + +
+
+
+ + diff --git a/content/media/webaudio/test/test_delayNode.html b/content/media/webaudio/test/test_delayNode.html index f22f0240b541..4f2139fca6f6 100644 --- a/content/media/webaudio/test/test_delayNode.html +++ b/content/media/webaudio/test/test_delayNode.html @@ -26,6 +26,9 @@ addLoadEvent(function() { var delay = context.createDelay(); + var delay2 = context.createDelayNode(); + isnot(delay, delay2, "createDelayNode should create a different delay node"); + source.buffer = buffer; source.connect(delay); diff --git a/content/media/webaudio/test/test_gainNode.html b/content/media/webaudio/test/test_gainNode.html index 51545c9e57a0..bdecacf6612b 100644 --- a/content/media/webaudio/test/test_gainNode.html +++ b/content/media/webaudio/test/test_gainNode.html @@ -25,6 +25,9 @@ addLoadEvent(function() { var gain = context.createGain(); + var gain2 = context.createGainNode(); + isnot(gain, gain2, "createGainNode should create a different gain node"); + source.buffer = buffer; source.connect(gain); diff --git a/content/media/webaudio/test/test_singleSourceDest.html b/content/media/webaudio/test/test_singleSourceDest.html index 446610184683..843951b390b3 100644 --- a/content/media/webaudio/test/test_singleSourceDest.html +++ b/content/media/webaudio/test/test_singleSourceDest.html @@ -3,6 +3,7 @@ Test whether we can create an AudioContext interface + @@ -25,6 +26,55 @@ addLoadEvent(function() { is(destination.numberOfInputs, 1, "Destination node has 1 inputs"); is(destination.numberOfOutputs, 0, "Destination node has 0 outputs"); + testWith(context, buffer, destination, function(source) { + source.start(0); + }, function(source) { + source.stop(); + }, function() { + testWith(context, buffer, destination, function(source) { + source.start(0, 1); + }, function(source) { + expectTypeError(function() { + source.noteOff(); + }); + source.noteOff(0); + }, function() { + testWith(context, buffer, destination, function(source) { + source.start(0, 1, 0.5); + }, function(source) { + source.stop(0); + }, function() { + testWith(context, buffer, destination, function(source) { + source.noteOn(0); + }, function(source) { + source.noteOff(0); + }, function() { + testWith(context, buffer, destination, function(source) { + source.noteGrainOn(0, 1, 0.5); + }, function(source) { + source.stop(); + }, function() { + SpecialPowers.clearUserPref("media.webaudio.enabled"); + SimpleTest.finish(); + }); + }); + }); + }); + }); +}); + +function testWith(context, buffer, destination, start, stop, callback) +{ + var source = createNode(context, buffer, destination); + start(source); + SimpleTest.executeSoon(function() { + stop(source); + callback(); + source.disconnect(); + }); +} + +function createNode(context, buffer, destination) { var source = context.createBufferSource(); is(source.context, context, "Source node has proper context"); is(source.numberOfInputs, 0, "Source node has 0 inputs"); @@ -44,15 +94,8 @@ addLoadEvent(function() { is(destination.numberOfInputs, 1, "Destination node has 0 inputs"); is(destination.numberOfOutputs, 0, "Destination node has 0 outputs"); - source.start(0); - SimpleTest.executeSoon(function() { - source.stop(0); - source.disconnect(); - - SpecialPowers.clearUserPref("media.webaudio.enabled"); - SimpleTest.finish(); - }); -}); + return source; +} diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 60f547ab9ad7..6d921ffb8153 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -110,7 +110,7 @@ DOMInterfaces = { }, 'AudioBufferSourceNode': { - 'implicitJSContext': [ 'start' ], + 'implicitJSContext': [ 'start', 'noteOn', 'noteGrainOn' ], 'resultNotAddRefed': [ 'playbackRate' ], 'wrapperCache': False }, diff --git a/dom/webidl/AudioBufferSourceNode.webidl b/dom/webidl/AudioBufferSourceNode.webidl index fc7aeb88eb4b..48f0c92e3b20 100644 --- a/dom/webidl/AudioBufferSourceNode.webidl +++ b/dom/webidl/AudioBufferSourceNode.webidl @@ -36,3 +36,21 @@ interface AudioBufferSourceNode : AudioNode { [Throws] void stop(optional double when = 0); }; + +/* + * The origin of this IDL file is + * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AlternateNames + */ +[PrefControlled] +partial interface AudioBufferSourceNode { + // Same as start() + [Throws] + void noteOn(double when); + [Throws] + void noteGrainOn(double when, double grainOffset, double grainDuration); + + [Throws] + // Same as stop() + void noteOff(double when); +}; + diff --git a/dom/webidl/AudioContext.webidl b/dom/webidl/AudioContext.webidl index 4e2655d14667..a24f7e723f86 100644 --- a/dom/webidl/AudioContext.webidl +++ b/dom/webidl/AudioContext.webidl @@ -51,3 +51,25 @@ interface AudioContext { }; +/* + * The origin of this IDL file is + * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AlternateNames + */ +[PrefControlled] +partial interface AudioContext { + // Same as createGain() + [Creator] + GainNode createGainNode(); + + // Same as createDelay() + [Creator, Throws] + DelayNode createDelayNode(optional double maxDelayTime = 1); + + // Same as createScriptProcessor() + // [Creator] + // ScriptProcessorNode createJavaScriptNode(unsigned long bufferSize, + // optional unsigned long numberOfInputChannels = 2, + // optional unsigned long numberOfOutputChannels = 2); +}; + + diff --git a/dom/webidl/AudioParam.webidl b/dom/webidl/AudioParam.webidl index 38376f592dbe..65ec049035a4 100644 --- a/dom/webidl/AudioParam.webidl +++ b/dom/webidl/AudioParam.webidl @@ -38,3 +38,14 @@ interface AudioParam { }; +/* + * The origin of this IDL file is + * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AlternateNames + */ +[PrefControlled] +partial interface AudioParam { + // Same as setTargetAtTime() + [Throws] + void setTargetValueAtTime(float target, double startTime, double timeConstant); +}; +