import { ByteVector } from "../byteVector"; import { ILosslessAudioCodec, MediaTypes } from "../properties"; /** * Defines the format of waveform-audio data. Only format information common to all waveform-audio * data formats is included in this structure. * https://docs.microsoft.com/en-us/previous-versions/dd757713(v=vs.85) */ export default class RiffWaveFormatEx implements ILosslessAudioCodec { /** * FOURCC code that indicates the chunk is a RiffWaveFormatEx object. */ static readonly CHUNK_FOURCC = "fmt "; /** * List of well-known wave format tags. This is similar to FOURCC codes but for audio codecs. * @remarks * This list was put together from the Windows 10 SDK mmreg.h header file * If any of these descriptions are wrong or out of date, please open a PR. */ static readonly WAVE_FORMAT_TAGS: Map; private readonly _averageBytesPerSecond; private readonly _bitsPerSample; private readonly _blockAlign; private readonly _channels; private readonly _formatTag; private readonly _samplesPerSecond; /** * Constructs and initializes a new instance of a RIFF wave format header from the provided * data. * @param data Byte vector that contains the raw header */ constructor(data: ByteVector); /** @inheritDoc */ get audioBitrate(): number; /** @inheritDoc */ get audioChannels(): number; /** @inheritDoc */ get audioSampleRate(): number; /** * Gets the average data-transfer rate, in bytes per second, of audio described by the current * instance. */ get averageBytesPerSecond(): number; /** * @inheritDoc * @remarks * Some compression schemes cannot define a value for this field, so it may be `0`. * This is especially common for MP3 audio embedded in an AVI. */ get bitsPerSample(): number; /** * Gets the block alignment, in bytes. Block alignment is the minimum atomic unit of data for * {@link formatTag} format type. */ get blockAlign(): number; /** @inheritDoc */ get description(): string; /** * @inheritDoc * @remarks Duration cannot be found from this object */ get durationMilliseconds(): number; /** * Gets the format tag of the audio described by the current instance. * @remarks * Format tags indicate the codec of the audio contained in the file and are * contained in a Microsoft registry. For a description of the format, use * {@link description}. The complete list can be found in the Win32 mmreg.h SDK header file */ get formatTag(): number; /** * @inheritDoc * @remarks * Technically any audio format can be encapsulated with a RIFF header since RIFF is * simply a "Resource Interchange File Format". It is entirely possible to encapsulate a * lossy format (and indeed, lossy WMA must be encapsulated) with a RIFF header. Therefore, * this designation as lossless is somewhat misleading and checking {@link description} is * necessary to verify the codec being used is lossless or not. */ get mediaTypes(): MediaTypes; }