Module: RockboxFFI::Metadata

Defined in:
lib/rockbox_ffi/metadata.rb

Overview

Audio file metadata parsing.

Class Method Summary collapse

Class Method Details

.probe(filename) ⇒ Object

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



25
26
27
# File 'lib/rockbox_ffi/metadata.rb', line 25

def probe(filename)
  RockboxFFI.take_string(Lib.rb_meta_probe(filename.to_s))
end

.read(path) ⇒ Object

Parse the metadata of the audio file at path.

Returns a Hash (symbol keys) with tag strings, :duration_ms, :bitrate, :sample_rate, a nested :replaygain Hash (including the raw Q7.24 raw_* fields), and optional :album_art / :cuesheet locations. Raises on failure.



16
17
18
19
20
21
# File 'lib/rockbox_ffi/metadata.rb', line 16

def read(path)
  s = RockboxFFI.take_string(Lib.rb_meta_read_json(path.to_s))
  raise "could not read metadata from #{path.inspect}" if s.nil?

  JSON.parse(s, symbolize_names: true)
end