UNPKG

@types/node-wav

Version:
78 lines (66 loc) 2.6 kB
# Installation > `npm install --save @types/node-wav` # Summary This package contains type definitions for node-wav (https://github.com/andreasgal/node-wav). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-wav. ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-wav/index.d.ts) ````ts /// <reference types="node" /> /** * Decodes a {@link Buffer} containing a WAVE file into raw sample data. * @param buffer The {@link Buffer} containing a WAVE file to decode. * @return The decoded WAVE file. */ export function decode(buffer: Buffer): { /** * The sample rate of the decoded WAVE file, in Hertz. */ readonly sampleRate: number; /** * The raw sample data. * When mono, this will be a single {@link Float32Array}. * When stereo, this will be two {@link Float32Array}s of equal length. */ readonly channelData: readonly Float32Array[]; }; /** * Encodes raw sample data into a {@link Buffer} containing the corresponding WAVE file. * @param channelData The raw sample data to encode. Each {@link ArrayBuffer} must be of equal length. One {@link ArrayBuffer} represents mono, while two {@link ArrayBuffer}s represent stereo. * @param opts Options regarding the WAVE file to encode. * @return The encoded {@link Buffer}. */ export function encode( channelData: readonly ArrayLike<number>[], opts: { /** * The sample rate of the given {@link channelData}. * Defaults to 16000 when not given. */ readonly sampleRate?: number; /** * When true, the WAVE file is encoded in floating point. * It is otherwise encoded in fixed point. * An alias of {@link floatingPoint}. */ readonly float?: boolean; /** * When true, the WAVE file is encoded in floating point. * It is otherwise encoded in fixed point. * An alias of {@link float}. */ readonly floatingPoint?: boolean; /** * The bit depth of the WAVE file to encode. * This is ignored in floating point mode; floating point WAVE files are always 32-bit. * Otherwise defaults to 16. */ readonly bitDepth?: number; }, ): Buffer; ```` ### Additional Details * Last updated: Thu, 27 Feb 2025 18:37:52 GMT * Dependencies: [@types/node](https://npmjs.com/package/@types/node) # Credits These definitions were written by [jameswilddev](https://github.com/jameswilddev).