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.

Constructors

Properties

Methods

Constructors

  • Internal

    Creates an instance of FrameBufferSegment. This constructor is intended for internal use only, and instances are generated by the library.

    Parameters

    • buffer: Float32Array

      The shared Float32Array buffer containing audio samples.

    • channelCount: number

      The number of channels per frame.

    • frameNumber: number

      The starting frame index within the buffer.

    • frameCount: number

      The number of frames included in this segment.

    Returns FrameBufferSegment

Properties

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.

Methods

  • 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.