From 452ffa56dc431266ee6b46c4d1991ea0518154c2 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 5 May 2024 11:18:02 +1200 Subject: [PATCH] LibWeb: Implement BaseAudioContext.createDynamicsCompressor --- .../expected/WebAudio/DynamicsCompressorNode.txt | 4 ++++ .../input/WebAudio/DynamicsCompressorNode.html | 16 ++++++++++++++++ .../LibWeb/WebAudio/BaseAudioContext.cpp | 8 ++++++++ .../Libraries/LibWeb/WebAudio/BaseAudioContext.h | 1 + .../LibWeb/WebAudio/BaseAudioContext.idl | 3 ++- 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/WebAudio/DynamicsCompressorNode.txt create mode 100644 Tests/LibWeb/Text/input/WebAudio/DynamicsCompressorNode.html diff --git a/Tests/LibWeb/Text/expected/WebAudio/DynamicsCompressorNode.txt b/Tests/LibWeb/Text/expected/WebAudio/DynamicsCompressorNode.txt new file mode 100644 index 00000000000..72ad4f051c3 --- /dev/null +++ b/Tests/LibWeb/Text/expected/WebAudio/DynamicsCompressorNode.txt @@ -0,0 +1,4 @@ +DynamicsCompressorNode +AudioNode +EventTarget +Object diff --git a/Tests/LibWeb/Text/input/WebAudio/DynamicsCompressorNode.html b/Tests/LibWeb/Text/input/WebAudio/DynamicsCompressorNode.html new file mode 100644 index 00000000000..2b3385e0612 --- /dev/null +++ b/Tests/LibWeb/Text/input/WebAudio/DynamicsCompressorNode.html @@ -0,0 +1,16 @@ + + diff --git a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp index 8b3cae4f6d0..60b01e66487 100644 --- a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp +++ b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace Web::WebAudio { @@ -44,6 +45,13 @@ WebIDL::ExceptionOr> BaseAudioContext::create_o return OscillatorNode::create(realm(), *this); } +// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createdynamicscompressor +WebIDL::ExceptionOr> BaseAudioContext::create_dynamics_compressor() +{ + // Factory method for a DynamicsCompressorNode. + return DynamicsCompressorNode::create(realm(), *this); +} + // 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/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h index fab80d0c9ca..8fd395a75c7 100644 --- a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h +++ b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h @@ -48,6 +48,7 @@ public: static WebIDL::ExceptionOr verify_audio_options_inside_nominal_range(JS::Realm&, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate); WebIDL::ExceptionOr> create_oscillator(); + WebIDL::ExceptionOr> create_dynamics_compressor(); protected: explicit BaseAudioContext(JS::Realm&, float m_sample_rate = 0); diff --git a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl index 22929aa13dc..a52ac7b5c7e 100644 --- a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl +++ b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl @@ -1,5 +1,6 @@ #import #import +#import #import // https://www.w3.org/TR/webaudio/#enumdef-audiocontextstate @@ -30,7 +31,7 @@ interface BaseAudioContext : EventTarget { // FIXME: ConstantSourceNode createConstantSource (); // FIXME: ConvolverNode createConvolver (); // FIXME: DelayNode createDelay (optional double maxDelayTime = 1.0); - // FIXME: DynamicsCompressorNode createDynamicsCompressor (); + DynamicsCompressorNode createDynamicsCompressor(); // FIXME: GainNode createGain (); // FIXME: IIRFilterNode createIIRFilter (sequence feedforward, sequence feedback); OscillatorNode createOscillator();