/src/serenity/Userland/Libraries/LibWeb/WebAudio/GainNode.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/Bindings/GainNodePrototype.h> |
10 | | #include <LibWeb/WebAudio/AudioNode.h> |
11 | | |
12 | | namespace Web::WebAudio { |
13 | | |
14 | | // https://webaudio.github.io/web-audio-api/#GainOptions |
15 | | struct GainOptions : AudioNodeOptions { |
16 | | float gain { 1.0 }; |
17 | | }; |
18 | | |
19 | | // https://webaudio.github.io/web-audio-api/#GainNode |
20 | | class GainNode : public AudioNode { |
21 | | WEB_PLATFORM_OBJECT(GainNode, AudioNode); |
22 | | JS_DECLARE_ALLOCATOR(GainNode); |
23 | | |
24 | | public: |
25 | | virtual ~GainNode() override; |
26 | | |
27 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> create(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {}); |
28 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> construct_impl(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {}); |
29 | | |
30 | 0 | WebIDL::UnsignedLong number_of_inputs() override { return 1; } |
31 | 0 | WebIDL::UnsignedLong number_of_outputs() override { return 1; } |
32 | | |
33 | 0 | JS::NonnullGCPtr<AudioParam const> gain() const { return m_gain; } |
34 | | |
35 | | protected: |
36 | | GainNode(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {}); |
37 | | |
38 | | virtual void initialize(JS::Realm&) override; |
39 | | virtual void visit_edges(Cell::Visitor&) override; |
40 | | |
41 | | private: |
42 | | // https://webaudio.github.io/web-audio-api/#dom-gainnode-gain |
43 | | JS::NonnullGCPtr<AudioParam> m_gain; |
44 | | }; |
45 | | |
46 | | } |