Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 1.95 KB

README.md

File metadata and controls

71 lines (50 loc) · 1.95 KB

WahWah

CI Coverage Status Ruby Style Guide

WahWah is an audio metadata reader Ruby gem, it supports many popular formats including mp3(ID3 v1, v2.2, v2.3, v2.4), m4a, ogg, oga, opus, wav, flac and wma.

WahWah is written in pure Ruby, and without any dependencies.

Installation

Add this line to your application's Gemfile:

gem "wahwah"

And then execute:

$ bundle

Or install it yourself as:

$ gem install wahwah

Compatibility

WahWah support Ruby 2.7+

Usage

WahWah is so easy to use.

require "wahwah"

# Get metadata from an audio file path
tag = WahWah.open("/files/example.wav")

# Or from IO like object
File.open("/files/example.wav") do |file|
  tag = WahWah.open(file)
end

# Supported attributes
tag.title       # => "song title"
tag.artist      # => "artist name"
tag.album       # => "album name"
tag.albumartist # => "albumartist name"
tag.composer    # => "composer name"
tag.comments    # => ["comment", "another comment"]
tag.track       # => 1
tag.track_total # => 10
tag.genre       # => "Rock"
tag.year        # => "1984"
tag.disc        # => 1
tag.disc_total  # => 2
tag.lyrics      # => "song lyrics"
tag.duration    # => 256.1 (in seconds)
tag.bitrate     # => 192 (in kbps)
tag.sample_rate # => 44100 (in Hz)
tag.bit_depth   # => 16 (in bits, only for PCM formats)
tag.file_size   # => 976700 (in bytes)
tag.images      # => [{ :type => :cover_front, :mime_type => 'image/jpeg', :data => 'image data binary string' }]


# Get all support formats
WahWah.support_formats # => ["mp3", "ogg", "oga", "opus", "wav", "flac", "wma", "m4a"]