I have to say that pretty much everything about ogg-vorbis files and streams stinks as far as Perl modules are concerned. For years, I've been using my own mp3-player backed up by the wonderful MPEG::MP3Play module. Unfortunately, the player itself was written in a dreadful way which made extending it impossible.
Now it happened that I got hold on a few .ogg
files that I would have liked to add to my playlist and, naturally, play them as if they were ordinary mp3s. Due to the inextensibility of my player that wasn't so easy at which point I decided to rewrite it. A song becomes a class and there's now on subclass for each filetype.
And then disaster set in for me finding a suitable module for decoding and playing back ogg-vorbis files. There's Ogg::Vorbis
which only allows to read PCM streams. That would be fine in its own right and I immedately added an Inline::C-section that opened /dev/dsp
and configured it accordingly to play PCM streams with 2 channels, 16 bits and 44100 Hz. That didn't work and I still can't say why. Also, I noticed that Ogg::Vorbis
doesn't provide methods for reporting the position of the current bitstream so with this modules it's impossible to have a counter of the playing time for each song.
Then I found Ogg::Vorbis::Decoder
which doesn't suffer from those limitations. Also, it actually comes with proper documentation. Yet, it still didn't work together with my Inline::C code. So I had to try two other modules, bother wrappers around libao. The first one (Ao) didn't even compile as it was evidently written for a very old version of libao. The other one (Audio::Ao
) did compile and passed its tests. Even better, it worked for me at first.
Then I looked for OGG-tagging modules. Ogg::Vorbis::Header
was the one I tried first. Didn't work although it passed its own tests. I found out that the reason was a strange interaction with Audio::Ao
. Both are Inline::C modules and I received many "One or more DATA sections were not processed by Inline"
. Apparently it's not trivial to use two such modules at the same time. I had to get rid of one of those two modules and I tried Ogg::Vorbis::Header::PurePerl
. Now my player worked again and was capable of displaying the tags. But I couldn't edit them as Ogg::Vorbis::Header::PurePerl
gives read-only access only.
The solution I eventually came up is clunky: I copied the Inline-code of Audio::Ao
into my OGG-class and added a Inline->init
right next to it. It's those kind of work-arounds that just confirm my hatred of anything Inline-related.
Now, compare that to mp3-handling in Perl: I only need two modules: One for the tag (MP3::Info
in my case) and one that can play them back (MPEG::MP3Play
). The latter gives me a unified event-API that reports timecode, supports pausing playback, adjusting the volume, comes with an equalizer etc. And of course it's written in proper XS so it's guaranteed to work immediately.