ladybird/Userland/Libraries/LibWeb/WebAudio/GainNode.h
Shannon Booth 1fa7235fec LibWeb: Add Implement GainNode interface
As with all other current audio nodes we still need to wire up the
inputs and outputs so it can be properly used in an audio context - but
this is enough to implement the public IDL interface.
2024-05-28 08:06:09 +02:00

44 lines
1.2 KiB
C++

/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/GainNodePrototype.h>
#include <LibWeb/WebAudio/AudioScheduledSourceNode.h>
namespace Web::WebAudio {
// https://webaudio.github.io/web-audio-api/#GainOptions
struct GainOptions : AudioNodeOptions {
float gain { 1.0 };
};
// https://webaudio.github.io/web-audio-api/#GainNode
class GainNode : public AudioNode {
WEB_PLATFORM_OBJECT(GainNode, AudioNode);
JS_DECLARE_ALLOCATOR(GainNode);
public:
virtual ~GainNode() override;
static JS::NonnullGCPtr<GainNode> create(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
static JS::NonnullGCPtr<GainNode> construct_impl(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
JS::NonnullGCPtr<AudioParam const> gain() const { return m_gain; }
protected:
GainNode(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
// https://webaudio.github.io/web-audio-api/#dom-gainnode-gain
JS::NonnullGCPtr<AudioParam> m_gain;
};
}