Please support our sponsor:
DirectX4VB.Com - All You Need For Multimedia Visual Basic Programming

Main Site Links Resources Tutorials
News VB Gaming Code Downloads DirectX 7
Contact Webmaster VB Programming Product Reviews DirectX 8
  General Multimedia Articles DirectX 9
      Miscellaneous

 

DirectXShow: MP3 Playback
Author: Jack Hoxley
Written: 29th August 2001
Contact: [EMail]
Download: DXS_MP3PLAY.Zip (11kb)


Contents of this lesson
1. Introduction
2. How to play Mp3s


1. Introduction

welcome 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...

Anyway, 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??


2. How to play Mp3s

okay okay, enough talk - show me how...

Due 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 Manager" (www.f1-team.co.uk), which will (someday) be a full blown proper game (yours truly is writing the multimedia engine).

The 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.

Now, go download the source from the top of the page (or download page), and enjoy.

DirectX 4 VB © 2000 Jack Hoxley. All rights reserved.
Reproduction of this site and it's contents, in whole or in part, is prohibited,
except where explicitly stated otherwise.
Design by Mateo
Contact Webmaster
This site is hosted by Exhedra Solutions, Inc., the parent company of RentACoder.com and PlanetSourceCode.com