LibWeb: Implement BaseAudioContext.createDynamicsCompressor

This commit is contained in:
Shannon Booth 2024-05-05 11:18:02 +12:00 committed by Tim Flynn
parent 2a56df8ecd
commit 452ffa56dc
Notes: sideshowbarker 2024-07-17 00:25:35 +09:00
5 changed files with 31 additions and 1 deletions

View File

@ -0,0 +1,4 @@
DynamicsCompressorNode
AudioNode
EventTarget
Object

View File

@ -0,0 +1,16 @@
<script src="../include.js"></script>
<script>
test(() => {
const audioContext = new OfflineAudioContext(1, 5000, 44100);
const compressor = audioContext.createDynamicsCompressor();
// Check prototype
let prototype = Object.getPrototypeOf(compressor);
while (prototype) {
println(prototype.constructor.name);
prototype = Object.getPrototypeOf(prototype);
}
});
</script>

View File

@ -9,6 +9,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/WebAudio/BaseAudioContext.h>
#include <LibWeb/WebAudio/DynamicsCompressorNode.h>
#include <LibWeb/WebAudio/OscillatorNode.h>
namespace Web::WebAudio {
@ -44,6 +45,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> BaseAudioContext::create_o
return OscillatorNode::create(realm(), *this);
}
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createdynamicscompressor
WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> 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<void> BaseAudioContext::verify_audio_options_inside_nominal_range(JS::Realm& realm, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate)
{

View File

@ -48,6 +48,7 @@ public:
static WebIDL::ExceptionOr<void> verify_audio_options_inside_nominal_range(JS::Realm&, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate);
WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> create_oscillator();
WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> create_dynamics_compressor();
protected:
explicit BaseAudioContext(JS::Realm&, float m_sample_rate = 0);

View File

@ -1,5 +1,6 @@
#import <DOM/EventTarget.idl>
#import <DOM/EventHandler.idl>
#import <WebAudio/DynamicsCompressorNode.idl>
#import <WebAudio/OscillatorNode.idl>
// 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<double> feedforward, sequence<double> feedback);
OscillatorNode createOscillator();