Ok, I’m quite confident I can turn Cinder to my whims when it’s about Graphics and Input.
But I also know the sound system Cinder uses is utterly… well, it doesn’t work very well.
So, from today onward, I’m using Bass (http://www.un4seen.com/) and this post will present anyone with a little cheat sheet on how to use it.
[stextbox id=”grey” caption=”Bass Cheat Sheet”]
//INIT
HSTREAM str;
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
//MessageBox(0,”An incorrect version of BASS.DLL was loaded”,0,MB_ICONERROR);
}
if (!BASS_Init(-1,44100,BASS_DEVICE_3D,win,NULL)) {
EndDialog(win,0);
}
//LOAD SOUND EFFECTS:
{
char file[MAX_PATH]=”C:\\WAVEFILE.wav”;
HSAMPLE sam;
if (sam=BASS_SampleLoad(FALSE,file,0,0,3,BASS_SAMPLE_OVER_POS)) {
samc++;
sams=(HSAMPLE*)realloc((void*)sams,samc*sizeof(*sams));
sams[samc-1]=sam;
SLM(LB_ADDSTRING,0,strrchr(file,’\\’)+1);
}
}
//PLAY SOUND EFFECTS:
int s=GETSAM();
if (s!=LB_ERR) {
// play the sample (at default rate, volume=50%, random pan position)
HCHANNEL ch=BASS_SampleGetChannel(sams[s],FALSE);
BASS_ChannelSetAttribute(ch,BASS_ATTRIB_VOL,0.5f);
BASS_ChannelSetAttribute(ch,BASS_ATTRIB_PAN,((rand()%201)-100)/100.f);
if (!BASS_ChannelPlay(ch,FALSE))
{
//Error(“Can’t play sample”);
}
}
//LOAD MUSIC:
{
char file[MAX_PATH]=”C:\\MP3FILE.mp3″;
if (str=BASS_StreamCreateFile(FALSE,file,0,0,0)) {
strc++;
strs=(HSTREAM*)realloc((void*)strs,strc*sizeof(*strs));
strs[strc-1]=str;
STLM(LB_ADDSTRING,0,strrchr(file,’\\’)+1);
}
}
//PLAY MUSIC:
s=GETSTR();
if (s!=LB_ERR)
if (!BASS_ChannelPlay(strs[s],FALSE)){ // play the stream (continue from current position)
int nauw = 1;
int bla = nauw;
int t = bla + 2;
// Error(“Can’t play stream”);
}
//MEMORY MANAGEMENT/DELETION:
// BASS_SampleFree(c->channel);
// BASS_MusicFree(c->channel);
// BASS_StreamFree(c->channel);
//3D:
/*
// INIT:
// Initialize the default output device with 3D support
if (!BASS_Init(-1,44100,BASS_DEVICE_3D,win,NULL)) {
Error(“Can’t initialize output device”);
EndDialog(win,0);
return 0;
}
// Use meters as distance unit, real world rolloff, real doppler effect
BASS_Set3DFactors(1,1,1);
//LOAD:
BASS_SampleLoad(FALSE,file,0,0,1,BASS_SAMPLE_LOOP|BASS_SAMPLE_3D|BASS_SAMPLE_MONO)
//USE:
BASS_ChannelSet3DPosition(channel,position,orientation,velocity);
BASS_Apply3D();
*/
[/stextbox]