00001 00002 // 00003 // Das Tank - Copyright (C) 2006, 2007 Windsor Schmidt <windsor@windsorworld.net> 00004 // 00005 // This program is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU General Public License as published by the Free 00007 // Software Foundation; either version 2 of the License, or (at your option) 00008 // any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 // more details. 00014 // 00015 // You should have received a copy of the GNU General Public License along with 00016 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00017 // Place, Suite 330, Boston, MA 02111-1307 USA 00018 // 00020 00021 00022 #ifndef STDAFX 00023 #include "stdafx.h" 00024 #endif 00025 00026 // global variables 00027 HCHANNEL hMainFX = NULL; 00028 HSAMPLE samples[256]; 00029 HSTREAM music[8]; 00030 HMUSIC track = NULL; 00031 00044 void InitSound(void) 00045 { 00046 // initialize sound effects 00047 samples[SOUNDID_FIRE_PS] = BASS_SampleLoad(false, "sfx\\fire_ps.wav", 0, 0, 8, NULL); 00048 samples[SOUNDID_FIRE_BS] = BASS_SampleLoad(false, "sfx\\fire_bs.wav", 0, 0, 8, NULL); 00049 samples[SOUNDID_FIRE_SB] = BASS_SampleLoad(false, "sfx\\fire_sb.wav", 0, 0, 8, NULL); 00050 samples[SOUNDID_FIRE_LM] = BASS_SampleLoad(false, "sfx\\fire_lm.wav", 0, 0, 8, NULL); 00051 samples[SOUNDID_FIRE_HS] = BASS_SampleLoad(false, "sfx\\fire_hs.wav", 0, 0, 8, NULL); 00052 samples[SOUNDID_POWERUP] = BASS_SampleLoad(false, "sfx\\powerup.wav", 0, 0, 8, NULL); 00053 samples[SOUNDID_CLICK] = BASS_SampleLoad(false, "sfx\\click.wav", 0, 0, 8, NULL); 00054 samples[SOUNDID_REFLECT] = BASS_SampleLoad(false, "sfx\\reflect.wav", 0, 0, 8, NULL); 00055 samples[SOUNDID_BOUNCE] = BASS_SampleLoad(false, "sfx\\bounce.wav", 0, 0, 8, NULL); 00056 samples[SOUNDID_HIT] = BASS_SampleLoad(false, "sfx\\hit.wav", 0, 0, 8, NULL); 00057 samples[SOUNDID_CRUNCH] = BASS_SampleLoad(false, "sfx\\crunch.wav", 0, 0, 8, NULL); 00058 samples[SOUNDID_POWERUP_HEALTH] = BASS_SampleLoad(false, "sfx\\health_orb.wav", 0, 0, 8, NULL); 00059 samples[SOUNDID_EXPLOSION] = BASS_SampleLoad(false, "sfx\\explosion.wav", 0, 0, 8, NULL); 00060 samples[SOUNDID_SCREAM] = BASS_SampleLoad(false, "sfx\\scream.wav", 0, 0, 8, NULL); 00061 samples[SOUNDID_VICTORY] = BASS_SampleLoad(false, "sfx\\victory.wav", 0, 0, 8, NULL); 00062 samples[SOUNDID_READY] = BASS_SampleLoad(false, "sfx\\ready.wav", 0, 0, 8, NULL); 00063 samples[SOUNDID_SET] = BASS_SampleLoad(false, "sfx\\set.wav", 0, 0, 8, NULL); 00064 samples[SOUNDID_GO] = BASS_SampleLoad(false, "sfx\\go.wav", 0, 0, 8, NULL); 00065 samples[SOUNDID_ENGINE] = BASS_SampleLoad(false, "sfx\\engine.wav", 0, 0, 8, NULL); 00066 samples[SOUNDID_BURNING] = BASS_SampleLoad(false, "sfx\\burning.wav", 0, 0, 8, NULL); 00067 samples[SOUNDID_MENUSELECT] = BASS_SampleLoad(false, "sfx\\menuselect.wav", 0, 0, 8, NULL); 00068 music[MUSICID_MENU] = BASS_StreamCreateFile(false,"mus\\menu.mp3",0,0,BASS_SAMPLE_LOOP); 00069 00070 // set volume levels 00071 SetSFXVolume(DEFAULT_SFX_VOLUME); 00072 SetBGMVolume(DEFAULT_BGM_VOLUME); 00073 } 00074 00075 00083 void PlaySound(int sound_id) 00084 { 00085 // play sound effect 00086 hMainFX = BASS_SampleGetChannel(samples[sound_id], FALSE); 00087 BASS_ChannelPlay(hMainFX, FALSE); 00088 } 00089 00090 00098 void PlayMusic(int music_id) 00099 { 00100 BASS_ChannelSetPosition(music[music_id], 0); 00101 BASS_ChannelPlay(music[music_id], FALSE); 00102 } 00103 00104 00112 void PlayLevelMusic(char * file) 00113 { 00114 if(track) 00115 { 00116 BASS_MusicFree(track); 00117 } 00118 track = BASS_MusicLoad(false, file, 0, 0, BASS_SAMPLE_LOOP, 0); 00119 BASS_ChannelPlay(track, TRUE); 00120 } 00121 00122 00131 void StopMusic(int music_id) 00132 { 00133 // stop music (both stream and tracker) 00134 BASS_ChannelStop(music[music_id]); 00135 BASS_ChannelStop(track); 00136 } 00137 00138 00143 void SetSFXVolume(int volume) 00144 { 00145 int vol = volume; 00146 if(vol > 100) { vol = 100; } 00147 if(vol < 0) { vol = 0; } 00148 BASS_SetConfig(BASS_CONFIG_GVOL_SAMPLE, vol); 00149 } 00150 00151 00156 void SetBGMVolume(int volume) 00157 { 00158 int vol = volume; 00159 if(vol > 100) { vol = 100; } 00160 if(vol < 0) { vol = 0; } 00161 BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, vol); // streaming music for the menu system 00162 BASS_SetConfig(BASS_CONFIG_GVOL_MUSIC, vol); // mod / it / s3m music for in-game 00163 }
Copyright Windsor Schmidt 2006 - All rights reserved.