#include <Sound.h>
Inheritance diagram for Sound:


Static Public Methods | |
| void | init (istream &in) |
| Initialze the sound system by loading settings, samples from a file. | |
| void | playRandomSound (int soundClass, float volume=s_masterSFXVol) |
| plays a random sound from set of sounds specified by soundClass | |
| void | play (int sample, float volume=s_masterSFXVol) |
| Play a sample. | |
| void | loop (int sample, float volume=s_masterSFXVol) |
| Loop a sample at specified volume. volume ranges from 0.0 to 1.0. | |
| void | stop (int sample) |
| Stop a sample from looping. | |
| const vector< NDX_Sample * > & | samples () |
| Return the list of samples. | |
| void | increaseSongVol () |
| increase the volume of the background song | |
| void | decreaseSongVol () |
| decrease the volume of the background song | |
| void | increaseSFXVol () |
| increase the volume of the sound effects | |
| void | decreaseSFXVol () |
| decrease the volume of the sound effects | |
| float | getMasterSFXVol () |
| float | getMasterSongVol () |
| void | shutdown () |
| Free any resources. | |
| void | playMusic (int sample, float volume=s_masterSongVol) |
| works just like loop(sample), except that there can be only 1 music at a time. When you play a new one, the old one is automatically stopped | |
| Sound & | getObj () |
Static Public Attributes | |
| const int | CLASS_SELECT = 0 |
| classes of sounds played when a unit is selected | |
| const int | CLASS_ACK = 1 |
| played when a unit is given a command | |
| const int | CLASS_TARGET = 2 |
| played when a battallion aquires a target | |
| const int | CLASS_DEATH = 3 |
| played when a unit dies | |
| const int | CLASS_CREATE_LT = 4 |
| played when light tank is created | |
| const int | CLASS_CREATE_HT = 5 |
| played when heavy tank is created | |
| const int | CLASS_CREATE_RT = 6 |
| played when rocket tank is created | |
| const int | CLASS_CREATE_AR = 7 |
| played when artillery is created | |
| const int | CLASS_CREATE_JT = 8 |
| played when jet is created | |
| const int | CLASS_BATTLE_CONTACT = 9 |
| played during when battle units engage | |
| const int | CLASS_BATTLE_STRESS = 10 |
| played during when battle units are stressed | |
| const int | CLASS_BATTLE_PANICK = 11 |
| played during when battle units are panicked | |
| const int | CLASS_JET_INTERCEPT = 12 |
| played during when jets intercept jets | |
| const int | CLASS_JET_BOMBING = 13 |
| played during when jets bomb targets | |
| const int | CLASS_JET_DIE = 14 |
| played during when jets die | |
| const int | NUM_CLASSES = 15 |
| const int | SMPL_SONG_WAR_WORLDS = 0 |
| const int | SMPL_SONG_MENU = 1 |
| const int | SMPL_SONG_WIN = 2 |
| const int | SMPL_SONG_LOST = 3 |
| const int | SMPL_SFX_EXPLOSION_LARGE = 4 |
| const int | SMPL_SFX_FIRE_LIGHTTANK = 5 |
| const int | SMPL_SFX_FIRE_LAUNCHER = 4 |
| const int | SMPL_SFX_FIRE_ARTILLERY = 7 |
| const int | SMPL_SFX_FIRE_JET = 8 |
| const int | SMPL_TUTORIAL_CITIES = 9 |
| const int | SMPL_TUTORIAL_INTRO = 10 |
| const int | SMPL_TUTORIAL_OVERHEAD = 11 |
| const int | SMPL_TUTORIAL_UNITS = 12 |
| const int | SMPL_TUTORIAL_BATTLE_CIRCLE = 13 |
| const int | SMPL_TUTORIAL_OVERHEAD_WHILE_BATTLE = 14 |
| const int | SMPL_TUTORIAL_BATTLE_MODE = 15 |
| const int | SMPL_TUTORIAL_TWO_BATTLES_AT_ONCE = 16 |
| const int | MSG_ANOTHER_BATTLE_IS_HAPPENING = 17 |
Static Protected Methods | |
| void | releaseObj () |
| should only be called by the class that inherits the Singleton functionality after the subclasses releases all its necessary resources | |
Static Private Methods | |
| NDX_Sample * | sampleFromWAV (LPSTR fn, int bufCount) |
Private Attributes | |
| NDX_Sound | m_sound |
| vector< NDX_Sample * > | m_sndClass [NUM_CLASSES] |
| vector< NDX_Sample * > | m_samples |
| int | currentMusic |
| vector< int > | lastRandomSelected |
Static Private Attributes | |
| Sound * | s_pObj |
| float | s_masterSongVol |
| float | s_masterSFXVol |
| int | s_songHandle |
|
|
decrease the volume of the sound effects
Definition at line 206 of file Sound.cpp. References s_masterSFXVol, and VOL_STEP(). Referenced by HUD::processOverheadInput().
00207 {
00208 if(s_masterSFXVol > 0.0f)
00209 s_masterSFXVol -= VOL_STEP;
00210
00211 }
|
|
|
decrease the volume of the background song
Definition at line 191 of file Sound.cpp. References currentMusic, m_samples, s_masterSongVol, s_pObj, and VOL_STEP(). Referenced by HUD::processOverheadInput().
00192 {
00193 if(s_masterSongVol > 0.0f)
00194 {
00195 s_masterSongVol -= VOL_STEP;
00196 s_pObj->m_samples[s_pObj->currentMusic]->SetVolume(s_songHandle, NDX_CALCVOLUME(s_masterSongVol));
00197 }
00198 }
|
|
|
Definition at line 213 of file Sound.cpp. References s_masterSFXVol. Referenced by BattleGroup::destroyUnit(), BattleGroup::fire(), BattleJets::fireAntiAirMissiles(), BattleJets::fireAntiSurfaceMissiles(), playVoiceContact(), playVoicePanick(), playVoiceStress(), and BattleJets::takeHit().
00214 {
00215 return s_masterSFXVol;
00216 }
|
|
|
Definition at line 218 of file Sound.cpp. References s_masterSongVol.
00219 {
00220 return s_masterSongVol;
00221 }
|
|
|
Referenced by init(), and main_init(). |
|
|
increase the volume of the sound effects
Definition at line 200 of file Sound.cpp. References s_masterSFXVol, and VOL_STEP(). Referenced by HUD::processOverheadInput().
00201 {
00202 if(s_masterSFXVol < 1.0f)
00203 s_masterSFXVol += VOL_STEP;
00204 }
|
|
|
increase the volume of the background song
Definition at line 182 of file Sound.cpp. References currentMusic, m_samples, s_masterSongVol, s_pObj, and VOL_STEP(). Referenced by HUD::processOverheadInput().
00183 {
00184 if(s_masterSongVol < 1.0f)
00185 {
00186 s_masterSongVol += VOL_STEP;
00187 s_pObj->m_samples[s_pObj->currentMusic]->SetVolume(s_songHandle, NDX_CALCVOLUME(s_masterSongVol));
00188 }
00189 }
|
|
|
Initialze the sound system by loading settings, samples from a file. Initializes the sound subsystem.
Definition at line 52 of file Sound.cpp. References currentMusic, Singleton< Sound >::getObj(), lastRandomSelected, m_samples, m_sndClass, m_sound, NUM_CLASSES, s_pObj, sampleFromWAV(), samples(), TOK_BEGIN_SAMPLES(), and TOK_BEGIN_SOUND_CLASSES(). Referenced by main_init().
00053 {
00054 s_pObj = &Sound::getObj();
00055
00056 assert(s_pObj->m_sound.Create(sys_getWindowHandle()) == NDXERR_OK);
00057
00058 // load the sound classes
00059 ostringstream dump;
00060 dump << in.rdbuf();
00061 string rawdata = dump.str();
00062
00063 size_t start = rawdata.find(TOK_BEGIN_SOUND_CLASSES)+TOK_BEGIN_SOUND_CLASSES.size();
00064 size_t len = rawdata.find(TOK_END_SOUND_CLASSES) - start;
00065 istringstream classData(rawdata.substr(start, len));
00066
00067 string line;
00068 while(getline(classData, line))
00069 {
00070 // format of the sound class data:
00071 // CLASS_NUM WAV_FILE_NAME NUMBER_OF_BUFFERS
00072 istringstream is(line);
00073 int classNum;
00074 string s;
00075 int bc;
00076 is >> classNum >> s >> bc;
00077 s_pObj->m_sndClass[classNum].push_back(sampleFromWAV(const_cast<LPSTR>(s.data()), bc));
00078
00079 for( int i=0; i<NUM_CLASSES; i++ )
00080 s_pObj->lastRandomSelected.push_back(-1);
00081 }
00082
00083 // load the rest of the samples
00084 start = rawdata.find(TOK_BEGIN_SAMPLES)+TOK_BEGIN_SAMPLES.size();
00085 len = rawdata.find(TOK_END_SAMPLES) - start;
00086 istringstream samples(rawdata.substr(start, len));
00087
00088 while(getline(samples, line))
00089 {
00090 // format of the sound samples data:
00091 // WAV_FILE_NAME NUMBER_OF_BUFFERS
00092 istringstream is(line);
00093 string s;
00094 int bc;
00095 is >> s >> bc;
00096 s_pObj->m_samples.push_back(sampleFromWAV(const_cast<LPSTR>(s.data()), bc));
00097 }
00098
00099 s_pObj->currentMusic = -1;
00100 }
|
|
||||||||||||
|
Loop a sample at specified volume. volume ranges from 0.0 to 1.0.
Definition at line 167 of file Sound.cpp. References m_samples, and s_pObj.
|
|
||||||||||||
|
Play a sample.
Definition at line 154 of file Sound.cpp. References m_samples, and s_pObj. Referenced by Tutorial::battleCircle(), Tutorial::battleMode(), Tutorial::city(), BattleGroup::destroyUnit(), Overhead::doCollisionDetection(), BattleGroup::fire(), BattleJets::fireAntiAirMissiles(), BattleJets::fireAntiSurfaceMissiles(), Tutorial::intro(), Tutorial::overhead(), Tutorial::overheadWhileBattle(), BattleJets::takeHit(), Tutorial::twoBattlesAtOnce(), and Tutorial::unit().
|
|
||||||||||||
|
works just like loop(sample), except that there can be only 1 music at a time. When you play a new one, the old one is automatically stopped
Definition at line 160 of file Sound.cpp. References currentMusic, m_samples, s_pObj, and stop(). Referenced by Overhead::overhead_init(), and updateSponsor().
00161 {
00162 if( s_pObj->currentMusic!=-1 ) s_pObj->stop(s_pObj->currentMusic);
00163 s_pObj->m_samples[sample]->Loop(NDX_CALCVOLUME(s_masterSongVol), &s_songHandle);
00164 s_pObj->currentMusic = sample;
00165 }
|
|
||||||||||||
|
plays a random sound from set of sounds specified by soundClass
Definition at line 141 of file Sound.cpp. References lastRandomSelected, m_sndClass, s_pObj, and sys_localRandInt(). Referenced by BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), BattleEntry::inputSelectGroups(), BattleEntry::inputSelectJets(), playVoiceContact(), playVoicePanick(), playVoiceStress(), HUD::processMiniMapInput(), Overhead::processOverheadInput(), and City::update().
00142 {
00144 int N = (int)s_pObj->m_sndClass[soundClass].size();
00145 size_t idx = sys_localRandInt() % N;
00146
00147 if( N>1 && idx==s_pObj->lastRandomSelected[soundClass] ) // don't pick the same thing twice
00148 idx = (idx+1) % N;
00149 s_pObj->lastRandomSelected[soundClass] = (int)idx;
00150
00151 s_pObj->m_sndClass[soundClass][idx]->Play(NDX_CALCVOLUME(volume));
00152 }
|
|
|
should only be called by the class that inherits the Singleton functionality after the subclasses releases all its necessary resources
Referenced by shutdown(). |
|
||||||||||||
|
Loads a sample from wav file.
Definition at line 108 of file Sound.cpp. References m_sound, and s_pObj. Referenced by init().
|
|
|
Return the list of samples.
Definition at line 177 of file Sound.cpp. References m_samples, and s_pObj. Referenced by init().
|
|
|
Free any resources. Frees all the resources Definition at line 119 of file Sound.cpp. References m_samples, m_sndClass, NUM_CLASSES, Singleton< Sound >::releaseObj(), and s_pObj. Referenced by Overhead::overhead_shutdown().
00120 {
00121 vector<NDX_Sample*>::iterator iter;
00122 for(int i=0; i<NUM_CLASSES; ++i)
00123 {
00124 for(iter = s_pObj->m_sndClass[i].begin(); iter != s_pObj->m_sndClass[i].end(); ++iter)
00125 {
00126 (*iter)->StopAll();
00127 delete *iter;
00128 }
00129 }
00130 for(iter = s_pObj->m_samples.begin(); iter != s_pObj->m_samples.end(); ++iter)
00131 {
00132 (*iter)->StopAll();
00133 delete *iter;
00134 }
00135 s_pObj->releaseObj();
00136 }
|
|
|
Stop a sample from looping.
Definition at line 172 of file Sound.cpp. References m_samples, and s_pObj. Referenced by playMusic(), and Tutorial::stopTutorial().
|
|
|
played when a unit is given a command
|
|
|
played during when battle units engage
|
|
|
played during when battle units are panicked
|
|
|
played during when battle units are stressed
|
|
|
played when artillery is created
|
|
|
played when heavy tank is created
|
|
|
played when jet is created
|
|
|
played when light tank is created
|
|
|
played when rocket tank is created
|
|
|
played when a unit dies
|
|
|
played during when jets bomb targets
|
|
|
played during when jets die
|
|
|
played during when jets intercept jets
|
|
|
classes of sounds played when a unit is selected
|
|
|
played when a battallion aquires a target
|
|
|
Definition at line 122 of file Sound.h. Referenced by decreaseSongVol(), increaseSongVol(), init(), and playMusic(). |
|
|
Definition at line 123 of file Sound.h. Referenced by init(), and playRandomSound(). |
|
|
Definition at line 119 of file Sound.h. Referenced by decreaseSongVol(), increaseSongVol(), init(), loop(), play(), playMusic(), samples(), shutdown(), and stop(). |
|
|
Definition at line 118 of file Sound.h. Referenced by init(), playRandomSound(), and shutdown(). |
|
|
Definition at line 117 of file Sound.h. Referenced by init(), and sampleFromWAV(). |
|
|
|
|
|
Definition at line 63 of file Sound.h. Referenced by init(), and shutdown(). |
|
|
Referenced by decreaseSFXVol(), getMasterSFXVol(), and increaseSFXVol(). |
|
|
Referenced by decreaseSongVol(), getMasterSongVol(), and increaseSongVol(). |
|
|
Definition at line 35 of file Sound.cpp. Referenced by decreaseSongVol(), increaseSongVol(), init(), loop(), play(), playMusic(), playRandomSound(), sampleFromWAV(), samples(), shutdown(), and stop(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 81 of file Sound.h. Referenced by Tutorial::stopTutorial(). |
|
|
|
1.3-rc2