rockbox/metadata

Audio file metadata / tag parsing.

Types

Parsed metadata for one audio file (the common fields).

pub type Metadata {
  Metadata(
    codec: String,
    codec_id: Int,
    title: String,
    artist: String,
    album: String,
    albumartist: String,
    composer: String,
    genre: String,
    year: option.Option(Int),
    track_number: option.Option(Int),
    disc_number: option.Option(Int),
    duration_ms: Int,
    bitrate: Int,
    sample_rate: Int,
    filesize: Int,
    samples: Int,
    vbr: Bool,
    replaygain: ReplayGain,
  )
}

Constructors

  • Metadata(
      codec: String,
      codec_id: Int,
      title: String,
      artist: String,
      album: String,
      albumartist: String,
      composer: String,
      genre: String,
      year: option.Option(Int),
      track_number: option.Option(Int),
      disc_number: option.Option(Int),
      duration_ms: Int,
      bitrate: Int,
      sample_rate: Int,
      filesize: Int,
      samples: Int,
      vbr: Bool,
      replaygain: ReplayGain,
    )

ReplayGain values parsed from the file’s tags. The *_db / *_peak fields are user-friendly; the raw_* fields keep Rockbox’s native Q7.24 encoding — feed them straight into dsp.set_replaygain_gains_raw.

pub type ReplayGain {
  ReplayGain(
    track_gain_db: option.Option(Float),
    album_gain_db: option.Option(Float),
    track_peak: option.Option(Float),
    album_peak: option.Option(Float),
    raw_track_gain: Int,
    raw_album_gain: Int,
    raw_track_peak: Int,
    raw_album_peak: Int,
  )
}

Constructors

Values

pub fn probe(filename: String) -> option.Option(String)

Guess the codec label (e.g. "FLAC") from a filename’s extension without opening the file. None for an unknown extension.

pub fn read(path: String) -> Result(Metadata, Nil)

Parse the metadata of the audio file at path. Error(Nil) if the file cannot be opened, no parser recognises it, or the JSON fails to decode.

Search Document