mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibWeb: Add stub IDL interface for AudioNode
An AudioNode is the fundamental building block used in 'Audio Contexts'. In our immediate case, the audio node we are working towards implementing is an oscillating source node.
This commit is contained in:
parent
5ae0ac7b73
commit
6661c68b28
7 changed files with 195 additions and 0 deletions
|
@ -33,6 +33,7 @@ static bool is_platform_object(Type const& type)
|
|||
"AnimationEffect"sv,
|
||||
"AnimationTimeline"sv,
|
||||
"Attr"sv,
|
||||
"AudioNode"sv,
|
||||
"AudioParam"sv,
|
||||
"AudioTrack"sv,
|
||||
"BaseAudioContext"sv,
|
||||
|
|
|
@ -659,6 +659,7 @@ set(SOURCES
|
|||
WebAssembly/WebAssembly.cpp
|
||||
WebAudio/AudioBuffer.cpp
|
||||
WebAudio/AudioContext.cpp
|
||||
WebAudio/AudioNode.cpp
|
||||
WebAudio/AudioParam.cpp
|
||||
WebAudio/BaseAudioContext.cpp
|
||||
WebAudio/OfflineAudioContext.cpp
|
||||
|
|
|
@ -681,6 +681,7 @@ class Table;
|
|||
|
||||
namespace Web::WebAudio {
|
||||
class AudioContext;
|
||||
class AudioNode;
|
||||
class AudioParam;
|
||||
class BaseAudioContext;
|
||||
class OfflineAudioContext;
|
||||
|
|
96
Userland/Libraries/LibWeb/WebAudio/AudioNode.cpp
Normal file
96
Userland/Libraries/LibWeb/WebAudio/AudioNode.cpp
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/WebAudio/AudioNode.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AudioNode);
|
||||
|
||||
AudioNode::~AudioNode() = default;
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-connect
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> AudioNode::connect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output, WebIDL::UnsignedLong input)
|
||||
{
|
||||
(void)destination_node;
|
||||
(void)output;
|
||||
(void)input;
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioNode::connect (AudioNode)"_fly_string);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-connect-destinationparam-output
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> AudioNode::connect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output)
|
||||
{
|
||||
(void)destination_param;
|
||||
(void)output;
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioNode::connect (AudioParam)"_fly_string);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
void AudioNode::disconnect()
|
||||
{
|
||||
dbgln("FIXME: Implement AudioNode::disconnect()");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-output
|
||||
void AudioNode::disconnect(WebIDL::UnsignedLong output)
|
||||
{
|
||||
(void)output;
|
||||
dbgln("FIXME: Implement AudioNode::disconnect(output)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode
|
||||
void AudioNode::disconnect(JS::NonnullGCPtr<AudioNode> destination_node)
|
||||
{
|
||||
(void)destination_node;
|
||||
dbgln("FIXME: Implement AudioNode::disconnect(destination_node)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode-output
|
||||
void AudioNode::disconnect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output)
|
||||
{
|
||||
(void)destination_node;
|
||||
(void)output;
|
||||
dbgln("FIXME: Implement AudioNode::disconnect(destination_node, output)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode-output-input
|
||||
void AudioNode::disconnect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output, WebIDL::UnsignedLong input)
|
||||
{
|
||||
(void)destination_node;
|
||||
(void)output;
|
||||
(void)input;
|
||||
dbgln("FIXME: Implement AudioNode::disconnect(destination_node, output, input)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationparam
|
||||
void AudioNode::disconnect(JS::NonnullGCPtr<AudioParam> destination_param)
|
||||
{
|
||||
(void)destination_param;
|
||||
dbgln("FIXME: Implement AudioNode::disconnect(destination_param)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationparam-output
|
||||
void AudioNode::disconnect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output)
|
||||
{
|
||||
(void)destination_param;
|
||||
(void)output;
|
||||
dbgln("FIXME: Implement AudioNode::disconnect(destination_param, output)");
|
||||
}
|
||||
|
||||
void AudioNode::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(AudioNode);
|
||||
}
|
||||
|
||||
void AudioNode::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
}
|
||||
|
||||
}
|
49
Userland/Libraries/LibWeb/WebAudio/AudioNode.h
Normal file
49
Userland/Libraries/LibWeb/WebAudio/AudioNode.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/AudioNodePrototype.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
namespace Web::WebAudio {
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#AudioNodeOptions
|
||||
struct AudioNodeOptions {
|
||||
Optional<WebIDL::UnsignedLong> 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<JS::NonnullGCPtr<AudioNode>> connect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output = 0, WebIDL::UnsignedLong input = 0);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> connect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output = 0);
|
||||
|
||||
void disconnect();
|
||||
void disconnect(WebIDL::UnsignedLong output);
|
||||
void disconnect(JS::NonnullGCPtr<AudioNode> destination_node);
|
||||
void disconnect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output);
|
||||
void disconnect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output, WebIDL::UnsignedLong input);
|
||||
void disconnect(JS::NonnullGCPtr<AudioParam> destination_param);
|
||||
void disconnect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output);
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
};
|
||||
|
||||
}
|
46
Userland/Libraries/LibWeb/WebAudio/AudioNode.idl
Normal file
46
Userland/Libraries/LibWeb/WebAudio/AudioNode.idl
Normal file
|
@ -0,0 +1,46 @@
|
|||
#import <WebAudio/AudioParam.idl>
|
||||
#import <WebAudio/BaseAudioContext.idl>
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#enumdef-channelcountmode
|
||||
enum ChannelCountMode {
|
||||
"max",
|
||||
"clamped-max",
|
||||
"explicit"
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#enumdef-channelinterpretation
|
||||
enum ChannelInterpretation {
|
||||
"speakers",
|
||||
"discrete"
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#AudioNodeOptions
|
||||
dictionary AudioNodeOptions {
|
||||
unsigned long channelCount;
|
||||
ChannelCountMode channelCountMode;
|
||||
ChannelInterpretation channelInterpretation;
|
||||
};
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#AudioNode
|
||||
[Exposed=Window]
|
||||
interface AudioNode : EventTarget {
|
||||
AudioNode connect(AudioNode destinationNode,
|
||||
optional unsigned long output = 0,
|
||||
optional unsigned long input = 0);
|
||||
undefined connect(AudioParam destinationParam, optional unsigned long output = 0);
|
||||
undefined disconnect();
|
||||
undefined disconnect(unsigned long output);
|
||||
undefined disconnect(AudioNode destinationNode);
|
||||
undefined disconnect(AudioNode destinationNode, unsigned long output);
|
||||
undefined disconnect(AudioNode destinationNode,
|
||||
unsigned long output,
|
||||
unsigned long input);
|
||||
undefined disconnect(AudioParam destinationParam);
|
||||
undefined disconnect(AudioParam destinationParam, unsigned long output);
|
||||
// FIXME: readonly attribute BaseAudioContext context;
|
||||
// FIXME: readonly attribute unsigned long numberOfInputs;
|
||||
// FIXME: readonly attribute unsigned long numberOfOutputs;
|
||||
// FIXME: attribute unsigned long channelCount;
|
||||
// FIXME: attribute ChannelCountMode channelCountMode;
|
||||
// FIXME: attribute ChannelInterpretation channelInterpretation;
|
||||
};
|
|
@ -295,6 +295,7 @@ libweb_js_bindings(WebAssembly/Table)
|
|||
libweb_js_bindings(WebAssembly/WebAssembly NAMESPACE)
|
||||
libweb_js_bindings(WebAudio/AudioBuffer)
|
||||
libweb_js_bindings(WebAudio/AudioContext)
|
||||
libweb_js_bindings(WebAudio/AudioNode)
|
||||
libweb_js_bindings(WebAudio/AudioParam)
|
||||
libweb_js_bindings(WebAudio/BaseAudioContext)
|
||||
libweb_js_bindings(WebAudio/OfflineAudioContext)
|
||||
|
|
Loading…
Add table
Reference in a new issue