Author Topic: Example C code for Bassmod  (Read 4310 times)

0 Members and 1 Guest are viewing this topic.

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Example C code for Bassmod
« on: January 14, 2007 »
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:
Code: [Select]
#include "bassmod.h"

Now to start the music:
Code: [Select]
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.

Code: [Select]
void endMusic() {
        BASSMOD_MusicStop();
BASSMOD_Free();
}

Thats it! Incredibly simple.

Bassmod is available here:
http://www.un4seen.com/   
« Last Edit: January 18, 2007 by taj »
Challenge Trophies Won:

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
Re: Example C code for Bassmod
« Reply #1 on: January 14, 2007 »
Nice, That looks easy :)

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

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Example C code for Bassmod
« Reply #2 on: January 15, 2007 »
BASS!!!

nice work taj :)
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Example C code for Bassmod
« Reply #3 on: January 16, 2007 »
Very useful snippet there Taj, thanks for posting it :) +K
Shockwave ^ Codigos
Challenge Trophies Won: