taglib-ts
    Preparing search index...

    Audio properties parsed from a WAV "fmt " chunk.

    fmt chunk layout (little-endian): format(2) + channels(2) + sampleRate(4) + avgBytesPerSec(4)

    • blockAlign(2) + bitsPerSample(2)

    For WAVE_FORMAT_EXTENSIBLE, the sub-format GUID occupies bytes 24–39, and bytes 24–25 contain the actual codec identifier.

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructs a WavProperties instance by parsing a "fmt " chunk. Matches the C++ calculation: uses exact floating-point arithmetic and Math.trunc(x + 0.5) rounding (equivalent to C++ static_cast<int>(x + 0.5)).

      Parameters

      • data: ByteVector

        Raw bytes of the "fmt " chunk (must be at least 16 bytes).

      • streamLength: number

        Byte length of the "data" chunk including chunk padding.

      • totalSamples: number = 0

        Sample frame count from the "fact" chunk (0 if absent).

      • readStyle: ReadStyle = ReadStyle.Average

        Level of detail for property parsing. Defaults to ReadStyle.Average.

      Returns WavProperties

    Properties

    _readStyle: ReadStyle

    The read style used when parsing the audio stream.

    Accessors

    • get bitrate(): number

      Average bitrate of the stream in kilobits per second.

      Returns number

      Bitrate in kbps, or 0 if unknown.

    • get bitsPerSample(): number

      Bits per sample (bit depth) of the audio stream.

      Returns number

      Bit depth (e.g. 16, 24, 32).

    • get channels(): number

      Number of audio channels.

      Returns number

      Channel count (e.g. 2 for stereo).

    • get format(): number

      Audio format tag from the "fmt " chunk. Common values: 1 = PCM, 3 = IEEE float, 6 = A-law, 7 = μ-law. For WAVE_FORMAT_EXTENSIBLE files, this is the sub-format tag.

      Returns number

      The format tag value.

    • get lengthInMilliseconds(): number

      Playback duration in milliseconds.

      Returns number

      Duration in milliseconds, or 0 if unknown.

    • get lengthInSeconds(): number

      Duration rounded to the nearest second.

      Returns number

    • get sampleFrames(): number

      Total number of PCM sample frames.

      Returns number

      Sample frame count, or 0 if unknown.

    • get sampleRate(): number

      Sample rate of the audio stream in Hz.

      Returns number

      Sample rate in Hz, or 0 if unknown.