TuningFork.Flac (TuningFork v0.1.11)

Copy Markdown View Source

Reads FLAC into 16-bit PCM.

{:ok, pcm, rate, channels} = TuningFork.Flac.decode(File.read!("bell.flac"))

Summary

Functions

The PCM in a FLAC stream, with its rate and channel count.

What a FLAC stream holds, read from its header without decoding it.

Read a FLAC file from disk.

Types

reason()

@type reason() :: :not_flac | :truncated | :unsupported

Functions

decode(arg1)

@spec decode(binary()) ::
  {:ok, binary(), pos_integer(), pos_integer()} | {:error, reason()}

The PCM in a FLAC stream, with its rate and channel count.

Returns {:ok, pcm, rate, channels}, or {:error, reason} where the reason is :not_flac for bytes that do not begin a FLAC stream, :truncated for a stream that ends mid-frame, and :unsupported for a channel count over two.

info(arg1)

@spec info(binary()) :: {:ok, map()} | {:error, reason()}

What a FLAC stream holds, read from its header without decoding it.

%{rate: rate, channels: channels, bits: bits_per_sample, frames: total_frames}, where frames is 0 for a stream whose length was not written.

read!(path)

@spec read!(Path.t()) :: {binary(), pos_integer(), pos_integer()}

Read a FLAC file from disk.

Gives {pcm, rate, channels} as TuningFork.Wav.read!/1 does, and raises ArgumentError for a file that is not FLAC or is cut short.