• Welcome to Dark Bit Factory & Gravity.
 

Example C code for Bassmod

Started by taj, January 14, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

taj

Music Coding Tutorial I : Taj

Hi all,

Its been a while since I posted any example code. So for complete newcomers like me to large intros (:-) ) here is some *minimal* (no error checking) C code for using bassmod. In effect I've written two wrapper functions for playing xm files. I chose bassmod as bass has great sound quality but bassmod is still quite small : its a cut down version of  the full bass library.

Of course start with:

#include "bassmod.h"


Now to start the music:

void startMusic () {
BASSMOD_Init (-1, 44100, 0);
BASSMOD_MusicLoad(FALSE,"music.xm",0,0,BASS_MUSIC_LOOP);
BASSMOD_MusicPlayEx(0,-1,TRUE);
}


This initialises the system at 44100 Hz, reads "music.xm" file and sets it to play in a loop.

and this code cleans up and closes down nicely.


void endMusic() {
        BASSMOD_MusicStop();
BASSMOD_Free();
}


Thats it! Incredibly simple.

Bassmod is available here:
http://www.un4seen.com/   
Challenge Trophies Won:

mike_g

Nice, That looks easy :)

I got Bass & C. So I'll have to play around with it sometime.

mind

Challenge Trophies Won:

Shockwave

Very useful snippet there Taj, thanks for posting it :) +K
Shockwave ^ Codigos
Challenge Trophies Won: