mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 08:11:13 +00:00
LibWeb: Implement BaseAudioContext.createGain
This commit is contained in:
parent
1fa7235fec
commit
6466fca20a
Notes:
sideshowbarker
2024-07-17 07:08:37 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/6466fca20a Pull-request: https://github.com/SerenityOS/serenity/pull/24471
5
Tests/LibWeb/Text/expected/WebAudio/GainNode.txt
Normal file
5
Tests/LibWeb/Text/expected/WebAudio/GainNode.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
GainNode
|
||||
AudioNode
|
||||
EventTarget
|
||||
Object
|
||||
[object AudioParam] current: 1, default: 1, min: -3.4028234663852886e+38, max: 3.4028234663852886e+38, rate: a-rate
|
23
Tests/LibWeb/Text/input/WebAudio/GainNode.html
Normal file
23
Tests/LibWeb/Text/input/WebAudio/GainNode.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
function dumpAudioParam(param) {
|
||||
println(`${param} current: ${param.value}, default: ${param.defaultValue}, min: ${param.minValue}, max: ${param.maxValue}, rate: ${param.automationRate}`);
|
||||
}
|
||||
|
||||
test(() => {
|
||||
const audioContext = new OfflineAudioContext(1, 5000, 44100);
|
||||
|
||||
const node = audioContext.createGain();
|
||||
|
||||
// Check prototype
|
||||
let prototype = Object.getPrototypeOf(node);
|
||||
|
||||
while (prototype) {
|
||||
println(prototype.constructor.name);
|
||||
prototype = Object.getPrototypeOf(prototype);
|
||||
}
|
||||
|
||||
// Audio Params
|
||||
dumpAudioParam(node.gain);
|
||||
});
|
||||
</script>
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibWeb/WebAudio/AudioBuffer.h>
|
||||
#include <LibWeb/WebAudio/BaseAudioContext.h>
|
||||
#include <LibWeb/WebAudio/DynamicsCompressorNode.h>
|
||||
#include <LibWeb/WebAudio/GainNode.h>
|
||||
#include <LibWeb/WebAudio/OscillatorNode.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
@ -61,6 +62,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> BaseAudioContext::
|
|||
return DynamicsCompressorNode::create(realm(), *this);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain
|
||||
JS::NonnullGCPtr<GainNode> BaseAudioContext::create_gain()
|
||||
{
|
||||
// Factory method for GainNode.
|
||||
return GainNode::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)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioBuffer>> create_buffer(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();
|
||||
JS::NonnullGCPtr<GainNode> create_gain();
|
||||
|
||||
protected:
|
||||
explicit BaseAudioContext(JS::Realm&, float m_sample_rate = 0);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#import <DOM/EventHandler.idl>
|
||||
#import <WebAudio/AudioBuffer.idl>
|
||||
#import <WebAudio/DynamicsCompressorNode.idl>
|
||||
#import <WebAudio/GainNode.idl>
|
||||
#import <WebAudio/OscillatorNode.idl>
|
||||
|
||||
// https://www.w3.org/TR/webaudio/#enumdef-audiocontextstate
|
||||
|
@ -33,7 +34,7 @@ interface BaseAudioContext : EventTarget {
|
|||
[FIXME] ConvolverNode createConvolver ();
|
||||
[FIXME] DelayNode createDelay (optional double maxDelayTime = 1.0);
|
||||
DynamicsCompressorNode createDynamicsCompressor();
|
||||
[FIXME] GainNode createGain ();
|
||||
GainNode createGain();
|
||||
[FIXME] IIRFilterNode createIIRFilter (sequence<double> feedforward, sequence<double> feedback);
|
||||
OscillatorNode createOscillator();
|
||||
[FIXME] PannerNode createPanner ();
|
||||
|
|
Loading…
Reference in a new issue