-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Add stub IDL interface for OscillatorNode
This source node generates a periodic wave form.
- Loading branch information
1 parent
adb2eed
commit 1f54b0c
Showing
6 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/Bindings/OscillatorNodePrototype.h> | ||
#include <LibWeb/WebAudio/OscillatorNode.h> | ||
|
||
namespace Web::WebAudio { | ||
|
||
OscillatorNode::~OscillatorNode() = default; | ||
|
||
WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> OscillatorNode::create(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, OscillatorOptions const& options) | ||
{ | ||
return construct_impl(realm, context, options); | ||
} | ||
|
||
// https://webaudio.github.io/web-audio-api/#dom-oscillatornode-oscillatornode | ||
WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> OscillatorNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext>, OscillatorOptions const&) | ||
{ | ||
return WebIDL::NotSupportedError::create(realm, "FIXME: Implement OscillatorNode::construct_impl"_fly_string); | ||
} | ||
|
||
void OscillatorNode::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(OscillatorNode); | ||
} | ||
|
||
void OscillatorNode::visit_edges(Cell::Visitor& visitor) | ||
{ | ||
Base::visit_edges(visitor); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibWeb/Bindings/OscillatorNodePrototype.h> | ||
#include <LibWeb/WebAudio/AudioScheduledSourceNode.h> | ||
|
||
namespace Web::WebAudio { | ||
|
||
// https://webaudio.github.io/web-audio-api/#OscillatorOptions | ||
struct OscillatorOptions : AudioNodeOptions { | ||
Bindings::OscillatorType type { Bindings::OscillatorType::Sine }; | ||
float frequency { 440 }; | ||
float detune { 0 }; | ||
JS::GCPtr<PeriodicWave> periodic_wave; | ||
}; | ||
|
||
// https://webaudio.github.io/web-audio-api/#OscillatorNode | ||
class OscillatorNode : public AudioScheduledSourceNode { | ||
WEB_PLATFORM_OBJECT(OscillatorNode, AudioScheduledSourceNode); | ||
JS_DECLARE_ALLOCATOR(OscillatorNode); | ||
|
||
public: | ||
virtual ~OscillatorNode() override; | ||
|
||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> create(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, OscillatorOptions const& = {}); | ||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> construct_impl(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, OscillatorOptions const& = {}); | ||
|
||
protected: | ||
virtual void initialize(JS::Realm&) override; | ||
virtual void visit_edges(Cell::Visitor&) override; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#import <WebAudio/AudioScheduledSourceNode.idl> | ||
#import <WebAudio/PeriodicWave.idl> | ||
|
||
// https://webaudio.github.io/web-audio-api/#enumdef-oscillatortype | ||
enum OscillatorType { | ||
"sine", | ||
"square", | ||
"sawtooth", | ||
"triangle", | ||
"custom" | ||
}; | ||
|
||
// https://webaudio.github.io/web-audio-api/#OscillatorOptions | ||
dictionary OscillatorOptions : AudioNodeOptions { | ||
OscillatorType type = "sine"; | ||
float frequency = 440; | ||
float detune = 0; | ||
PeriodicWave periodicWave; | ||
}; | ||
|
||
// https://webaudio.github.io/web-audio-api/#OscillatorNode | ||
[Exposed=Window] | ||
interface OscillatorNode : AudioScheduledSourceNode { | ||
constructor (BaseAudioContext context, optional OscillatorOptions options = {}); | ||
// FIXME: attribute OscillatorType type; | ||
// FIXME: readonly attribute AudioParam frequency; | ||
// FIXME: readonly attribute AudioParam detune; | ||
// FIXME: undefined setPeriodicWave(PeriodicWave periodicWave); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters