Class AudioWorkletGlobalScope
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The AudioWorkletGlobalScope interface of the Web Audio API represents a global execution context for user-supplied code, which defines custom AudioWorkletProcessor-derived classes.
[Value("AudioWorkletGlobalScope")]
public class AudioWorkletGlobalScope : WorkletGlobalScope
- Inheritance
-
AudioWorkletGlobalScope
- Inherited Members
Remarks
Each BaseAudioContext has a single AudioWorklet available under the AudioWorklet property, which runs its code in a single AudioWorkletGlobalScope.
As the global execution context is shared across the current BaseAudioContext, it's possible to define any other variables and perform any actions allowed in worklets — apart from defining AudioWorkletProcessor derived classes.
Constructors
AudioWorkletGlobalScope()
public AudioWorkletGlobalScope()
Properties
CurrentFrame
The read-only currentFrame property of the AudioWorkletGlobalScope interface returns an integer that represents the ever-increasing current sample-frame of the audio block being processed. It is incremented by 128 (the size of a render quantum) after the processing of each audio block.
[Value("currentFrame")]
public ulong CurrentFrame { get; }
Property Value
- ulong
An integer number.
Remarks
CurrentTime
The read-only currentTime property of the AudioWorkletGlobalScope interface returns a double that represents the ever-increasing context time of the audio block being processed. It is equal to the CurrentTime property of the BaseAudioContext the worklet belongs to.
[Value("currentTime")]
public Number CurrentTime { get; }
Property Value
- Number
A floating-point number representing the time.
Remarks
Port
NOTE
Experimentalport read-only property of the AudioWorkletGlobalScope interface returns a MessagePort object that can be used to send and receive messages between the main thread and the associated AudioWorklet.
[Value("port")]
public MessagePort Port { get; }
Property Value
- MessagePort
The MessagePort object that is connecting the
AudioWorkletand its associatedAudioWorkletGlobalScope.
Remarks
This allows for custom, asynchronous communication between code in the main thread and the global scope of an audio worklet, such as sending control data or global settings.
RenderQuantumSize
[Value("renderQuantumSize")]
public ulong RenderQuantumSize { get; }
Property Value
SampleRate
The read-only sampleRate property of the AudioWorkletGlobalScope interface returns a float that represents the sample rate of the associated BaseAudioContext the worklet belongs to.
[Value("sampleRate")]
public Number SampleRate { get; }
Property Value
- Number
A floating-point number representing the associated sample rate.
Remarks
Methods
RegisterProcessor(string, AudioWorkletProcessorConstructor)
The registerProcessor method of the
AudioWorkletGlobalScope interface registers a class constructor derived
from AudioWorkletProcessor interface under a specified name.
[Value("registerProcessor")]
public GlobalObject.Undefined RegisterProcessor(string name, AudioWorkletProcessorConstructor processorCtor)
Parameters
namestringprocessorCtorAudioWorkletProcessorConstructor