taglib-ts
    Preparing search index...

    AIFF / AIFC file handler.

    AIFF is a big-endian RIFF-like container ("FORM" / "AIFF" or "AIFC"):

    • "COMM" – common audio properties
    • "SSND" – sound data
    • "ID3 " / "id3 " – ID3v2 tag

    Hierarchy (View Summary)

    Index

    Properties

    _bigEndian: boolean

    Whether multi-byte integers in this container are big-endian (true for AIFF/FORM, false for WAV/RIFF).

    _stream: IOStream

    The underlying I/O stream.

    _valid: boolean = true

    Whether the file was parsed successfully. Subclasses set this to false when a fatal parse error is encountered.

    Accessors

    • get chunkCount(): number

      Total number of top-level chunks found in the file.

      Returns number

      The chunk count.

    • get hasId3v2Tag(): boolean

      Whether the file contained an ID3v2 chunk when it was opened.

      Returns boolean

      true if an "ID3 " chunk was found during parsing.

    • get isOpen(): boolean

      Whether the underlying stream is currently open. Synchronous.

      Returns boolean

    • get isValid(): boolean

      Whether this file was parsed successfully.

      Returns boolean

    • get name(): string

      The name (path) of the underlying stream, as reported by the stream itself. Synchronous.

      Returns string

    • get readOnly(): boolean

      Whether the underlying stream is read-only. Synchronous.

      Returns boolean

    • get riffFormat(): string

      The format identifier from the file header (e.g. "WAVE", "AIFF", "AIFC").

      Returns string

    Methods

    • Returns the data size (in bytes) of the chunk at the given index.

      Parameters

      • index: number

        Zero-based chunk index.

      Returns number

      Chunk data size in bytes.

    • Returns the four-character identifier of the chunk at the given index.

      Parameters

      • index: number

        Zero-based chunk index.

      Returns string

      The chunk name (e.g. "fmt ", "data").

    • Returns the byte offset of the chunk data (past the 8-byte header) at the given index.

      Parameters

      • index: number

        Zero-based chunk index.

      Returns number

      Byte offset within the file.

    • Returns the number of pad bytes (0 or 1) appended to the chunk at the given index.

      Parameters

      • index: number

        Zero-based chunk index.

      Returns number

      Padding byte count.

    • Resets the stream position to the beginning (equivalent to seek(0, Position.Beginning)).

      Returns Promise<void>

      A promise that resolves when the operation is complete.

    • Returns the list of complex-property keys supported by the tag.

      Returns string[]

      An array of key strings (e.g. "PICTURE").

    • Returns the total length of the stream in bytes.

      Note: this is an async method rather than a getter because getters cannot be async.

      Returns Promise<number>

      A promise resolving to the stream length in bytes.

    • Searches the stream forward for pattern starting at fromOffset.

      The stream cursor is restored to its original position after the search. If before is provided, the search stops (returning -1) as soon as before is encountered.

      Parameters

      • pattern: ByteVector

        The byte sequence to search for.

      • fromOffset: number = 0

        Byte offset at which to start searching. Defaults to 0.

      • Optionalbefore: ByteVector

        Optional sentinel; if found before pattern, returns -1.

      Returns Promise<number>

      A promise resolving to the byte offset of the first match, or -1 if not found.

    • Inserts data into the stream at start, optionally replacing replace bytes.

      Parameters

      • data: ByteVector

        The bytes to insert.

      • start: number = 0

        Byte offset at which to insert. Defaults to 0.

      • replace: number = 0

        Number of bytes to overwrite. Defaults to 0.

      Returns Promise<void>

      A promise that resolves when the operation is complete.

    • Reads the RIFF/FORM file header and populates the internal chunk list. Sets _valid to false if the file header is missing or unrecognised.

      Returns Promise<void>

    • Reads up to length bytes from the current stream position.

      Parameters

      • length: number

        The maximum number of bytes to read.

      Returns Promise<ByteVector>

      A promise resolving to the bytes read as a ByteVector.

    • Remove ALL chunks matching name from both the file and the in-memory chunk list. Matches C++ RIFF::File::removeChunk(const ByteVector &name) which removes all occurrences.

      Parameters

      • name: string

        Four-character chunk identifier to remove.

      Returns Promise<void>

    • Removes length bytes from the stream starting at start.

      Parameters

      • start: number = 0

        Byte offset of the first byte to remove. Defaults to 0.

      • length: number = 0

        Number of bytes to remove. Defaults to 0.

      Returns Promise<void>

      A promise that resolves when the operation is complete.

    • Remove the first chunk matching name from both the file and the in-memory chunk list.

      Parameters

      • name: string

        Four-character chunk identifier to remove.

      Returns Promise<void>

    • Removes unsupported properties from the tag.

      Parameters

      • properties: string[]

        The list of property keys to remove.

      Returns void

    • Searches the stream backward for pattern, starting at fromOffset (default: end of file).

      The stream cursor is restored to its original position after the search. If before is provided, the search stops (returning -1) as soon as before is encountered while scanning backward.

      Parameters

      • pattern: ByteVector

        The byte sequence to search for.

      • fromOffset: number = 0

        Upper bound for the search. 0 means end of file. Defaults to 0.

      • Optionalbefore: ByteVector

        Optional sentinel; if found before pattern, returns -1.

      Returns Promise<number>

      A promise resolving to the byte offset of the match, or -1 if not found.

    • Writes all pending tag changes back to the underlying stream. Matches C++ behavior: always removes all existing ID3 chunks first, then re-appends a fresh "ID3 " chunk if the tag is non-empty.

      Parameters

      • Optionalversion: number

        Optional ID3v2 version to save as.

      Returns Promise<boolean>

      true on success, false if the file is read-only.

    • Moves the stream's read/write cursor to offset relative to position.

      Parameters

      • offset: number

        The byte offset to seek to.

      • position: Position = Position.Beginning

        The seek origin. Defaults to Position.Beginning.

      Returns Promise<void>

      A promise that resolves when the seek is complete.

    • Set (or add) a chunk with the given four-character name. If overwrite is true (default) and a chunk with the same name already exists, its data is replaced in-place; otherwise a new chunk is appended.

      Parameters

      • name: string

        Four-character chunk identifier.

      • data: ByteVector

        Raw data bytes to store in the chunk.

      • overwrite: boolean = true

        When true, replace an existing chunk with the same name.

      Returns Promise<void>

    • Sets complex property values for the given key.

      Parameters

      Returns boolean

      true if the property was set, false if not supported.

    • Returns the current byte offset of the stream cursor.

      Returns Promise<number>

      A promise resolving to the cursor position.

    • Truncates (or extends) the stream to exactly length bytes.

      Parameters

      • length: number

        The desired stream length in bytes.

      Returns Promise<void>

      A promise that resolves when the truncation is complete.

    • Writes data at the current stream position.

      Parameters

      Returns Promise<void>

      A promise that resolves when the write is complete.

    • Open and parse an AIFF file from the given stream.

      Parameters

      • stream: IOStream

        The I/O stream to read from.

      • readProperties: boolean = true

        Whether to parse audio properties. Defaults to true.

      • OptionalreadStyle: ReadStyle

        Level of detail for audio property parsing.

      Returns Promise<AiffFile>

      A fully initialised AiffFile instance.