0.0.3 • Published 6 months ago

@types/node-wav v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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

// Type definitions for node-wav 0.0
// Project: https://github.com/andreasgal/node-wav
// Definitions by: jameswilddev <https://github.com/jameswilddev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <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: ReadonlyArray<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: ReadonlyArray<ArrayBuffer>,
    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, 02 Sep 2021 21:31:20 GMT
  • Dependencies: @types/node
  • Global values: none

Credits

These definitions were written by jameswilddev.

0.0.1

7 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.0

3 years ago