diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp b/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp index 39a3081b3be..59994aa216d 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp @@ -134,6 +134,17 @@ WebIDL::ExceptionOr> BaseAudioContext::create_panner() return PannerNode::create(realm(), *this); } +WebIDL::ExceptionOr> BaseAudioContext::create_periodic_wave(Vector const& real, Vector const& imag, Optional const& constraints) +{ + PeriodicWaveOptions options; + options.real = real; + options.imag = imag; + if (constraints.has_value()) + options.disable_normalization = constraints->disable_normalization; + + return PeriodicWave::construct_impl(realm(), *this, options); +} + // https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer WebIDL::ExceptionOr BaseAudioContext::verify_audio_options_inside_nominal_range(JS::Realm& realm, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate) { diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.h b/Libraries/LibWeb/WebAudio/BaseAudioContext.h index 144dd73a11f..ea50a48b77b 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.h +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.h @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace Web::WebAudio { @@ -67,6 +68,7 @@ public: WebIDL::ExceptionOr> create_dynamics_compressor(); WebIDL::ExceptionOr> create_gain(); WebIDL::ExceptionOr> create_panner(); + WebIDL::ExceptionOr> create_periodic_wave(Vector const& real, Vector const& imag, Optional const& constraints = {}); 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 cb28f5f53fc..668a9400443 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.idl +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.idl @@ -44,7 +44,7 @@ interface BaseAudioContext : EventTarget { [FIXME] IIRFilterNode createIIRFilter (sequence feedforward, sequence feedback); OscillatorNode createOscillator(); PannerNode createPanner(); - [FIXME] PeriodicWave createPeriodicWave (sequence real, sequence imag, optional PeriodicWaveConstraints constraints = {}); + 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 (); [FIXME] WaveShaperNode createWaveShaper (); diff --git a/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-periodicwave-interface/periodicWave.txt b/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-periodicwave-interface/periodicWave.txt new file mode 100644 index 00000000000..2ce571622c3 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/webaudio/the-audio-api/the-periodicwave-interface/periodicWave.txt @@ -0,0 +1,35 @@ +Harness status: OK + +Found 29 tests + +28 Pass +1 Fail +Pass # AUDIT TASK RUNNER STARTED. +Pass Executing "create with factory method" +Pass Executing "different length with factory method" +Pass Executing "too small with factory method" +Pass Executing "create with constructor" +Pass Executing "different length with constructor" +Pass Executing "too small with constructor" +Fail Executing "output test" +Pass Audit report +Pass > [create with factory method] +Pass context.createPeriodicWave(new Float32Array(8192), new Float32Array(8192)) did not throw an exception. +Pass < [create with factory method] All assertions passed. (total 1 assertions) +Pass > [different length with factory method] +Pass context.createPeriodicWave(new Float32Array(512), new Float32Array(4)) threw IndexSizeError: "Real and imaginary arrays must have the same length and contain at least 2 elements". +Pass < [different length with factory method] All assertions passed. (total 1 assertions) +Pass > [too small with factory method] +Pass context.createPeriodicWave(new Float32Array(1), new Float32Array(1)) threw IndexSizeError: "Real and imaginary arrays must have the same length and contain at least 2 elements". +Pass < [too small with factory method] All assertions passed. (total 1 assertions) +Pass > [create with constructor] +Pass new PeriodicWave(context, { real : new Float32Array(8192), imag : new Float32Array(8192) }) did not throw an exception. +Pass < [create with constructor] All assertions passed. (total 1 assertions) +Pass > [different length with constructor] +Pass new PeriodicWave(context, { real : new Float32Array(8192), imag : new Float32Array(4) }) threw IndexSizeError: "Real and imaginary arrays must have the same length and contain at least 2 elements". +Pass < [different length with constructor] All assertions passed. (total 1 assertions) +Pass > [too small with constructor] +Pass new PeriodicWave(context, { real : new Float32Array(1), imag : new Float32Array(1) }) threw IndexSizeError: "Real and imaginary arrays must have the same length and contain at least 2 elements". +Pass < [too small with constructor] All assertions passed. (total 1 assertions) +Pass > [output test] +Pass # AUDIT TASK RUNNER FINISHED: 7 tasks ran successfully. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/webaudio/the-audio-api/the-periodicwave-interface/periodicWave.html b/Tests/LibWeb/Text/input/wpt-import/webaudio/the-audio-api/the-periodicwave-interface/periodicWave.html new file mode 100644 index 00000000000..991c9b862f7 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/webaudio/the-audio-api/the-periodicwave-interface/periodicWave.html @@ -0,0 +1,130 @@ + + + + + Test Constructor: PeriodicWave + + + + + + + + + +