NAME

AudioFile::Info - Perl extension to get info from audio files.

SYNOPSIS

use AudioFile::Info;

my $song = AudioFile::Info->new($some_mp3_or_ogg_vorbis_file);

print 'Title:  ', $song->title, "\n",
      'Artist: ', $song->artist, "\n".
      'Album:  ', $song->album, "\n",
      'Track:  ', $song->track, "\n";
      'Year:   ', $song->year, "\n",
      'Genre:  ', $song->genre, "\n";

ABSTRACT

AudioFile::Info is a simple way to get track information out of an audio file. It gives a unified interface for extracting information from both MP3 and Ogg Vorbis files.

DESCRIPTION

What is AudioFile::Info

I rip all of my audio files into Ogg Vorbis files. But some of my older rips are in MP3 format. If I'm writing a program to access information from my audio files it's annoying when I have to handle MP3 and Ogg Vorbis files completely separately.

AudioFile::Info is my solution to that problem. It works on both MP3 and Ogg Vorbis files and gives an identical interface for dealing with both of them.

Using AudioFile::Info

To use AudioFile::Info in your programs you simply load the module as normal.

use AudioFile::Info;

You then create an object using the new method and passing it the pathname of an audio file.

my $song = AudioFile::Info->new($some_mp3_or_ogg_vorbis_file);

The module works out whether the file is in MP3 or Ogg Vorbis format and creates an object which can extract the information from the correct type of file. You can then use this object to access the various pieces of information about the file.

print 'Title:  ', $song->title, "\n",
      'Artist: ', $song->artist, "\n".
      'Album:  ', $song->album, "\n",
      'Track:  ', $song->track, "\n";
      'Year:   ', $song->year, "\n",
      'Genre:  ', $song->genre, "\n";

Currently you can access the title, artist, album, track number, year and genre of the file.

Currently you can only read data from the files. You can't alter it an write it back.

AudioFile::Info Plugins

AudioFile::Info is simply a wrapper around various other modules which read MP3 and Ogg Vorbis files. It makes use of module by using plugin modules which act as an interface between AudioFile::Info and the other modules. AudioFile::Info is pretty much useless without at least one these plugins installed.

Each time you install a plugin, AudioFile::Info notes how it compares with other installed plugins. It then works out how which of your installed plugins is best for handling the variosu types of audio files. When you use the module to read a file it will use the "best" plugin for the file type.

You can override this behaviour and tell it to use a particular plugin by using an extended version of the new method.

new takes an optional argument which is a reference to a hash that contains details of which plugin to use for each file type. You use it like this.

my $song = AudioFile::Info->new($file,
                                { mp3 => 'AudioFile::Info::MP3::Info' });

In this case, if $file is the name of an MP3 file then AudioFile::Info will use AudioFile::Info::MP3::Info to handle it rather than the default MP3 plugin. If $file contains the name of an Ogg Vorbis file then the default Ogg Vorbis plugin will still be used. You can change the Ogg Vorbis plugin by using the ogg key in the optional hash.

Currently plugins are available for the following modules.

  • MP3::ID3Lib

  • MP3::Info

  • Ogg::Vorbis::Header::PurePerl

Plugins for other modules will appear soon.

EXPORT

None.

SEE ALSO

The various plugin modules.

TO DO

  • Make more data available.

  • Changing and writing data.

AUTHOR

Dave Cross, <dave@dave.org.uk>

COPYRIGHT AND LICENSE

Copyright 2003 by Dave Cross

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.