BASS Library MP3 Playback Tutorial
 
Example Program with Source Code for Visual C - 725Kb
 
This tutorial will show you how to use the BASS lib to stream an MP3 from a file.
 
1 - Download the BASS library found in the library/bass section of this site, then uncompress to a directory on your hardrive.
 
2 - Next setup Visual C by linking the compiler to the required files.
Goto Tools/Options via the menu and include the two directories as shown below (Hilighted in blue)
 
 
Now that this is done, your compiler is setup correctly, all that has to be done now is to setup the project.
Goto Project/Settings, then click on the links tab and add bass.lib as shown below...
 

Everything is now setup apart from one thing.... When creating a new project, you have to copy the bass.dll to the root dir of that project. This DLL has to be with every project that you create using the bass library. Simply copy the BASS.DLL file from whereever you installed BASS, to your projects root directory. Once this is done you are ready to actually start coding!!!

 
Playing back an MP3 within your project.
 
First we need to declare a variable for the handle of the MP3 file, we do this with the line....
 

DWORD YourMP3File; // Handle for the file - This can be anything you like

 
Next we tell bass which sound output to use and the frequency with the following line....
 
if (!BASS_Init(-1,44100,0,g_hWnd)) { // Uses sound device 1 at a frequency of 44100
BASS_Init(-2,44100,0,g_hWnd); }// if the above device could not be found, then use no sound.
 
Next we start the BASS sound engine with this....
 
BASS_Start();
 
Now we tell bass which file to use....
 
YourMP3File=BASS_StreamCreateFile(FALSE,"Soundfile.mp3",0,0,BASS_MP3_SETPOS);
 
That's all the setting up done, easy eh? :) Now all that is required is to actually play the file. This is done with....
 
BASS_StreamPlay(MusicBack,0,BASS_SAMPLE_LOOP);
 
 

I created this tutorial just to show you how simple it is to use BASS, it is not an indepth tutorial, just the basics :)

This library is cool, the only bad thing is that if you plan to create your game/app as shareware or commercial, you have to pay money to acquire a license, BUT if ya making summin as freeware, then you may use it completly free!

 
This is just one of the many uses of the BASS library, for more information, read the manual that comes with the BASS download.