FormatParser.Audio (format_parser v2.6.0)

An Audio struct and functions.

The Audio struct contains the fields format, sample_rate_hz, num_audio_channels, intrinsics and nature.

Summary

Functions

Parses an audio file or result.

Types

t()

@type t() :: %FormatParser.Audio{
  format: atom() | nil,
  intrinsics: map(),
  nature: :audio,
  num_audio_channels: integer() | nil,
  sample_rate_hz: integer() | nil
}

Functions

parse(file)

@spec parse({:error, binary()} | binary() | any()) :: any()

Parses an audio file or result.

  • If given a tuple {:error, file} where file is a binary, attempts to parse the audio file.
  • If given a binary file, attempts to parse the audio file.
  • For any other input, returns the input as-is.

Examples

iex> parse({:error, "audio.mp3"}) # parsed audio result

iex> parse("audio.mp3") # parsed audio result

iex> parse(:ok) :ok