Written: 29th August 2001
of this lesson
2. How to play Mp3s
to another tutorial in using DirectXShow, This
is probably the one that everyones been waiting
for - Mp3 playback. In recent years this music
format has taken off as being the most popular
digital music format around - Mp3 players, Mp3
web servers, Mp3 walkmans... you name it, it exists.
It also has a nice tendency to get involved with
music piracy - I read somewhere that the top 3
music producers (Sony etc..) have spent US$300m+
on trying to stop this format - culminating (at
time of writing) in the successful legal case
again "Napster" (one of the massive
online Mp3 databases). As Mp3's can rival CD-Quality
replication it's easy to see why the big suits
are worried about their profit margins...
with respect to game development (or multimedia
development in general), the mp3 format is a brilliant
little tool - high quality music, little playback
overhead, small files. compared with the older
MIDI and wave formats this is a blessing - MIDI
sounded crap on all but the best sound cards,
and wave files - well, 100mb for a decent soundtrack??
How to play Mp3s
okay, enough talk - show me how...
to my lack of spare time at the moment I'm not
going to run through the in's and out's of all
the code - it is pretty simple actually, so instead
I'm giving you a modified version of the music
playback module from "Formula 1 Championship
which will (someday) be a full blown proper game
(yours truly is writing the multimedia engine).
sample code should be pretty obvious really -
the main module has Load( ), Play( ), Pause( )
and Stop( ) functions, as well as functions for
setting the balance, volume and speed (yep, you
can get chipmunk music). Whilst it's only "modDirectShow"
that you really need to pay attention to, it comes
with a simple interface for you to test things
out and see how it should work.
go download the source from the top of the page
page), and enjoy.