mwg API
    Preparing search index...

    Function decodeFlac

    • Decodes a FLAC stream to mono 16-bit frames and the rate its STREAMINFO states. A stereo stream keeps its left channel; a sample size other than 16 bits is shifted to 16. The stream's own length and rate are checked against maxFrames (default MAX_SAMPLE_FRAMES) and the rates a SoundFont can state before anything is allocated, since the bytes may come from a downloaded font.

      Parameters

      • bytes: Uint8Array
      • maxFrames: number = MAX_SAMPLE_FRAMES

      Returns { frames: Int16Array; rate: number }

      import { decodeFlac, encodeFlac } from '@datamoc/mwg/audio';

      const { frames, rate } = decodeFlac(encodeFlac(Int16Array.from([1, 2, 3]), 8000));
      console.log(frames.length, rate); // 3 8000