/** @packageDocumentation Abstract base class for RIFF/FORM container formats (WAV, AIFF). Handles chunk parsing and manipulation. */ import { ByteVector } from "../byteVector.js"; import { File } from "../file.js"; import type { offset_t } from "../toolkit/types.js"; import type { IOStream } from "../toolkit/ioStream.js"; /** * Abstract base for RIFF container formats (WAV uses little-endian "RIFF", * AIFF uses big-endian "FORM"). * * File layout: * fileId(4) + fileSize(4) + format(4) + chunks… * Each chunk: * chunkId(4) + chunkSize(4) + data (padded to even byte boundary) */ export declare abstract class RiffFile extends File { /** Whether multi-byte integers in this container are big-endian (`true` for AIFF/FORM, `false` for WAV/RIFF). */ protected _bigEndian: boolean; /** Ordered list of chunks found during header parsing. */ private _chunks; /** Format identifier read from bytes 8–11 of the file header (e.g. `"WAVE"`, `"AIFF"`). */ private _format; /** * Protected constructor — subclasses call this to set up the stream and endianness. * @param stream - The underlying I/O stream for the container file. * @param bigEndian - `true` for big-endian (AIFF/FORM), `false` for little-endian (WAV/RIFF). */ protected constructor(stream: IOStream, bigEndian: boolean); /** * Total number of top-level chunks found in the file. * @returns The chunk count. */ get chunkCount(): number; /** * Returns the four-character identifier of the chunk at the given index. * @param index - Zero-based chunk index. * @returns The chunk name (e.g. `"fmt "`, `"data"`). */ chunkName(index: number): string; /** * Returns the byte offset of the chunk data (past the 8-byte header) at the given index. * @param index - Zero-based chunk index. * @returns Byte offset within the file. */ chunkOffset(index: number): offset_t; /** * Returns the data size (in bytes) of the chunk at the given index. * @param index - Zero-based chunk index. * @returns Chunk data size in bytes. */ chunkDataSize(index: number): number; /** * Reads and returns the raw data bytes of the chunk at the given index. * @param index - Zero-based chunk index. * @returns A promise resolving to the chunk's data as a {@link ByteVector}. */ chunkData(index: number): Promise; /** * Returns the number of pad bytes (0 or 1) appended to the chunk at the given index. * @param index - Zero-based chunk index. * @returns Padding byte count. */ chunkPadding(index: number): number; /** The format identifier from the file header (e.g. `"WAVE"`, `"AIFF"`, `"AIFC"`). */ get riffFormat(): string; /** * 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. * @param name - Four-character chunk identifier. * @param data - Raw data bytes to store in the chunk. * @param overwrite - When `true`, replace an existing chunk with the same name. */ setChunkData(name: string, data: ByteVector, overwrite?: boolean): Promise; /** * Remove the first chunk matching `name` from both the file and the in-memory chunk list. * @param name - Four-character chunk identifier to remove. */ removeChunk(name: string): Promise; /** * 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. * @param name - Four-character chunk identifier to remove. */ removeAllChunks(name: string): Promise; /** * Reads the RIFF/FORM file header and populates the internal chunk list. * Sets `_valid` to `false` if the file header is missing or unrecognised. */ protected parseHeader(): Promise; /** * Rewrites the 4-byte file-size field at byte offset 4 to reflect the current file length. */ private updateFileSize; } //# sourceMappingURL=riffFile.d.ts.map