@ain1084/audio-worklet-stream - v2.0.2
    Preparing search index...

    Interface OutputStreamNode

    OutputStreamNode class This class extends AudioWorkletNode to handle audio processing. It manages a buffer using a FrameBufferWriter instance and tracks the current frame position.

    interface OutputStreamNode {
        channelCount: number;
        channelCountMode: ChannelCountMode;
        channelInterpretation: ChannelInterpretation;
        context: BaseAudioContext;
        numberOfInputs: number;
        numberOfOutputs: number;
        onprocessorerror: ((this: AudioWorkletNode, ev: ErrorEvent) => any) | null;
        parameters: AudioParamMap;
        port: MessagePort;
        get isStart(): boolean;
        get totalReadFrames(): bigint;
        get totalWriteFrames(): bigint;
        addEventListener<K extends keyof AudioWorkletNodeEventMap>(
            type: K,
            listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any,
            options?: boolean | AddEventListenerOptions,
        ): void;
        addEventListener(
            type: string,
            listener: EventListenerOrEventListenerObject,
            options?: boolean | AddEventListenerOptions,
        ): void;
        connect(
            destinationNode: AudioNode,
            output?: number,
            input?: number,
        ): AudioNode;
        connect(destinationParam: AudioParam, output?: number): void;
        disconnect(): void;
        disconnect(output: number): void;
        disconnect(destinationNode: AudioNode): void;
        disconnect(destinationNode: AudioNode, output: number): void;
        disconnect(destinationNode: AudioNode, output: number, input: number): void;
        disconnect(destinationParam: AudioParam): void;
        disconnect(destinationParam: AudioParam, output: number): void;
        dispatchEvent(event: Event): boolean;
        dispatchEvent(event: Event): boolean;
        removeEventListener<K extends keyof AudioWorkletNodeEventMap>(
            type: K,
            listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any,
            options?: boolean | EventListenerOptions,
        ): void;
        removeEventListener(
            type: string,
            listener: EventListenerOrEventListenerObject,
            options?: boolean | EventListenerOptions,
        ): void;
        start(): boolean;
        stop(framePosition?: bigint): Promise<void>;
    }

    Hierarchy

    • AudioWorkletNode
      • OutputStreamNode
    Index

    Properties

    channelCount: number

    The channelCount property of the AudioNode interface represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to any inputs to the node.

    MDN Reference

    channelCountMode: ChannelCountMode

    The channelCountMode property of the AudioNode interface represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.

    MDN Reference

    channelInterpretation: ChannelInterpretation

    The channelInterpretation property of the AudioNode interface represents an enumerated value describing how input channels are mapped to output channels when the number of inputs/outputs is different.

    MDN Reference

    context: BaseAudioContext

    The read-only context property of the the node is participating in.

    MDN Reference

    numberOfInputs: number

    The numberOfInputs property of the AudioNode interface returns the number of inputs feeding the node.

    MDN Reference

    numberOfOutputs: number

    The numberOfOutputs property of the AudioNode interface returns the number of outputs coming out of the node.

    MDN Reference

    onprocessorerror: ((this: AudioWorkletNode, ev: ErrorEvent) => any) | null
    parameters: AudioParamMap

    The read-only parameters property of the underlying AudioWorkletProcessor according to its getter.

    MDN Reference

    port: MessagePort

    The read-only port property of the associated AudioWorkletProcessor.

    MDN Reference

    Accessors

    • get isStart(): boolean

      Checks if playback has started.

      Returns boolean

      A boolean indicating if playback has started.

    • get totalReadFrames(): bigint

      Get the current frame position since the start of playback. The position is in frames and increases by 1 for each frame. It represents the total number of frames processed by the AudioWorkletProcessor.

      • AudioWorkletProcessor has read this total number of frames from the buffer. It closely indicates the playback position in frames.
      • totalReadFrames will never exceed the number of frames written to the buffer, ensuring it is always less than or equal to totalWriteFrames.
      • The difference between totalWriteFrames and totalReadFrames represents the delay in samples before playback (excluding processing beyond the AudioNode).

      Returns bigint

      The current frame position as a bigint.

    • get totalWriteFrames(): bigint

      Get the total number of frames written to the buffer. This reflects the total frames written by the BufferWriteStrategy. Note: The method of writing to the buffer is implemented by the BufferWriteStrategy. The OutputStreamNode itself does not modify this value.

      Returns bigint

      The total number of frames written as a bigint.

    Methods

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Type Parameters

      • K extends keyof AudioWorkletNodeEventMap

      Parameters

      • type: K
      • listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • listener: EventListenerOrEventListenerObject
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The connect() method of the AudioNode interface lets you connect one of the node's outputs to a target, which may be either another AudioNode (thereby directing the sound data to the specified node) or an change the value of that parameter over time.

      MDN Reference

      Parameters

      • destinationNode: AudioNode
      • Optionaloutput: number
      • Optionalinput: number

      Returns AudioNode

    • Parameters

      • destinationParam: AudioParam
      • Optionaloutput: number

      Returns void

    • The disconnect() method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.

      MDN Reference

      Returns void

    • Parameters

      • output: number

      Returns void

    • Parameters

      • destinationNode: AudioNode

      Returns void

    • Parameters

      • destinationNode: AudioNode
      • output: number

      Returns void

    • Parameters

      • destinationNode: AudioNode
      • output: number
      • input: number

      Returns void

    • Parameters

      • destinationParam: AudioParam

      Returns void

    • Parameters

      • destinationParam: AudioParam
      • output: number

      Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Type Parameters

      • K extends keyof AudioWorkletNodeEventMap

      Parameters

      • type: K
      • listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Parameters

      • type: string
      • listener: EventListenerOrEventListenerObject
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Start playback. The node must be connected before starting playback using connect() method. Output samples must be written to the buffer before starting. Playback can only be started once. Once stopped, it cannot be restarted.

      Returns boolean

      A boolean indicating whether the playback started successfully.

    • Stop the node processing at a given frame position. Returns a Promise that resolves when the node has completely stopped. The node is disconnected once stopping is complete.

      Parameters

      • framePosition: bigint = ...

        The frame position at which to stop the processing, in frames. If framePosition is 0 or if the current playback frame position has already passed the specified value, the node will stop immediately.

      Returns Promise<void>

      A promise that resolves when the node has stopped.