Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "write"

Index

Variables

Const HEADER_SIZE

HEADER_SIZE: 44 = 44

Functions

Const wavByteArray

  • wavByteArray(spec: WavSpec, src: Iterable<number>): Uint8Array
  • Takes a WavSpec and iterable of normalized float samples, creates WAV format header, converts samples to specified bit depth and returns Uint8Array of complete WAV file, ready for export.

    remarks

    If using more than one channel, the source samples need to be already interleaved, i.e. for stereo: left, right, left, right etc.

    At most, only the number of samples specified in the given header spec are consumed & written. The source iterable does not need to be limited explicitly.

    example
    import { osc, sin } from "@thi.ng/dsp";
    
    const FS = 48000;
    
    // write 1 second 24bit mono WAV file, 440Hz sine
    fs.writeFileSync(
      "sine-440.wav",
      wavByteArray(
        { sampleRate: FS, channels: 1, length: FS, bits: 24 },
        osc(sin, 440 / FS)
      )
    )

    Parameters

    Returns Uint8Array

Const wavBytes

  • wavBytes(spec: WavSpec, src: Iterable<number>): IterableIterator<number>
  • Similar to wavByteArray, but yields an iterator of the result bytes, not an actual byte array.

    Parameters

    Returns IterableIterator<number>

Const wavHeader

  • wavHeader(spec: WavSpec): BinStructItem[]

Object literals

Const CONVERTERS

CONVERTERS: object

16

  • 16(x: number): [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]
  • Parameters

    • x: number

    Returns [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]

24

  • 24(x: number): [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]
  • Parameters

    • x: number

    Returns [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]

32

  • 32(x: number): [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]
  • Parameters

    • x: number

    Returns [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]

8

  • 8(x: number): [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]
  • Parameters

    • x: number

    Returns [I8, number] | [I8_ARRAY, ArrayLike<number>] | [U8, number] | [U8_ARRAY, ArrayLike<number>] | [I16, number, undefined | false | true] | [I16_ARRAY, ArrayLike<number>, undefined | false | true] | [U16, number, undefined | false | true] | [U16_ARRAY, ArrayLike<number>, undefined | false | true] | [I24, number, undefined | false | true] | [I24_ARRAY, ArrayLike<number>, undefined | false | true] | [U24, number, undefined | false | true] | [U24_ARRAY, ArrayLike<number>, undefined | false | true] | [I32, number, undefined | false | true] | [I32_ARRAY, ArrayLike<number>, undefined | false | true] | [U32, number, undefined | false | true] | [U32_ARRAY, ArrayLike<number>, undefined | false | true] | [F32, number, undefined | false | true] | [F32_ARRAY, ArrayLike<number>, undefined | false | true] | [F64, number, undefined | false | true] | [F64_ARRAY, ArrayLike<number>, undefined | false | true] | [STR, string]

Generated using TypeDoc