diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp b/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp index d343550c7f2..f4606ed4dec 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp @@ -160,6 +160,13 @@ WebIDL::ExceptionOr> BaseAudioContext::create_periodic_wav return PeriodicWave::construct_impl(realm(), *this, options); } +// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createstereopanner +WebIDL::ExceptionOr> BaseAudioContext::create_stereo_panner() +{ + // Factory method for a StereoPannerNode. + return StereoPannerNode::create(realm(), *this); +} + WebIDL::ExceptionOr BaseAudioContext::verify_audio_options_inside_nominal_range(JS::Realm& realm, float sample_rate) { if (sample_rate < MIN_SAMPLE_RATE || sample_rate > MAX_SAMPLE_RATE) diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.h b/Libraries/LibWeb/WebAudio/BaseAudioContext.h index 93f77e8c83c..30922e9e1c5 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.h +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.h @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace Web::WebAudio { @@ -74,6 +75,7 @@ public: WebIDL::ExceptionOr> create_gain(); WebIDL::ExceptionOr> create_panner(); WebIDL::ExceptionOr> create_periodic_wave(Vector const& real, Vector const& imag, Optional const& constraints = {}); + WebIDL::ExceptionOr> create_stereo_panner(); GC::Ref decode_audio_data(GC::Root, GC::Ptr, GC::Ptr); diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.idl b/Libraries/LibWeb/WebAudio/BaseAudioContext.idl index 7e39ce0a766..7aadb6dff56 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.idl +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.idl @@ -46,7 +46,7 @@ interface BaseAudioContext : EventTarget { PannerNode createPanner(); PeriodicWave createPeriodicWave (sequence real, sequence imag, optional PeriodicWaveConstraints constraints = {}); [FIXME] ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2); - [FIXME] StereoPannerNode createStereoPanner (); + StereoPannerNode createStereoPanner (); [FIXME] WaveShaperNode createWaveShaper (); Promise decodeAudioData (ArrayBuffer audioData, optional DecodeSuccessCallback? successCallback, optional DecodeErrorCallback? errorCallback); diff --git a/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-audioparam-interface/audioparam-nominal-range.txt b/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-audioparam-interface/audioparam-nominal-range.txt index 4e04a3c942f..13dd52c3f5a 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-audioparam-interface/audioparam-nominal-range.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-audioparam-interface/audioparam-nominal-range.txt @@ -1,15 +1,15 @@ Harness status: OK -Found 306 tests +Found 317 tests -297 Pass -9 Fail +309 Pass +8 Fail Pass # AUDIT TASK RUNNER STARTED. Pass Executing "initialize" Pass Executing "Offline createGain" Pass Executing "Offline createDelay" Pass Executing "Offline createBufferSource" -Fail Executing "Offline createStereoPanner" +Pass Executing "Offline createStereoPanner" Pass Executing "Offline createDynamicsCompressor" Pass Executing "Offline createBiquadFilter" Pass Executing "Offline createOscillator" @@ -71,6 +71,17 @@ Pass AudioBufferSourceNode.detune.maxValue is read-only is equal to true. Pass Nominal ranges for AudioParam(s) of AudioBufferSourceNode are correct Pass < [Offline createBufferSource] All assertions passed. (total 13 assertions) Pass > [Offline createStereoPanner] +Pass StereoPannerNode.pan.minValue is equal to -1. +Pass StereoPannerNode.pan.maxValue is equal to 1. +Pass StereoPannerNode.pan.minValue = 42 is not equal to 42. +Pass StereoPannerNode.pan.minValue is read-only is equal to true. +Pass StereoPannerNode.pan.maxValue = 42 is not equal to 42. +Pass StereoPannerNode.pan.maxValue is read-only is equal to true. +Pass Set StereoPannerNode.pan.value = -3 is equal to -1. +Pass Set StereoPannerNode.pan.value = 3 is equal to 1. +Pass StereoPannerNode.pan was clipped to lie within the nominal range is equal to true. +Pass Nominal ranges for AudioParam(s) of StereoPannerNode are correct +Pass < [Offline createStereoPanner] All assertions passed. (total 10 assertions) Pass > [Offline createDynamicsCompressor] Pass DynamicsCompressorNode.threshold.minValue is equal to -100. Pass DynamicsCompressorNode.threshold.maxValue is equal to 0. diff --git a/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-stereopanner-interface/stereopannernode-basic.txt b/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-stereopanner-interface/stereopannernode-basic.txt new file mode 100644 index 00000000000..f5513c432d9 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-stereopanner-interface/stereopannernode-basic.txt @@ -0,0 +1,20 @@ +Harness status: OK + +Found 15 tests + +15 Pass +Pass # AUDIT TASK RUNNER STARTED. +Pass Executing "test" +Pass Audit report +Pass > [test] Attributes and basic functionality of StereoPannerNode +Pass panner.numberOfInputs is equal to 1. +Pass panner.numberOfOutputs is equal to 1. +Pass panner.pan.defaultValue is equal to 0. +Pass panner.pan.value = 1.0 did not throw an exception. +Pass panner.pan.value is equal to 1. +Pass panner.channelCount = 1 did not throw an exception. +Pass panner.channelCount = 3 threw NotSupportedError: "StereoPannerNode does not support channel count greater than 2". +Pass panner.channelCountMode = "explicit" did not throw an exception. +Pass panner.channelCountMode = "max" threw NotSupportedError: "StereoPannerNode does not support 'max' as channelCountMode.". +Pass < [test] All assertions passed. (total 9 assertions) +Pass # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/webaudio/the-audio-api/the-stereopanner-interface/stereopannernode-basic.html b/Tests/LibWeb/Text/input/wpt-import/webaudio/the-audio-api/the-stereopanner-interface/stereopannernode-basic.html new file mode 100644 index 00000000000..c0b10c9aea1 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/webaudio/the-audio-api/the-stereopanner-interface/stereopannernode-basic.html @@ -0,0 +1,54 @@ + + + + + stereopannernode-basic.html + + + + + + + + + +