Skip to content

FileDecoder

Melchor Garau Madrigal edited this page Nov 27, 2016 · 3 revisions

A stream.Readable class that converts a flac encoded file to PCM output.

FileDecoder(options)

You can pass all the options that can expect the Readable object, but also you can pass:

  • file: String
    • The file with the FLAC stream and where it will be read
    • You must provide this value
  • oggStream: Boolean
    • Determines if the Input data is an OGG Stream
    • Defaults to false
  • metadata: Array or Boolean
    • If is an array, tells the decoder to emit metadata when metadata blocks of the types passed are found
    • If is true, tells the decoder to emit metadata on all metadata blocks found
    • Defaults to STREAMINFO only

Buffer? FileDecoder.read()

Reads a chunk of decoded audio, in interleaved PCM format, on which every sample has the bit depth from FileDecoder.getBitsPerSample(). As example, a 16bit stream with 2 channels will produce the following structure in the buffer:

 --------------------------------------------------
| Left | Right | Left | Right | Left | Right | ... | 2 bytes per sample
|    Frame 0   |    Frame 1   |    Frame 2   | ... | 4 bytes per frame
 --------------------------------------------------

Here, frame means a pack of one sample for every channel. Differs from FLAC frame that is other thing.

Number FileDecoder.getTotalSamples()

Gets the number of samples stored in the stream, or 0 if it's undefined.

Number FileDecoder.getChannels()

Gets the number of channels stored in the stream.

Number FileDecoder.getChannelAssignment()

Returns the channel assignment of the stream. Values are from bindings.format.ChannelAssignment.

Number FileDecoder.getBitsPerSample()

Gets the bits per sample of the stream.

Event metadata

When some metadata has been read, is emitted in a event and it passes an JS representation of it.

Clone this wiki locally