@ain1084/audio-frame-buffer - v0.2.1
    Preparing search index...

    Interface FrameBufferSegment

    FrameBufferSegment class Represents a segment of audio frames within a shared Float32Array buffer, providing methods to access and modify individual samples in a frame-based structure across multiple channels.

    This class is used internally by the library to represent a specific range of frames within the shared buffer, allowing controlled access for reading or writing operations. Users do not create instances of this class directly; instead, instances are provided by the library when using the FrameBufferReader.read and FrameBufferWriter.write methods.

    interface FrameBufferSegment {
        channels: number;
        frameCount: number;
        samples: Float32Array;
        get(frame: number, channel: number): number;
        set(frame: number, channel: number, value: number): void;
    }
    Index
    channels: number

    The number of channels in each frame. This value defines how many samples make up a single frame.

    frameCount: number

    The number of frames in this segment. This determines the length of this segment in terms of frames, rather than samples.

    samples: Float32Array

    The Float32Array representing the sample data in the segment. Each frame consists of multiple samples (one for each channel).

    If the arrangement of samples within a frame is understood, direct access to samples is possible without using the get and set methods, by indexing based on frame * channels + channel.

    • Gets the sample value for a specific frame and channel.

      Parameters

      • frame: number

        The frame index within the segment (0 to frameCount - 1).

      • channel: number

        The channel index within the frame (0 to channels - 1).

      Returns number

      The sample value for the specified frame and channel.

      RangeError if the frame or channel index is out of bounds.

    • Sets the sample value for a specific frame and channel.

      Parameters

      • frame: number

        The frame index within the segment (0 to frameCount - 1).

      • channel: number

        The channel index within the frame (0 to channels - 1).

      • value: number

        The value to set for the specified frame and channel.

      Returns void

      RangeError if the frame or channel index is out of bounds.