/* * Copyright (c) 2024, Shannon Booth * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::WebAudio { // https://webaudio.github.io/web-audio-api/#AudioNodeOptions struct AudioNodeOptions { Optional channel_count; Bindings::ChannelCountMode channel_count_mode; Bindings::ChannelInterpretation channel_interpretation; }; // https://webaudio.github.io/web-audio-api/#AudioNode class AudioNode : public DOM::EventTarget { WEB_PLATFORM_OBJECT(AudioNode, DOM::EventTarget); JS_DECLARE_ALLOCATOR(AudioNode); public: virtual ~AudioNode() override; WebIDL::ExceptionOr> connect(JS::NonnullGCPtr destination_node, WebIDL::UnsignedLong output = 0, WebIDL::UnsignedLong input = 0); void connect(JS::NonnullGCPtr destination_param, WebIDL::UnsignedLong output = 0); void disconnect(); void disconnect(WebIDL::UnsignedLong output); void disconnect(JS::NonnullGCPtr destination_node); void disconnect(JS::NonnullGCPtr destination_node, WebIDL::UnsignedLong output); void disconnect(JS::NonnullGCPtr destination_node, WebIDL::UnsignedLong output, WebIDL::UnsignedLong input); void disconnect(JS::NonnullGCPtr destination_param); void disconnect(JS::NonnullGCPtr destination_param, WebIDL::UnsignedLong output); // https://webaudio.github.io/web-audio-api/#dom-audionode-context JS::NonnullGCPtr context() const { // The BaseAudioContext which owns this AudioNode. return m_context; } WebIDL::UnsignedLong number_of_inputs(); WebIDL::UnsignedLong number_of_outputs(); WebIDL::ExceptionOr set_channel_count(WebIDL::UnsignedLong); WebIDL::UnsignedLong channel_count(); WebIDL::ExceptionOr set_channel_count_mode(Bindings::ChannelCountMode); Bindings::ChannelCountMode channel_count_mode(); WebIDL::ExceptionOr set_channel_interpretation(Bindings::ChannelInterpretation); Bindings::ChannelInterpretation channel_interpretation(); protected: AudioNode(JS::Realm&, JS::NonnullGCPtr); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: JS::NonnullGCPtr m_context; Bindings::ChannelCountMode m_channel_count_mode { Bindings::ChannelCountMode::Max }; Bindings::ChannelInterpretation m_channel_interpretation { Bindings::ChannelInterpretation::Speakers }; }; }