diff --git a/panda/src/audiotraits/Sources.pp b/panda/src/audiotraits/Sources.pp index a1210a7b46..518a4ddd91 100644 --- a/panda/src/audiotraits/Sources.pp +++ b/panda/src/audiotraits/Sources.pp @@ -23,7 +23,7 @@ #begin lib_target #define TARGET fmod_audio - #define BUILD_TARGET $[HAVE_FMOD] + #define BUILD_TARGET $[HAVE_FMODEX] #define USE_PACKAGES fmod #define BUILDING_DLL BUILDING_FMOD_AUDIO #define LOCAL_LIBS audio event diff --git a/panda/src/audiotraits/config_fmodAudio.cxx b/panda/src/audiotraits/config_fmodAudio.cxx index c83ff4d818..797fd638d1 100644 --- a/panda/src/audiotraits/config_fmodAudio.cxx +++ b/panda/src/audiotraits/config_fmodAudio.cxx @@ -17,7 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "pandabase.h" -#ifdef HAVE_FMOD //[ +#ifdef HAVE_FMODEX //[ #include "config_fmodAudio.h" diff --git a/panda/src/audiotraits/config_fmodAudio.h b/panda/src/audiotraits/config_fmodAudio.h index 53ce3630f4..5d5e29691f 100644 --- a/panda/src/audiotraits/config_fmodAudio.h +++ b/panda/src/audiotraits/config_fmodAudio.h @@ -21,7 +21,7 @@ #include "pandabase.h" -#ifdef HAVE_FMOD //[ +#ifdef HAVE_FMODEX //[ #include "notifyCategoryProxy.h" #include "dconfig.h" diff --git a/panda/src/audiotraits/fmodAudioDSP.cxx b/panda/src/audiotraits/fmodAudioDSP.cxx index c905249e6c..d20d57d93d 100644 --- a/panda/src/audiotraits/fmodAudioDSP.cxx +++ b/panda/src/audiotraits/fmodAudioDSP.cxx @@ -20,7 +20,7 @@ #include "pandabase.h" #include "dcast.h" -#ifdef HAVE_FMOD //[ +#ifdef HAVE_FMODEX //[ //Panda Headers #include "config_audio.h" @@ -33,31 +33,29 @@ TypeHandle FmodAudioDSP::_type_handle; // Function: FmodAudioDSP::FmodAudioDSP // Access: Protected // Description: Constructor -// This is a thin wrapper around FMOD-EX. +// This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -FmodAudioDSP::FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat) { +FmodAudioDSP:: +FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat) { // Intentionally blank. - audio_debug("FmodAudioDSP::FmodAudioDSP() Creating new DSP " ); + audio_debug("FmodAudioDSP::FmodAudioDSP() Creating new DSP " ); + + //Local Variables that are needed. + FMOD_RESULT result; - //Local Variables that are needed. - FMOD_RESULT result; + //Assign the values we need + DCAST_INTO_V(_manager, manager); - //Assign the values we need - DCAST_INTO_V(_manager, manager); + FMOD_DSP_TYPE dsptype = (FMOD_DSP_TYPE)cat; - FMOD_DSP_TYPE dsptype = (FMOD_DSP_TYPE)cat; + result = _manager->_system->createDSPByType( dsptype, &_dsp); + ERRCHECK(result); - result = _manager->_system->createDSPByType( dsptype, &_dsp); - ERRCHECK(result); - - set_in_chain(false); - - cerr << get_dsp_name() << endl; - - audio_debug("DSP Loaded"); + set_in_chain(false); + audio_debug("DSP Loaded"); } @@ -68,21 +66,20 @@ FmodAudioDSP::FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat // Access: Published, Virtual // Description: DESTRUCTOR!!! //////////////////////////////////////////////////////////////////// -FmodAudioDSP::~FmodAudioDSP() { +FmodAudioDSP:: +~FmodAudioDSP() { + audio_debug("FmodAudioSound::FmodAudioDSP() Destruction!!! " ); - audio_debug("FmodAudioSound::FmodAudioDSP() Destruction!!! " ); + //Local Variables that are needed. + FMOD_RESULT result; - //Local Variables that are needed. - FMOD_RESULT result; + result = _dsp->remove(); + ERRCHECK(result); - result = _dsp->remove(); - ERRCHECK(result); + result = _dsp->release(); + ERRCHECK(result); - result = _dsp->release(); - ERRCHECK(result); - - audio_debug("DSP GONE"); - + audio_debug("DSP GONE"); } @@ -91,20 +88,19 @@ FmodAudioDSP::~FmodAudioDSP() { // Access: Published, Virtual // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. -// [This resets an FMOD DSP to its default values] +// [This resets an FMOD DSP to its default values] //////////////////////////////////////////////////////////////////// -void FmodAudioDSP::reset() { +void FmodAudioDSP:: +reset() { + audio_debug("FmodAudioSound::reset() Reset DSP to default settings." ); - audio_debug("FmodAudioSound::reset() Reset DSP to default settings." ); + //Local Variables that are needed. + FMOD_RESULT result; - //Local Variables that are needed. - FMOD_RESULT result; - - result = _dsp->reset(); - ERRCHECK(result); - - audio_debug("DSP Reset."); + result = _dsp->reset(); + ERRCHECK(result); + audio_debug("DSP Reset."); } //////////////////////////////////////////////////////////////////// @@ -112,19 +108,19 @@ void FmodAudioDSP::reset() { // Access: Published, Virtual // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. -// [This removes the DSP from an Effects Chain] +// [This removes the DSP from an Effects Chain] //////////////////////////////////////////////////////////////////// -void FmodAudioDSP::remove() { - audio_debug("FmodAudioSound::remove() Removes a DSP from and effect chain." ); +void FmodAudioDSP:: +remove() { + audio_debug("FmodAudioSound::remove() Removes a DSP from and effect chain." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - result = _dsp->remove(); - ERRCHECK(result); - - audio_debug("DSP Removed from relative effects chain."); + result = _dsp->remove(); + ERRCHECK(result); + audio_debug("DSP Removed from relative effects chain."); } //////////////////////////////////////////////////////////////////// @@ -132,18 +128,19 @@ void FmodAudioDSP::remove() { // Access: Published, Virtual // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. -// [This turns the Bypass for an Effect on and off]/ +// [This turns the Bypass for an Effect on and off]/ //////////////////////////////////////////////////////////////////// -void FmodAudioDSP::set_bypass(bool bypass) { - audio_debug("FmodAudioSound::set_bypass() ." ); +void FmodAudioDSP:: +set_bypass(bool bypass) { + audio_debug("FmodAudioSound::set_bypass() ." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - result = _dsp->setBypass(bypass); - ERRCHECK(result); + result = _dsp->setBypass(bypass); + ERRCHECK(result); - audio_debug("DSP Bypass set to:" << bypass ); + audio_debug("DSP Bypass set to:" << bypass ); } //////////////////////////////////////////////////////////////////// @@ -152,19 +149,19 @@ void FmodAudioDSP::set_bypass(bool bypass) { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -bool FmodAudioDSP::get_bypass() { - audio_debug("FmodAudioSound::get_bypass() ." ); +bool FmodAudioDSP:: +get_bypass() { + audio_debug("FmodAudioSound::get_bypass() ." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - bool bypass; + bool bypass; - result = _dsp->getBypass(&bypass); - ERRCHECK(result); - - return bypass; + result = _dsp->getBypass(&bypass); + ERRCHECK(result); + return bypass; } @@ -175,19 +172,18 @@ bool FmodAudioDSP::get_bypass() { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -void FmodAudioDSP::set_parameter(const string &name, float value) { - - int parameterIndex = find_parameter(name); - if (parameterIndex < 0) { - return; - } +void FmodAudioDSP:: +set_parameter(const string &name, float value) { + int parameterIndex = find_parameter(name); + if (parameterIndex < 0) { + return; + } - //Local Variables that are needed. - FMOD_RESULT result; - - result = _dsp->setParameter(parameterIndex, value); - ERRCHECK(result); + //Local Variables that are needed. + FMOD_RESULT result; + result = _dsp->setParameter(parameterIndex, value); + ERRCHECK(result); } @@ -197,18 +193,19 @@ void FmodAudioDSP::set_parameter(const string &name, float value) { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -int FmodAudioDSP::get_num_parameters() { - audio_debug("FmodAudioSound::get_num_parameters() ." ); +int FmodAudioDSP:: +get_num_parameters() { + audio_debug("FmodAudioSound::get_num_parameters() ." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - int numOfParameters; + int numOfParameters; - result = _dsp->getNumParameters(&numOfParameters); - ERRCHECK(result); + result = _dsp->getNumParameters(&numOfParameters); + ERRCHECK(result); - return numOfParameters; + return numOfParameters; } //////////////////////////////////////////////////////////////////// @@ -217,30 +214,30 @@ int FmodAudioDSP::get_num_parameters() { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -string FmodAudioDSP::get_parameter_name(int parameterIndex) { - // intentionally blank +string FmodAudioDSP:: +get_parameter_name(int parameterIndex) { - audio_debug("FmodAudioSound::get_parameter_name()" ); + audio_debug("FmodAudioSound::get_parameter_name()" ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - //int parameterIndex; - char parameterName[32]; - char parameterLabel[32]; - char parameterDescription[32]; - int parameterDescriptionLength = 0; - float parameterMin; - float parameterMax; + //int parameterIndex; + char parameterName[32]; + char parameterLabel[32]; + char parameterDescription[32]; + int parameterDescriptionLength = 0; + float parameterMin; + float parameterMax; - result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); - ERRCHECK(result); + result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); + ERRCHECK(result); - string returnInfo = (parameterName); + string returnInfo = (parameterName); - return returnInfo; + return returnInfo; - //return ""; + //return ""; } @@ -249,37 +246,38 @@ string FmodAudioDSP::get_parameter_name(int parameterIndex) { // Access: Published, Virtual // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. -// This Method actually returns FMOD's Parameter Label -// Information, and not Description. -// The reason is, that most of the FMOD's Description -// Properties seem to be empty. -// Also the Label sort of serves as as a description by -// return the type of unit the cooresponding parameter -// modifies for a DSP. -// IE. For the Echo. The first parameter is 'Delay' -// and the units for measuring the Delay is in Milliseconds. -// The Label returns Milliseconds letting you know that. +// This Method actually returns FMOD's Parameter Label +// Information, and not Description. +// The reason is, that most of the FMOD's Description +// Properties seem to be empty. +// Also the Label sort of serves as as a description by +// return the type of unit the cooresponding parameter +// modifies for a DSP. +// IE. For the Echo. The first parameter is 'Delay' +// and the units for measuring the Delay is in Milliseconds. +// The Label returns Milliseconds letting you know that. //////////////////////////////////////////////////////////////////// -string FmodAudioDSP::get_parameter_description(int parameterIndex) { - // intentionally blank +string FmodAudioDSP:: +get_parameter_description(int parameterIndex) { + // intentionally blank - audio_debug("FmodAudioSound::get_parameter_description()." ); + audio_debug("FmodAudioSound::get_parameter_description()." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - //int parameterIndex; - char parameterName[32]; - char parameterLabel[32]; - char parameterDescription[32]; - int parameterDescriptionLength = 0; - float parameterMin; - float parameterMax; + //int parameterIndex; + char parameterName[32]; + char parameterLabel[32]; + char parameterDescription[32]; + int parameterDescriptionLength = 0; + float parameterMin; + float parameterMax; - result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); - ERRCHECK(result); + result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); + ERRCHECK(result); - return parameterLabel; + return parameterLabel; } @@ -289,25 +287,26 @@ string FmodAudioDSP::get_parameter_description(int parameterIndex) { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -float FmodAudioDSP::get_parameter_min(int parameterIndex) { - - audio_debug("FmodAudioSound::get_parameter_min()." ); +float FmodAudioDSP:: +get_parameter_min(int parameterIndex) { + + audio_debug("FmodAudioSound::get_parameter_min()." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - //int parameterIndex; - char parameterName[32]; - char parameterLabel[32]; - char parameterDescription[32]; - int parameterDescriptionLength = 0; - float parameterMin; - float parameterMax; + //int parameterIndex; + char parameterName[32]; + char parameterLabel[32]; + char parameterDescription[32]; + int parameterDescriptionLength = 0; + float parameterMin; + float parameterMax; - result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); - ERRCHECK(result); + result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); + ERRCHECK(result); - return parameterMin; + return parameterMin; } //////////////////////////////////////////////////////////////////// @@ -316,25 +315,26 @@ float FmodAudioDSP::get_parameter_min(int parameterIndex) { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -float FmodAudioDSP::get_parameter_max(int parameterIndex) { - - audio_debug("FmodAudioSound::get_parameter_min()." ); +float FmodAudioDSP:: +get_parameter_max(int parameterIndex) { + + audio_debug("FmodAudioSound::get_parameter_min()." ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - //int parameterIndex; - char parameterName[32]; - char parameterLabel[32]; - char parameterDescription[32]; - int parameterDescriptionLength = 0; - float parameterMin; - float parameterMax; + //int parameterIndex; + char parameterName[32]; + char parameterLabel[32]; + char parameterDescription[32]; + int parameterDescriptionLength = 0; + float parameterMin; + float parameterMax; - result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); - ERRCHECK(result); + result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax); + ERRCHECK(result); - return parameterMax; + return parameterMax; } @@ -344,25 +344,26 @@ float FmodAudioDSP::get_parameter_max(int parameterIndex) { // Description: This is a thin wrapper around FMOD-EX. // See the FMOD-EX documentation. //////////////////////////////////////////////////////////////////// -float FmodAudioDSP::get_parameter_value(const string &name) { - - int parameterIndex = find_parameter(name); - if (parameterIndex < 0) { - return 0.0; - } +float FmodAudioDSP:: +get_parameter_value(const string &name) { + + int parameterIndex = find_parameter(name); + if (parameterIndex < 0) { + return 0.0; + } - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - float parameterValue; - char valuestr[32]; - int valuestrlen = 32; + float parameterValue; + char valuestr[32]; + int valuestrlen = 32; - result = _dsp->getParameter(parameterIndex, ¶meterValue, valuestr, valuestrlen); - ERRCHECK(result); + result = _dsp->getParameter(parameterIndex, ¶meterValue, valuestr, valuestrlen); + ERRCHECK(result); - return parameterValue; + return parameterValue; } //////////////////////////////////////////////////////////////////// @@ -370,17 +371,18 @@ float FmodAudioDSP::get_parameter_value(const string &name) { // Access: Private // Description: Convert a parameter name to an fmod parameter index. //////////////////////////////////////////////////////////////////// -int FmodAudioDSP::find_parameter(const string &name) { - int np = get_num_parameters(); - for (int i=0; igetInfo(name, &version, &channels, &configwidth, &configheight); - ERRCHECK(result); + result = _dsp->getInfo(name, &version, &channels, &configwidth, &configheight); + ERRCHECK(result); - string returnInfo = (name); - //returnInfo.append(" Version: "); - //returnInfo.append(version); - //returnInfo.append("\n"); - - return returnInfo; + string returnInfo = (name); + //returnInfo.append(" Version: "); + //returnInfo.append(version); + //returnInfo.append("\n"); + return returnInfo; } @@ -418,17 +419,15 @@ string FmodAudioDSP::get_dsp_name() { // Function: FmodAudioDSP::get_in_chain() // Access: Published, Virtual // Description: This is a functiont to query if a DSP have been assigned -// to the GLOBAL or a SOUND's effect chain. -// This is to make sure you 'remove' an effect from a chain -// before you move it somewhere else or destroy it. +// to the GLOBAL or a SOUND's effect chain. +// This is to make sure you 'remove' an effect from a chain +// before you move it somewhere else or destroy it. //////////////////////////////////////////////////////////////////// -bool FmodAudioDSP::get_in_chain() { - - audio_debug("FmodAudioSound::get_in_chain()." ); - - return _in_chain; - +bool FmodAudioDSP:: +get_in_chain() { + audio_debug("FmodAudioSound::get_in_chain()." ); + return _in_chain; } @@ -436,16 +435,14 @@ bool FmodAudioDSP::get_in_chain() { // Function: FmodAudioDSP::set_in_chain() // Access: Published, Virtual // Description: This is a functiont to set if a DSP have been assigned -// to the GLOBAL or a SOUND's effect chain. +// to the GLOBAL or a SOUND's effect chain. //////////////////////////////////////////////////////////////////// -void FmodAudioDSP::set_in_chain(bool chain_state) { - - audio_debug("FmodAudioSound::set_in_chain()." ); - - _in_chain = chain_state; +void FmodAudioDSP:: +set_in_chain(bool chain_state) { + audio_debug("FmodAudioSound::set_in_chain()." ); + _in_chain = chain_state; } - #endif //] diff --git a/panda/src/audiotraits/fmodAudioDSP.h b/panda/src/audiotraits/fmodAudioDSP.h index 1856cac888..db090ed39f 100644 --- a/panda/src/audiotraits/fmodAudioDSP.h +++ b/panda/src/audiotraits/fmodAudioDSP.h @@ -72,7 +72,7 @@ #include -#ifdef HAVE_FMOD //[ +#ifdef HAVE_FMODEX //[ #include "audioManager.h" #include "audioDSP.h" diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 2f042105a8..30b2dc8e3b 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -23,7 +23,7 @@ #include "config_audio.h" #include "dcast.h" -#ifdef HAVE_FMOD //[ +#ifdef HAVE_FMODEX //[ //Panda headers. #include "config_audio.h" @@ -61,13 +61,13 @@ TypeHandle FmodAudioManager::_type_handle; // Python Prompt ///////////////////////////////////////////////////////////////////// void ERRCHECK(FMOD_RESULT result){ - audio_debug("FMOD State: "<< result <<" "<< FMOD_ErrorString(result) ); + audio_debug("FMOD State: "<< result <<" "<< FMOD_ErrorString(result) ); } PT(AudioManager) Create_AudioManager() { - audio_debug("Create_AudioManager() Fmod."); - return new FmodAudioManager; + audio_debug("Create_AudioManager() Fmod."); + return new FmodAudioManager; } @@ -76,92 +76,91 @@ PT(AudioManager) Create_AudioManager() { // Access: Public // Description: Constructor //////////////////////////////////////////////////////////////////// -FmodAudioManager::FmodAudioManager() { +FmodAudioManager:: +FmodAudioManager() { - //OK Lets create the FMOD Audio Manager. - audio_debug("FmodAudioManager::FmodAudioManager()"); + //OK Lets create the FMOD Audio Manager. + audio_debug("FmodAudioManager::FmodAudioManager()"); - FMOD_RESULT result; + FMOD_RESULT result; - //We need a varible temporary to check the FMOD Version. - unsigned int version; + //We need a varible temporary to check the FMOD Version. + unsigned int version; - //Init 3D attributes - _position.x = 0; - _position.y = 0; - _position.z = 0; + //Init 3D attributes + _position.x = 0; + _position.y = 0; + _position.z = 0; - _velocity.x = 0; - _velocity.y = 0; - _velocity.z = 0; + _velocity.x = 0; + _velocity.y = 0; + _velocity.z = 0; - _forward.x = 0; - _forward.y = 0; - _forward.z = 0; + _forward.x = 0; + _forward.y = 0; + _forward.z = 0; - _up.x = 0; - _up.y = 0; - _up.z = 0; - + _up.x = 0; + _up.y = 0; + _up.z = 0; + - audio_debug("FMOD::System_Create()"); - result = FMOD::System_Create(&_system); - ERRCHECK(result); + audio_debug("FMOD::System_Create()"); + result = FMOD::System_Create(&_system); + ERRCHECK(result); - // Let check the Version of FMOD to make sure the Headers and Libraries are correct. - audio_debug("FMOD::System_Create()"); - result = _system->getVersion(&version); - ERRCHECK(result); + // Let check the Version of FMOD to make sure the Headers and Libraries are correct. + audio_debug("FMOD::System_Create()"); + result = _system->getVersion(&version); + ERRCHECK(result); - audio_debug("FMOD VERSION:" << hex << version ); - audio_debug("FMOD - Getting Version"); + audio_debug("FMOD VERSION:" << hex << version ); + audio_debug("FMOD - Getting Version"); - if (version < FMOD_VERSION){ - audio_debug("Error! You are using an old version of FMOD. This program requires:" << FMOD_VERSION); - } + if (version < FMOD_VERSION){ + audio_debug("Error! You are using an old version of FMOD. This program requires:" << FMOD_VERSION); + } - //Stick Surround Sound 5.1 thing Here. + //Stick Surround Sound 5.1 thing Here. - audio_debug("Checking for Surround Sound Flag.") + audio_debug("Checking for Surround Sound Flag."); - cerr << fmod_use_surround_sound << endl ; + if (fmod_use_surround_sound) { + audio_debug("Setting FMOD to use 5.1 Surround Sound."); + result = _system->setSpeakerMode( FMOD_SPEAKERMODE_5POINT1 ); + ERRCHECK(result); + } - if (fmod_use_surround_sound) { - audio_debug("Setting FMOD to use 5.1 Surround Sound.") - result = _system->setSpeakerMode( FMOD_SPEAKERMODE_5POINT1 ); - ERRCHECK(result); - } + //Now we Initialize the System. - //Now we Initialize the System. + audio_debug("FMOD::System_Init"); + result = _system->init(fmod_number_of_sound_channels, FMOD_INIT_NORMAL, 0); + ERRCHECK(result); - audio_debug("FMOD::System_Init"); - result = _system->init(fmod_number_of_sound_channels, FMOD_INIT_NORMAL, 0); - ERRCHECK(result); + if (result == FMOD_OK){ + audio_debug("FMOD Intialized OK, We are good to go Houston!"); + _is_valid = true; + } else { + audio_debug("Something is still wrong with FMOD! Check source."); + _is_valid = false; + } - if (result == FMOD_OK){ - audio_debug("FMOD Intialized OK, We are good to go Houston!"); - _is_valid = true; - } else { - audio_debug("Something is still wrong with FMOD! Check source."); - _is_valid = false; - } + // This sets the distance factor for 3D audio to use feet. + // FMOD uses meters by default. + // Since Panda use feet we need to compensate for that with a factor of 3.28 + // + // This can be over written. You just need to call + // audio_3d_set_distance_factor(float factor) and set you new factor. + + _doppler_factor = 1; + _distance_factor = 3.28; + _drop_off_factor = 1; - // This sets the distance factor for 3D audio to use feet. - // FMOD uses meters by default. - // Since Panda use feet we need to compensate for that with a factor of 3.28 - // - // This can be over written. You just need to call - // audio_3d_set_distance_factor(float factor) and set you new factor. - - _doppler_factor = 1; - _distance_factor = 3.28; - _drop_off_factor = 1; + audio_debug("Setting 3D Audio settings: Doppler Factor, Distance Factor, Drop Off Factor"); - audio_debug("Setting 3D Audio settings: Doppler Factor, Distance Factor, Drop Off Factor"); - - result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); - ERRCHECK( result ); + result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); + ERRCHECK( result ); } @@ -170,25 +169,26 @@ FmodAudioManager::FmodAudioManager() { // Access: Public // Description: DESTRCUTOR !!! //////////////////////////////////////////////////////////////////// -FmodAudioManager::~FmodAudioManager() { - // Be sure to delete associated sounds before deleting the manager! - audio_debug("~FmodAudioManager(): Closing Down"); +FmodAudioManager:: +~FmodAudioManager() { + // Be sure to delete associated sounds before deleting the manager! + audio_debug("~FmodAudioManager(): Closing Down"); - FMOD_RESULT result; + FMOD_RESULT result; - //Release DSPs First - _system_dsp.clear(); + //Release DSPs First + _system_dsp.clear(); - //Release Sounds Next - _all_sounds.clear(); + //Release Sounds Next + _all_sounds.clear(); - //result = _system->close(); - //ERRCHECK(result); + //result = _system->close(); + //ERRCHECK(result); - result = _system->release(); - ERRCHECK(result); + result = _system->release(); + ERRCHECK(result); - audio_debug("~FmodAudioManager(): System Down."); + audio_debug("~FmodAudioManager(): System Down."); } @@ -196,11 +196,12 @@ FmodAudioManager::~FmodAudioManager() { // Function: FmodAudioManager::is_valid // Access: Public // Description: This just check to make sure the FMOD System is -// up and running correctly. +// up and running correctly. //////////////////////////////////////////////////////////////////// -bool FmodAudioManager::is_valid() { - audio_debug("FmodAudioManager::is_valid() = " << _is_valid ); - return _is_valid; +bool FmodAudioManager:: +is_valid() { + audio_debug("FmodAudioManager::is_valid() = " << _is_valid ); + return _is_valid; } //////////////////////////////////////////////////////////////////// @@ -208,23 +209,24 @@ bool FmodAudioManager::is_valid() { // Access: Public // Description: This is what creates a sound instance. //////////////////////////////////////////////////////////////////// -PT(AudioSound) FmodAudioManager::get_sound(const string &file_name, bool positional) { +PT(AudioSound) FmodAudioManager:: +get_sound(const string &file_name, bool positional) { - audio_debug("FmodAudioManager::get_sound(file_name=\""<get_in_chain() ) { + if ( fdsp->get_in_chain() ) { - audio_debug("FmodAudioManager()::add_dsp"); - audio_debug("This DSP has already been assigned to the system or a sound."); + audio_debug("FmodAudioManager()::add_dsp"); + audio_debug("This DSP has already been assigned to the system or a sound."); - return false; + return false; - } else - { + } else + { - result = _system->addDSP( fdsp->_dsp ); - ERRCHECK( result ); + result = _system->addDSP( fdsp->_dsp ); + ERRCHECK( result ); - _system_dsp.insert(fdsp); + _system_dsp.insert(fdsp); - fdsp->set_in_chain(true); + fdsp->set_in_chain(true); - return true; - } + return true; + } } @@ -288,37 +291,37 @@ bool FmodAudioManager::add_dsp( PT(AudioDSP) x) { // Access: Published // Description: This removes the DSP from the Global Effect chain but does not destroy it. // Just remember a "Removed" DSP is still availible for use -// in another chain Global or a specific sound. +// in another chain Global or a specific sound. //////////////////////////////////////////////////////////////////// bool FmodAudioManager:: remove_dsp(PT(AudioDSP) x) { - // intentionally blank + // intentionally blank - FMOD_RESULT result; + FMOD_RESULT result; - FmodAudioDSP *fdsp; - DCAST_INTO_R(fdsp, x, false); + FmodAudioDSP *fdsp; + DCAST_INTO_R(fdsp, x, false); - if ( fdsp->get_in_chain() ) { + if ( fdsp->get_in_chain() ) { - result = fdsp->_dsp->remove(); - ERRCHECK( result ); + result = fdsp->_dsp->remove(); + ERRCHECK( result ); - _system_dsp.erase(fdsp); + _system_dsp.erase(fdsp); - fdsp->set_in_chain(false); + fdsp->set_in_chain(false); - return true; + return true; - } else - { + } else + { - audio_debug("FmodAudioManager()::remove_dsp()"); - audio_debug("This DSP doesn't exist in this chain."); + audio_debug("FmodAudioManager()::remove_dsp()"); + audio_debug("This DSP doesn't exist in this chain."); - return false; + return false; - } + } } @@ -330,85 +333,85 @@ remove_dsp(PT(AudioDSP) x) { //////////////////////////////////////////////////////////////////// int FmodAudioManager:: getSpeakerSetup() { - // intentionally blank + // intentionally blank - FMOD_RESULT result; - FMOD_SPEAKERMODE speakerMode; - int returnMode; + FMOD_RESULT result; + FMOD_SPEAKERMODE speakerMode; + int returnMode; - result = _system->getSpeakerMode( &speakerMode ); - ERRCHECK( result ); + result = _system->getSpeakerMode( &speakerMode ); + ERRCHECK( result ); - switch (speakerMode) { - case FMOD_SPEAKERMODE_RAW: - returnMode = 0; - break; - case FMOD_SPEAKERMODE_MONO: - returnMode = 1; - break; - case FMOD_SPEAKERMODE_STEREO: - returnMode = 2; - break; - case FMOD_SPEAKERMODE_QUAD: - returnMode = 3; - break; - case FMOD_SPEAKERMODE_SURROUND: - returnMode = 4; - break; - case FMOD_SPEAKERMODE_5POINT1: - returnMode = 5; - break; - case FMOD_SPEAKERMODE_7POINT1: - returnMode = 6; - break; - case FMOD_SPEAKERMODE_PROLOGIC: - returnMode = 7; - break; - case FMOD_SPEAKERMODE_MAX: - returnMode = 8; - break; - default: - returnMode = -1; - } + switch (speakerMode) { + case FMOD_SPEAKERMODE_RAW: + returnMode = 0; + break; + case FMOD_SPEAKERMODE_MONO: + returnMode = 1; + break; + case FMOD_SPEAKERMODE_STEREO: + returnMode = 2; + break; + case FMOD_SPEAKERMODE_QUAD: + returnMode = 3; + break; + case FMOD_SPEAKERMODE_SURROUND: + returnMode = 4; + break; + case FMOD_SPEAKERMODE_5POINT1: + returnMode = 5; + break; + case FMOD_SPEAKERMODE_7POINT1: + returnMode = 6; + break; + case FMOD_SPEAKERMODE_PROLOGIC: + returnMode = 7; + break; + case FMOD_SPEAKERMODE_MAX: + returnMode = 8; + break; + default: + returnMode = -1; + } - return returnMode; + return returnMode; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioManager::setSpeakerSetup() // Access: Published // Description: This is to set up FMOD to use a MultiChannel Setup. -// This method is pretty much useless. -// To set a speaker setup in FMOD for Surround Sound, -// stereo, or whatever you have to set the SpeakerMode -// BEFORE you Initialize FMOD. -// Since Panda Inits the FmodAudioManager right when you -// Start it up, you are never given an oppertunity to call -// this function. -// That is why I stuck a BOOL in the CONFIG.PRC file, whichs -// lets you flag if you want to use a Multichannel or not. -// That will set the speaker setup when an instance of this -// class is constructed. -// Still I put this here as a measure of good faith, since you -// can query the speaker setup after everything in Init. -// Also, maybe someone will completely hack Panda someday, in which -// one can init or re-init the AudioManagers after Panda is running. +// This method is pretty much useless. +// To set a speaker setup in FMOD for Surround Sound, +// stereo, or whatever you have to set the SpeakerMode +// BEFORE you Initialize FMOD. +// Since Panda Inits the FmodAudioManager right when you +// Start it up, you are never given an oppertunity to call +// this function. +// That is why I stuck a BOOL in the CONFIG.PRC file, whichs +// lets you flag if you want to use a Multichannel or not. +// That will set the speaker setup when an instance of this +// class is constructed. +// Still I put this here as a measure of good faith, since you +// can query the speaker setup after everything in Init. +// Also, maybe someone will completely hack Panda someday, in which +// one can init or re-init the AudioManagers after Panda is running. //////////////////////////////////////////////////////////////////// void FmodAudioManager:: setSpeakerSetup(AudioManager::SPEAKERMODE_category cat) { - // intentionally blank + // intentionally blank - audio_debug("FmodAudioSound::setSpeakerSetup() " ); + audio_debug("FmodAudioSound::setSpeakerSetup() " ); - //Local Variables that are needed. - FMOD_RESULT result; + //Local Variables that are needed. + FMOD_RESULT result; - FMOD_SPEAKERMODE speakerModeType = (FMOD_SPEAKERMODE)cat; + FMOD_SPEAKERMODE speakerModeType = (FMOD_SPEAKERMODE)cat; - result = _system->setSpeakerMode( speakerModeType); - ERRCHECK(result); + result = _system->setSpeakerMode( speakerModeType); + ERRCHECK(result); - audio_debug("Speaker Mode Set"); + audio_debug("Speaker Mode Set"); } @@ -416,37 +419,37 @@ setSpeakerSetup(AudioManager::SPEAKERMODE_category cat) { // Function: FmodAudioManager::set_volume(float volume) // Access: Public // Description: -// There isn't a specific system volume function in FMOD-EX, -// so this function is moot now. +// There isn't a specific system volume function in FMOD-EX, +// so this function is moot now. //////////////////////////////////////////////////////////////////// void FmodAudioManager::set_volume(float volume) { - audio_debug("FmodAudioManager::set_volume()" ); - audio_debug("This function has no effect in this version." ) - + audio_debug("FmodAudioManager::set_volume()" ); + audio_debug("This function has no effect in this version." ); } //////////////////////////////////////////////////////////////////// // Function: FmodAudioManager::get_volume() // Access: Public // Description: -// There isn't a specific system volume function in FMOD-EX, -// so this function is moot now. +// There isn't a specific system volume function in FMOD-EX, +// so this function is moot now. //////////////////////////////////////////////////////////////////// -float FmodAudioManager::get_volume() const { - audio_debug("FmodAudioManager::get_volume() returning "); - audio_debug("This function has no effect in this version." ) - return 0; +float FmodAudioManager:: +get_volume() const { + audio_debug("FmodAudioManager::get_volume() returning "); + audio_debug("This function has no effect in this version." ); + return 0; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioManager::set_active(bool active) // Access: Public // Description: Turn on/off -// Again, this function is pretty much moot in this version now. +// Again, this function is pretty much moot in this version now. //////////////////////////////////////////////////////////////////// -void FmodAudioManager::set_active(bool active) { - audio_debug("FmodAudioManager::set_active(flag="<stop(); - - } +void FmodAudioManager:: +stop_all_sounds() { + audio_debug("FmodAudioManager::stop_all_sounds()" ); + for (SoundSet::iterator i = _all_sounds.begin(); i != _all_sounds.end(); ++i) { + (*i)->stop(); + } } //////////////////////////////////////////////////////////////////// @@ -483,11 +484,12 @@ void FmodAudioManager::stop_all_sounds() { // positioned sounds. Normally, you'd want to call this // once per iteration of your main loop. //////////////////////////////////////////////////////////////////// -void FmodAudioManager::audio_3d_update() { - audio_debug("FmodAudioManager::audio_3d_update()"); - audio_debug("Calling FMOD's update function"); +void FmodAudioManager:: +audio_3d_update() { + audio_debug("FmodAudioManager::audio_3d_update()"); + audio_debug("Calling FMOD's update function"); - _system->update(); + _system->update(); } @@ -495,40 +497,41 @@ void FmodAudioManager::audio_3d_update() { // Function: FmodAudioManager::audio_3d_set_listener_attributes // Access: Public // Description: Set position of the "ear" that picks up 3d sounds -// NOW LISTEN UP!!! THIS IS IMPORTANT! -// Both Panda3D and FMOD use a left handed coordinate system. -// But there is a major difference! -// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. -// In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. -// The solution is simple, we just flip the Y and Z axis, as we move coordinates -// from Panda to FMOD and back. -// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. -// But if you decide to do any 3D audio work in here you have to keep it in mind. -// I told you, so you can't say I didn't. +// NOW LISTEN UP!!! THIS IS IMPORTANT! +// Both Panda3D and FMOD use a left handed coordinate system. +// But there is a major difference! +// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. +// In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. +// The solution is simple, we just flip the Y and Z axis, as we move coordinates +// from Panda to FMOD and back. +// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. +// But if you decide to do any 3D audio work in here you have to keep it in mind. +// I told you, so you can't say I didn't. //////////////////////////////////////////////////////////////////// -void FmodAudioManager::audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) { - audio_debug("FmodAudioManager::audio_3d_set_listener_attributes()"); +void FmodAudioManager:: +audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) { + audio_debug("FmodAudioManager::audio_3d_set_listener_attributes()"); - FMOD_RESULT result; - - _position.x = px; - _position.y = pz; - _position.z = py; + FMOD_RESULT result; + + _position.x = px; + _position.y = pz; + _position.z = py; - _velocity.x = vx; - _velocity.y = vz; - _velocity.z = vy; + _velocity.x = vx; + _velocity.y = vz; + _velocity.z = vy; - _forward.x = fx; - _forward.y = fz; - _forward.z = fy; + _forward.x = fx; + _forward.y = fz; + _forward.z = fy; - _up.x = ux; - _up.y = uz; - _up.z = uy; - - result = _system->set3DListenerAttributes( 0, &_position, &_velocity, &_forward, &_up); - ERRCHECK( result ); + _up.x = ux; + _up.y = uz; + _up.z = uy; + + result = _system->set3DListenerAttributes( 0, &_position, &_velocity, &_forward, &_up); + ERRCHECK( result ); } @@ -537,8 +540,9 @@ void FmodAudioManager::audio_3d_set_listener_attributes(float px, float py, floa // Access: Public // Description: Get position of the "ear" that picks up 3d sounds //////////////////////////////////////////////////////////////////// -void FmodAudioManager::audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) { - audio_error("audio3dGetListenerAttributes: currently unimplemented. Get the attributes of the attached object"); +void FmodAudioManager:: +audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) { + audio_error("audio3dGetListenerAttributes: currently unimplemented. Get the attributes of the attached object"); } @@ -549,15 +553,16 @@ void FmodAudioManager::audio_3d_get_listener_attributes(float *px, float *py, fl // Description: Set units per meter (Fmod uses meters internally for // its sound-spacialization calculations) //////////////////////////////////////////////////////////////////// -void FmodAudioManager::audio_3d_set_distance_factor(float factor) { - audio_debug( "FmodAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")" ); - - FMOD_RESULT result; +void FmodAudioManager:: +audio_3d_set_distance_factor(float factor) { + audio_debug( "FmodAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")" ); + + FMOD_RESULT result; - _distance_factor = factor; + _distance_factor = factor; - result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); - ERRCHECK( result ); + result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); + ERRCHECK( result ); } @@ -568,10 +573,11 @@ void FmodAudioManager::audio_3d_set_distance_factor(float factor) { // Description: Gets units per meter (Fmod uses meters internally for // its sound-spacialization calculations) //////////////////////////////////////////////////////////////////// -float FmodAudioManager::audio_3d_get_distance_factor() const { - audio_debug("FmodAudioManager::audio_3d_get_distance_factor()"); +float FmodAudioManager:: +audio_3d_get_distance_factor() const { + audio_debug("FmodAudioManager::audio_3d_get_distance_factor()"); - return _distance_factor; + return _distance_factor; } //////////////////////////////////////////////////////////////////// @@ -580,15 +586,16 @@ float FmodAudioManager::audio_3d_get_distance_factor() const { // Description: Exaggerates or diminishes the Doppler effect. // Defaults to 1.0 //////////////////////////////////////////////////////////////////// -void FmodAudioManager::audio_3d_set_doppler_factor(float factor) { - audio_debug("FmodAudioManager::audio_3d_set_doppler_factor(factor="<set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); - ERRCHECK( result ); + result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); + ERRCHECK( result ); } @@ -597,10 +604,11 @@ void FmodAudioManager::audio_3d_set_doppler_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float FmodAudioManager::audio_3d_get_doppler_factor() const { - audio_debug("FmodAudioManager::audio_3d_get_doppler_factor()"); +float FmodAudioManager:: +audio_3d_get_doppler_factor() const { + audio_debug("FmodAudioManager::audio_3d_get_doppler_factor()"); - return _doppler_factor; + return _doppler_factor; } //////////////////////////////////////////////////////////////////// @@ -609,15 +617,16 @@ float FmodAudioManager::audio_3d_get_doppler_factor() const { // Description: Control the effect distance has on audability. // Defaults to 1.0 //////////////////////////////////////////////////////////////////// -void FmodAudioManager::audio_3d_set_drop_off_factor(float factor) { - audio_debug("FmodAudioManager::audio_3d_set_drop_off_factor("<set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); - ERRCHECK( result ); + result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); + ERRCHECK( result ); } @@ -626,10 +635,11 @@ void FmodAudioManager::audio_3d_set_drop_off_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float FmodAudioManager::audio_3d_get_drop_off_factor() const { - audio_debug("FmodAudioManager::audio_3d_get_drop_off_factor()"); +float FmodAudioManager:: +audio_3d_get_drop_off_factor() const { + audio_debug("FmodAudioManager::audio_3d_get_drop_off_factor()"); - return _drop_off_factor; + return _drop_off_factor; } @@ -640,7 +650,8 @@ float FmodAudioManager::audio_3d_get_drop_off_factor() const { // Access: Public // Description: NOT USED FOR FMOD-EX!!! //////////////////////////////////////////////////////////////////// -void FmodAudioManager::set_concurrent_sound_limit(unsigned int limit) { +void FmodAudioManager:: +set_concurrent_sound_limit(unsigned int limit) { } @@ -649,8 +660,9 @@ void FmodAudioManager::set_concurrent_sound_limit(unsigned int limit) { // Access: Public // Description: NOT USED FOR FMOD-EX!!! //////////////////////////////////////////////////////////////////// -unsigned int FmodAudioManager::get_concurrent_sound_limit() const { - return 0; +unsigned int FmodAudioManager:: +get_concurrent_sound_limit() const { + return 1000000; } //////////////////////////////////////////////////////////////////// @@ -658,7 +670,8 @@ unsigned int FmodAudioManager::get_concurrent_sound_limit() const { // Access: Private // Description: NOT USED FOR FMOD-EX!!! //////////////////////////////////////////////////////////////////// -void FmodAudioManager::reduce_sounds_playing_to(unsigned int count) { +void FmodAudioManager:: +reduce_sounds_playing_to(unsigned int count) { } @@ -667,10 +680,11 @@ void FmodAudioManager::reduce_sounds_playing_to(unsigned int count) { // Function: FmodAudioManager::uncache_sound // Access: Public // Description: NOT USED FOR FMOD-EX!!! -// Clears a sound out of the sound cache. +// Clears a sound out of the sound cache. //////////////////////////////////////////////////////////////////// -void FmodAudioManager::uncache_sound(const string& file_name) { - audio_debug("FmodAudioManager::uncache_sound(\""<_system->getSpeakerMode( &_speakermode ); - ERRCHECK(result); + //Get the Speaker Mode [Important for later on.] + result = _manager->_system->getSpeakerMode( &_speakermode ); + ERRCHECK(result); - if (positional == true) { - - result = _manager->_system->createSound( file_name.c_str(), FMOD_SOFTWARE | FMOD_3D , 0, &_sound); - ERRCHECK(result); + if (positional == true) { + + result = _manager->_system->createSound( file_name.c_str(), FMOD_SOFTWARE | FMOD_3D , 0, &_sound); + ERRCHECK(result); - //This is just to collect the defaults of the sound, so we don't - //Have to query FMOD everytime for the info. - //It is also important we get the '_sampleFrequency' variable here, for the - //'set_play_rate()' and 'get_play_rate()' methods later; - - result = _sound->getDefaults( &_sampleFrequency, &_volume , &_balance, &_priority); - ERRCHECK(result); + //This is just to collect the defaults of the sound, so we don't + //Have to query FMOD everytime for the info. + //It is also important we get the '_sampleFrequency' variable here, for the + //'set_play_rate()' and 'get_play_rate()' methods later; + + result = _sound->getDefaults( &_sampleFrequency, &_volume , &_balance, &_priority); + ERRCHECK(result); - audio_debug("Sound loaded as 3D"); + audio_debug("Sound loaded as 3D"); - } else { + } else { - result = _manager->_system->createSound( file_name.c_str(), FMOD_SOFTWARE | FMOD_2D , 0, &_sound); - ERRCHECK(result); - - //This is just to collect the defaults of the sound, so we don't - //Have to query FMOD everytime for the info. - //It is also important we get the '_sampleFrequency' variable here, for the - //'set_play_rate()' and 'get_play_rate()' methods later; + result = _manager->_system->createSound( file_name.c_str(), FMOD_SOFTWARE | FMOD_2D , 0, &_sound); + ERRCHECK(result); + + //This is just to collect the defaults of the sound, so we don't + //Have to query FMOD everytime for the info. + //It is also important we get the '_sampleFrequency' variable here, for the + //'set_play_rate()' and 'get_play_rate()' methods later; - result = _sound->getDefaults( &_sampleFrequency, &_volume , &_balance, &_priority); - ERRCHECK(result); + result = _sound->getDefaults( &_sampleFrequency, &_volume , &_balance, &_priority); + ERRCHECK(result); - audio_debug("Sound loaded as 2D"); - - } + audio_debug("Sound loaded as 2D"); + } } @@ -119,23 +119,24 @@ FmodAudioSound::FmodAudioSound(AudioManager *manager, string file_name, bool pos // Access: public // Description: DESTRUCTOR!!! //////////////////////////////////////////////////////////////////// -FmodAudioSound::~FmodAudioSound() { +FmodAudioSound:: +~FmodAudioSound() { - audio_debug("FmodAudioSound::~FmodAudioSound() Closing this Sound Instance Down."); + audio_debug("FmodAudioSound::~FmodAudioSound() Closing this Sound Instance Down."); - FMOD_RESULT result; + FMOD_RESULT result; - //Remove me from table of all sounds. - _manager->_all_sounds.erase(this); + //Remove me from table of all sounds. + _manager->_all_sounds.erase(this); - //Release DSPs First - _sound_dsp.clear(); + //Release DSPs First + _sound_dsp.clear(); - //The Release Sound - result = _sound->release(); - ERRCHECK(result); + //The Release Sound + result = _sound->release(); + ERRCHECK(result); - audio_debug("FmodAudioSound::~FmodAudioSound() FMOD Sound Released and Closed."); + audio_debug("FmodAudioSound::~FmodAudioSound() FMOD Sound Released and Closed."); } @@ -144,83 +145,84 @@ FmodAudioSound::~FmodAudioSound() { // Function: FmodAudioSound:: play // Access: public // Description: Plays a sound. -// OK when you play a Sound a couple of things are going -// to happen. -// First Panda is going to check if the sound is in a pause -// State because of if a 'set_time()' has been called on the sound. -// Second, remember when I said channels don't exist unless a sound, -// is playing on them? Well they don't and therefore any associated -// DSP, looping, playback rate, pan, volume, or 3D information associated with -// that sound is not going to be known by that channel either. -// So all we do, is load a sound on a channel PAUSED. -// While the sound is paused, it sets up all the sound attributes, and -// then plays the sound. This all happens really fast, so you should -// notice a hit. -// And yes this is the FMOD way of doing things. -// -// The biggest problem with this comes when you are 'looping' sounds. -// In the 'prepare2DSound()' and prepare3DSound' [private methods -// which set up their respected type of sounds], I had to impliment the -// 'FMOD_CHANNEL_REUSE' flag. -// Remember back in the header file, where I said there is only one dedicated, -// Channel for each sound, where there is a reason for that. -// If you were to use 'FMOD_CHANNEL_FREE' each time you played a sound, -// FMOD would grab the first available channel and play the sound on that. -// This is bad for Panda because the FmodAudioSound class is only set up to -// remember only channel at a time. If we play a sound that is set to loop, and -// then trigger that sound to loop again, the reference to the Channel Object for a particular -// sound is replaced with the new, instance of the loop. Thus the previous sound keeps playing -// forever because we have lost the reference to it. -// But using the 'FMOD_CHANNEL_REUSE' flag, we avoid this problem, because the new call to play -// the looping sound will, play the sound on the previous allocated channel. -// The only to downside to this, is that playing a looping sound a second time, will cause the -// Previous instance to be cut off. +// OK when you play a Sound a couple of things are going +// to happen. +// First Panda is going to check if the sound is in a pause +// State because of if a 'set_time()' has been called on the sound. +// Second, remember when I said channels don't exist unless a sound, +// is playing on them? Well they don't and therefore any associated +// DSP, looping, playback rate, pan, volume, or 3D information associated with +// that sound is not going to be known by that channel either. +// So all we do, is load a sound on a channel PAUSED. +// While the sound is paused, it sets up all the sound attributes, and +// then plays the sound. This all happens really fast, so you should +// notice a hit. +// And yes this is the FMOD way of doing things. +// +// The biggest problem with this comes when you are 'looping' sounds. +// In the 'prepare2DSound()' and prepare3DSound' [private methods +// which set up their respected type of sounds], I had to impliment the +// 'FMOD_CHANNEL_REUSE' flag. +// Remember back in the header file, where I said there is only one dedicated, +// Channel for each sound, where there is a reason for that. +// If you were to use 'FMOD_CHANNEL_FREE' each time you played a sound, +// FMOD would grab the first available channel and play the sound on that. +// This is bad for Panda because the FmodAudioSound class is only set up to +// remember only channel at a time. If we play a sound that is set to loop, and +// then trigger that sound to loop again, the reference to the Channel Object for a particular +// sound is replaced with the new, instance of the loop. Thus the previous sound keeps playing +// forever because we have lost the reference to it. +// But using the 'FMOD_CHANNEL_REUSE' flag, we avoid this problem, because the new call to play +// the looping sound will, play the sound on the previous allocated channel. +// The only to downside to this, is that playing a looping sound a second time, will cause the +// Previous instance to be cut off. // -// Honestly, it should be easy to create a work around for this. So you could -// use the 'FMOD_CHANNEL_FREE' which will prevent the cutoff program, by creating -// a set, that keeps track of channels playing the same looping sound, when the sound is looping -// [or is really long, another possible scenerio for this problem]. -// -// But honestly the cutoff shouldn't be a big problem, in most cases. -// I just wanted to explain my reasoning here. -// +// Honestly, it should be easy to create a work around for this. So you could +// use the 'FMOD_CHANNEL_FREE' which will prevent the cutoff program, by creating +// a set, that keeps track of channels playing the same looping sound, when the sound is looping +// [or is really long, another possible scenerio for this problem]. +// +// But honestly the cutoff shouldn't be a big problem, in most cases. +// I just wanted to explain my reasoning here. +// //////////////////////////////////////////////////////////////////// -void FmodAudioSound::play() { - - audio_debug("FmodAudioSound::play() Going to play a sound." ); +void FmodAudioSound:: +play() { + + audio_debug("FmodAudioSound::play() Going to play a sound." ); - FMOD_RESULT result; - bool paused = 0; + FMOD_RESULT result; + bool paused = 0; - result = _channel->getPaused(&paused); - ERRCHECK(result); + result = _channel->getPaused(&paused); + ERRCHECK(result); - if ( paused ) { + if ( paused ) { - set_volume_on_channel(); - set_play_rate_on_channel(); - set_speaker_mix_or_balance_on_channel(); - add_dsp_on_channel(); + set_volume_on_channel(); + set_play_rate_on_channel(); + set_speaker_mix_or_balance_on_channel(); + add_dsp_on_channel(); - result = _channel->setPaused(false); - ERRCHECK(result); + result = _channel->setPaused(false); + ERRCHECK(result); - } else { + } else { - prepareSound(); + prepareSound(); - set_volume_on_channel(); - set_play_rate_on_channel(); - set_speaker_mix_or_balance_on_channel();; - add_dsp_on_channel(); + set_volume_on_channel(); + set_play_rate_on_channel(); + set_speaker_mix_or_balance_on_channel();; + add_dsp_on_channel(); - result = _channel->setPaused(false); - ERRCHECK(result); + result = _channel->setPaused(false); + ERRCHECK(result); - } + } - audio_debug("FmodAudioSound::play() Sound should be playing (or played if it is really short)." ); + audio_debug("FmodAudioSound::play() Sound should be playing (or played if it is really short)." ); } @@ -230,28 +232,29 @@ void FmodAudioSound::play() { // Access: Private // Description: Prepares a sound [GENERAL] //////////////////////////////////////////////////////////////////// -void FmodAudioSound::prepareSound() { - - audio_debug("FmodAudioSound::prepareSound()" ); +void FmodAudioSound:: +prepareSound() { + + audio_debug("FmodAudioSound::prepareSound()" ); - FMOD_RESULT result; - bool paused = 0; - FMOD_MODE soundMode; + FMOD_RESULT result; + bool paused = 0; + FMOD_MODE soundMode; - audio_debug("FmodAudioSound::play() Going to perpare a sound." ); + audio_debug("FmodAudioSound::play() Going to perpare a sound." ); - result = _sound->getMode(&soundMode); - ERRCHECK(result); + result = _sound->getMode(&soundMode); + ERRCHECK(result); - if ( ( soundMode & FMOD_3D ) > 0 ) { + if ( ( soundMode & FMOD_3D ) > 0 ) { - prepare3DSound(); - - } else { - - prepare2DSound(); + prepare3DSound(); + + } else { + + prepare2DSound(); - } + } } @@ -259,22 +262,23 @@ void FmodAudioSound::prepareSound() { // Function: FmodAudioSound::prepare2DSound // Access: Private // Description: Prepares a 2D sound. -// We need seperate 3D and 2D play commands, because of -// the way FMOD sets the 3D Attributes to the 'channel' a -// sound is playing on. -// Since a 'channel' is initialize when a sound is set to -// play to one, and then subsiquenctly destroyed once the -// sound is finished playing. -// +// We need seperate 3D and 2D play commands, because of +// the way FMOD sets the 3D Attributes to the 'channel' a +// sound is playing on. +// Since a 'channel' is initialize when a sound is set to +// play to one, and then subsiquenctly destroyed once the +// sound is finished playing. +// //////////////////////////////////////////////////////////////////// -void FmodAudioSound::prepare2DSound() { - - audio_debug("FmodAudioSound::prepare2DSound()" ); +void FmodAudioSound:: +prepare2DSound() { + + audio_debug("FmodAudioSound::prepare2DSound()" ); - FMOD_RESULT result; + FMOD_RESULT result; - result = _manager->_system->playSound(FMOD_CHANNEL_REUSE, _sound, true, &_channel); - ERRCHECK(result); + result = _manager->_system->playSound(FMOD_CHANNEL_REUSE, _sound, true, &_channel); + ERRCHECK(result); } @@ -282,25 +286,26 @@ void FmodAudioSound::prepare2DSound() { // Function: FmodAudioSound::prepare3DSound // Access: Private // Description: Prepares a 3D sound -// We need seperate 3D and 2D play commands, because of -// the way FMOD sets the 3D Attributes to the 'channel' a -// sound is playing on. -// Since a 'channel' is initialize when a sound is set to -// play to one, and then subsiquenctly destroyed once the -// sound is finished playing. -// +// We need seperate 3D and 2D play commands, because of +// the way FMOD sets the 3D Attributes to the 'channel' a +// sound is playing on. +// Since a 'channel' is initialize when a sound is set to +// play to one, and then subsiquenctly destroyed once the +// sound is finished playing. +// //////////////////////////////////////////////////////////////////// -void FmodAudioSound::prepare3DSound() { - - audio_debug("FmodAudioSound::prepare2DSound()" ); +void FmodAudioSound:: +prepare3DSound() { + + audio_debug("FmodAudioSound::prepare2DSound()" ); - FMOD_RESULT result; + FMOD_RESULT result; - result = _manager->_system->playSound(FMOD_CHANNEL_REUSE, _sound, true, &_channel); - ERRCHECK(result); + result = _manager->_system->playSound(FMOD_CHANNEL_REUSE, _sound, true, &_channel); + ERRCHECK(result); - result = _channel->set3DAttributes( &_location, &_velocity ); - ERRCHECK(result); + result = _channel->set3DAttributes( &_location, &_velocity ); + ERRCHECK(result); } @@ -311,18 +316,17 @@ void FmodAudioSound::prepare3DSound() { // Access: public // Description: Stop a sound //////////////////////////////////////////////////////////////////// -void FmodAudioSound::stop() { +void FmodAudioSound:: +stop() { + audio_debug("FmodAudioSound::stop() Going to stop a sound." ); - audio_debug("FmodAudioSound::stop() Going to stop a sound." ); + //LOCALS + FMOD_RESULT result; - //LOCALS - FMOD_RESULT result; - - result = _channel->stop(); - ERRCHECK(result); - - audio_debug("FmodAudioSound::stop() Sound should be stopped."); + result = _channel->stop(); + ERRCHECK(result); + audio_debug("FmodAudioSound::stop() Sound should be stopped."); } @@ -332,23 +336,20 @@ void FmodAudioSound::stop() { // Access: public // Description: Turns looping on and off //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_loop(bool loop) { - - audio_debug("FmodAudioSound::set_loop() Setting loop state to " << loop); - - FMOD_RESULT result; - - if ( loop ) { - result = _sound->setMode(FMOD_LOOP_NORMAL); - ERRCHECK(result); - audio_debug("This sound is set to loop." ); - - } else { - result = _sound->setMode(FMOD_LOOP_OFF); - ERRCHECK(result); - audio_debug("FmodAudioSound::set_loop() This sound is set to one-shot." ); - } +void FmodAudioSound:: +set_loop(bool loop) { + audio_debug("FmodAudioSound::set_loop() Setting loop state to " << loop); + FMOD_RESULT result; + if ( loop ) { + result = _sound->setMode(FMOD_LOOP_NORMAL); + ERRCHECK(result); + audio_debug("This sound is set to loop." ); + } else { + result = _sound->setMode(FMOD_LOOP_OFF); + ERRCHECK(result); + audio_debug("FmodAudioSound::set_loop() This sound is set to one-shot." ); + } } //////////////////////////////////////////////////////////////////// @@ -356,60 +357,61 @@ void FmodAudioSound::set_loop(bool loop) { // Access: public // Description: Returns whether looping is on or off //////////////////////////////////////////////////////////////////// -bool FmodAudioSound::get_loop() const { - - audio_debug( "FmodAudioSound::get_loop() Retreiving a sound's loop state." ); - - // 0 means loop forever, - // >1 means loop that many times - // So _loop_count != 1 means we're looping +bool FmodAudioSound:: +get_loop() const { + + audio_debug( "FmodAudioSound::get_loop() Retreiving a sound's loop state." ); + + // 0 means loop forever, + // >1 means loop that many times + // So _loop_count != 1 means we're looping - FMOD_RESULT result; - FMOD_MODE loopMode; - bool loopState; + FMOD_RESULT result; + FMOD_MODE loopMode; + bool loopState; - result = _sound->getMode( &loopMode ); - ERRCHECK(result); + result = _sound->getMode( &loopMode ); + ERRCHECK(result); - if ( (loopMode & FMOD_LOOP_NORMAL) != 0 ) { - loopState = true; - } else { - loopState = false; - } + if ( (loopMode & FMOD_LOOP_NORMAL) != 0 ) { + loopState = true; + } else { + loopState = false; + } - return (loopState); + return (loopState); } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_loop_count // Access: public // Description: -// Panda uses 0 to mean loop forever. -// Fmod uses negative numbers to mean loop forever. -// (0 means don't loop, 1 means play twice, etc. -// We must convert! +// Panda uses 0 to mean loop forever. +// Fmod uses negative numbers to mean loop forever. +// (0 means don't loop, 1 means play twice, etc. +// We must convert! //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_loop_count(unsigned long loop_count) { +void FmodAudioSound:: +set_loop_count(unsigned long loop_count) { - audio_debug("FmodAudioSound::set_loop_count() Setting the sound's loop count to: " << loop_count); + audio_debug("FmodAudioSound::set_loop_count() Setting the sound's loop count to: " << loop_count); - //LOCALS - FMOD_RESULT result; - int numberOfLoops; + //LOCALS + FMOD_RESULT result; + int numberOfLoops; - numberOfLoops = (int) loop_count; - numberOfLoops = numberOfLoops - 1; + numberOfLoops = (int) loop_count; + numberOfLoops = numberOfLoops - 1; - if (numberOfLoops == 0) { - result = _sound->setLoopCount( -1 ); - ERRCHECK(result); - } else { - result = _sound->setLoopCount( numberOfLoops ); - ERRCHECK(result); - } - - audio_debug("FmodAudioSound::set_loop_count() Sound's loop count should be set to: " << loop_count); + if (numberOfLoops == 0) { + result = _sound->setLoopCount( -1 ); + ERRCHECK(result); + } else { + result = _sound->setLoopCount( numberOfLoops ); + ERRCHECK(result); + } + audio_debug("FmodAudioSound::set_loop_count() Sound's loop count should be set to: " << loop_count); } //////////////////////////////////////////////////////////////////// @@ -417,22 +419,23 @@ void FmodAudioSound::set_loop_count(unsigned long loop_count) { // Access: public // Description: Return how many times a sound will loop. //////////////////////////////////////////////////////////////////// -unsigned long FmodAudioSound::get_loop_count() const { +unsigned long FmodAudioSound:: +get_loop_count() const { - audio_debug("FmodAudioSound::get_loop_count() Getting the sound's loop count. "); + audio_debug("FmodAudioSound::get_loop_count() Getting the sound's loop count. "); - FMOD_RESULT result; - int loop_count; - unsigned long returnedNumber; + FMOD_RESULT result; + int loop_count; + unsigned long returnedNumber; - result = _sound->getLoopCount( &loop_count ); - ERRCHECK(result); + result = _sound->getLoopCount( &loop_count ); + ERRCHECK(result); - audio_debug("FmodAudioSound::get_loop_count() returning "<< loop_count); + audio_debug("FmodAudioSound::get_loop_count() returning "<< loop_count); - returnedNumber = (unsigned long) loop_count; + returnedNumber = (unsigned long) loop_count; - return loop_count; + return loop_count; } //////////////////////////////////////////////////////////////////// @@ -440,21 +443,22 @@ unsigned long FmodAudioSound::get_loop_count() const { // Access: public // Description: Sets the play position within the sound //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_time(float start_time) { - - FMOD_RESULT result; - audio_debug("FmodAudioSound::set_time() Going to set a sounds start position" ); +void FmodAudioSound:: +set_time(float start_time) { + + FMOD_RESULT result; + audio_debug("FmodAudioSound::set_time() Going to set a sounds start position" ); - unsigned int startTime; + unsigned int startTime; - //We must 'prepareSound()' [set it to play on a channel] so - //we can set its start time. - prepareSound(); + //We must 'prepareSound()' [set it to play on a channel] so + //we can set its start time. + prepareSound(); - startTime = start_time * 1000; + startTime = start_time * 1000; - result = _channel->setPosition( startTime , FMOD_TIMEUNIT_MS ); - ERRCHECK(result); + result = _channel->setPosition( startTime , FMOD_TIMEUNIT_MS ); + ERRCHECK(result); } @@ -463,20 +467,19 @@ void FmodAudioSound::set_time(float start_time) { // Access: public // Description: Gets the play position within the sound //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_time() const { - - audio_debug("FmodAudioSound::get_time() Going to get a sound's position" ); +float FmodAudioSound:: +get_time() const { + audio_debug("FmodAudioSound::get_time() Going to get a sound's position" ); - FMOD_RESULT result; - unsigned int current_time; + FMOD_RESULT result; + unsigned int current_time; - result = _channel->getPosition( ¤t_time , FMOD_TIMEUNIT_MS ); - ERRCHECK(result); + result = _channel->getPosition( ¤t_time , FMOD_TIMEUNIT_MS ); + ERRCHECK(result); - current_time = current_time / 1000; - - return current_time; + current_time = current_time / 1000; + return current_time; } //////////////////////////////////////////////////////////////////// @@ -485,19 +488,19 @@ float FmodAudioSound::get_time() const { // Description: 0.0 to 1.0 scale of volume converted to Fmod's // internal 0.0 to 255.0 scale. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_volume(float vol) { - - audio_debug("FmodAudioSound::set_volume() Going to set a sounds volume." ); +void FmodAudioSound:: +set_volume(float vol) { + + audio_debug("FmodAudioSound::set_volume() Going to set a sounds volume." ); - FMOD_RESULT result; + FMOD_RESULT result; - _volume = vol; + _volume = vol; - result = _channel->setVolume( _volume ); - ERRCHECK(result); - - audio_debug("FmodAudioSound::set_volume() Setting volume to " << vol); + result = _channel->setVolume( _volume ); + ERRCHECK(result); + audio_debug("FmodAudioSound::set_volume() Setting volume to " << vol); } //////////////////////////////////////////////////////////////////// @@ -505,17 +508,16 @@ void FmodAudioSound::set_volume(float vol) { // Access: Private // Description: Set the volume on a prepared Sound channel. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_volume_on_channel() { - - audio_debug("FmodAudioSound::set_volume() Going to set a sounds volume." ); +void FmodAudioSound:: +set_volume_on_channel() { + audio_debug("FmodAudioSound::set_volume() Going to set a sounds volume." ); - FMOD_RESULT result; + FMOD_RESULT result; - result = _channel->setVolume( _volume ); - ERRCHECK(result); - - audio_debug("FmodAudioSound::set_volume() Setting volume to " << _volume ); + result = _channel->setVolume( _volume ); + ERRCHECK(result); + audio_debug("FmodAudioSound::set_volume() Setting volume to " << _volume ); } //////////////////////////////////////////////////////////////////// @@ -523,11 +525,12 @@ void FmodAudioSound::set_volume_on_channel() { // Access: public // Description: Gets the current volume of a sound. 1 is Max. O is Min. //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_volume() const { +float FmodAudioSound:: +get_volume() const { - audio_debug("FmodAudioSound::get_volume() Going to get a sound's volume." ); + audio_debug("FmodAudioSound::get_volume() Going to get a sound's volume." ); - return _volume; + return _volume; } //////////////////////////////////////////////////////////////////// @@ -535,89 +538,89 @@ float FmodAudioSound::get_volume() const { // Access: public // Description: -1.0 to 1.0 scale //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_balance(float bal) { - - audio_debug("FmodAudioSound::set_balance() Going to set a sound's balance." ); +void FmodAudioSound:: +set_balance(float bal) { + audio_debug("FmodAudioSound::set_balance() Going to set a sound's balance." ); - FMOD_RESULT result; + FMOD_RESULT result; - _balance = bal; + _balance = bal; - result = _sound->setDefaults( _sampleFrequency, _volume , _balance, _priority); - ERRCHECK(result); + result = _sound->setDefaults( _sampleFrequency, _volume , _balance, _priority); + ERRCHECK(result); - result = _channel->setPan( _balance ); - ERRCHECK(result); - - audio_debug("FmodAudioSound::set_balance() Setting Pan to " << bal); + result = _channel->setPan( _balance ); + ERRCHECK(result); + audio_debug("FmodAudioSound::set_balance() Setting Pan to " << bal); } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_balance_on_channel() // Access: public // Description: -1.0 to 1.0 scale Set the pan on a prepared Sound channel. -// -1 should be all the way left. -// 1 is all the way to the right. +// -1 should be all the way left. +// 1 is all the way to the right. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_balance_on_channel() { - - audio_debug("FmodAudioSound::set_balance() Going to set a sound's balance to " << _balance ); +void FmodAudioSound:: +set_balance_on_channel() { + + audio_debug("FmodAudioSound::set_balance() Going to set a sound's balance to " << _balance ); - FMOD_RESULT result; + FMOD_RESULT result; - result = _channel->setPan( _balance ); - ERRCHECK(result); - - audio_debug("FmodAudioSound::set_balance() Setting Pan to " << _balance); + result = _channel->setPan( _balance ); + ERRCHECK(result); + audio_debug("FmodAudioSound::set_balance() Setting Pan to " << _balance); } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::get_balance // Access: public // Description: -1.0 to 1.0 scale -// -1 should be all the way left. -// 1 is all the way to the right. +// -1 should be all the way left. +// 1 is all the way to the right. //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_balance() const { - - audio_debug("FmodAudioSound::get_balance() Going to get a sound's balance." ); +float FmodAudioSound:: +get_balance() const { + + audio_debug("FmodAudioSound::get_balance() Going to get a sound's balance." ); - return _balance; + return _balance; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_play_rate(float rate) // Access: public // Description: Sets the speed at which a sound plays back. -// The rate is a multiple of the sound, normal playback speed. -// IE 2 would play back 2 times fast, 3 would play 3 times, and so on. -// This can also be set to a negative number so a sound plays backwards. -// But rememeber if the sound is not playing, you must set the -// sound's time to its end to hear a song play backwards. +// The rate is a multiple of the sound, normal playback speed. +// IE 2 would play back 2 times fast, 3 would play 3 times, and so on. +// This can also be set to a negative number so a sound plays backwards. +// But rememeber if the sound is not playing, you must set the +// sound's time to its end to hear a song play backwards. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_play_rate(float rate) { - audio_debug("FmodAudioSound::set_play_rate() Going to set a sound's play rate to " << rate); +void FmodAudioSound:: +set_play_rate(float rate) { + audio_debug("FmodAudioSound::set_play_rate() Going to set a sound's play rate to " << rate); - FMOD_RESULT result; - float frequencyToSetChannelTo; + FMOD_RESULT result; + float frequencyToSetChannelTo; - _playrate = rate; + _playrate = rate; - if (rate == 1) { - result = _channel->setFrequency( _sampleFrequency ); - ERRCHECK(result); - } else { - frequencyToSetChannelTo = _sampleFrequency * rate ; - - result = _channel->setFrequency( frequencyToSetChannelTo ); - ERRCHECK(result); - - } - - audio_debug("FmodAudioSound::set_play_rate() Sound's balance set to " << rate); + if (rate == 1) { + result = _channel->setFrequency( _sampleFrequency ); + ERRCHECK(result); + } else { + frequencyToSetChannelTo = _sampleFrequency * rate ; + result = _channel->setFrequency( frequencyToSetChannelTo ); + ERRCHECK(result); + + } + + audio_debug("FmodAudioSound::set_play_rate() Sound's balance set to " << rate); } //////////////////////////////////////////////////////////////////// @@ -625,24 +628,25 @@ void FmodAudioSound::set_play_rate(float rate) { // Access: public // Description: Set the play rate on a prepared Sound channel. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_play_rate_on_channel() { - audio_debug("FmodAudioSound::set_play_rate() Going to set a sound's balance to " << _playrate); +void FmodAudioSound:: +set_play_rate_on_channel() { + audio_debug("FmodAudioSound::set_play_rate() Going to set a sound's balance to " << _playrate); - FMOD_RESULT result; - float frequencyToSetChannelTo; + FMOD_RESULT result; + float frequencyToSetChannelTo; - if ( _playrate == 1) { - result = _channel->setFrequency( _sampleFrequency ); - ERRCHECK(result); - } else { - frequencyToSetChannelTo = _sampleFrequency * _playrate ; + if ( _playrate == 1) { + result = _channel->setFrequency( _sampleFrequency ); + ERRCHECK(result); + } else { + frequencyToSetChannelTo = _sampleFrequency * _playrate ; - result = _channel->setFrequency( frequencyToSetChannelTo ); - ERRCHECK(result); - - } - - audio_debug("FmodAudioSound::set_play_rate() Sound's balance set to " << _playrate); + result = _channel->setFrequency( frequencyToSetChannelTo ); + ERRCHECK(result); + + } + + audio_debug("FmodAudioSound::set_play_rate() Sound's balance set to " << _playrate); } @@ -653,11 +657,12 @@ void FmodAudioSound::set_play_rate_on_channel() { // Access: public // Description: //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_play_rate() const { +float FmodAudioSound:: +get_play_rate() const { - audio_debug("FmodAudioSound::set_play_rate() Going to get a sound's balance."); + audio_debug("FmodAudioSound::set_play_rate() Going to get a sound's balance."); - return _playrate; + return _playrate; } @@ -666,76 +671,77 @@ float FmodAudioSound::get_play_rate() const { // Access: public // Description: Get name of sound file //////////////////////////////////////////////////////////////////// -const string& FmodAudioSound::get_name() const { - audio_debug("FmodAudioSound::get_name() Going to get a sound's file name."); +const string& FmodAudioSound:: +get_name() const { + audio_debug("FmodAudioSound::get_name() Going to get a sound's file name."); - return _file_name; + return _file_name; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::length // Access: public // Description: Get length -// FMOD returns the time in MS so we have to convert to seconds. +// FMOD returns the time in MS so we have to convert to seconds. //////////////////////////////////////////////////////////////////// -float FmodAudioSound::length() const { - - audio_debug("FmodAudioSound::length() Going to get a sound's length in second."); +float FmodAudioSound:: +length() const { + + audio_debug("FmodAudioSound::length() Going to get a sound's length in second."); - FMOD_RESULT result; - unsigned int length; + FMOD_RESULT result; + unsigned int length; - result = _sound->getLength( &length, FMOD_TIMEUNIT_MS ); - ERRCHECK(result); + result = _sound->getLength( &length, FMOD_TIMEUNIT_MS ); + ERRCHECK(result); - length = length / 1000; + length = length / 1000; - return length; + return length; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_3d_attributes // Access: public // Description: Set position and velocity of this sound -// NOW LISTEN UP!!! THIS IS IMPORTANT! -// Both Panda3D and FMOD use a left handed coordinate system. -// But there is a major difference! -// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. -// In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. -// The solution is simple, we just flip the Y and Z axis, as we move coordinates -// from Panda to FMOD and back. -// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. -// But if you decide to do any 3D audio work in here you have to keep it in mind. -// I told you, so you can't say I didn't. +// NOW LISTEN UP!!! THIS IS IMPORTANT! +// Both Panda3D and FMOD use a left handed coordinate system. +// But there is a major difference! +// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. +// In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. +// The solution is simple, we just flip the Y and Z axis, as we move coordinates +// from Panda to FMOD and back. +// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. +// But if you decide to do any 3D audio work in here you have to keep it in mind. +// I told you, so you can't say I didn't. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { - - audio_debug("FmodAudioSound::set_3d_attributes() Setting a sound's 3D Coordinates.") - - FMOD_RESULT result; - - _location.x = px; - _location.y = pz; - _location.z = py; - - _velocity.x = vx; - _velocity.y = vz; - _velocity.z = vy; - - result = _channel->set3DAttributes( &_location, &_velocity ); - ERRCHECK(result); - +void FmodAudioSound:: +set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { + audio_debug("FmodAudioSound::set_3d_attributes() Setting a sound's 3D Coordinates."); + FMOD_RESULT result; + + _location.x = px; + _location.y = pz; + _location.z = py; + + _velocity.x = vx; + _velocity.y = vz; + _velocity.z = vy; + + result = _channel->set3DAttributes( &_location, &_velocity ); + ERRCHECK(result); } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::get_3d_attributes // Access: public // Description: Get position and velocity of this sound -// Currently unimplemented. Get the attributes of the attached object. +// Currently unimplemented. Get the attributes of the attached object. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { - audio_error("get3dAttributes: Currently unimplemented. Get the attributes of the attached object."); +void FmodAudioSound:: +get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { + audio_error("get3dAttributes: Currently unimplemented. Get the attributes of the attached object."); } @@ -745,16 +751,17 @@ void FmodAudioSound::get_3d_attributes(float *px, float *py, float *pz, float *v // Description: Set the distance that this sound begins to fall off. Also // affects the rate it falls off. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_3d_min_distance(float dist) { - - audio_debug("FmodAudioSound::set_3d_min_distance() Setting the sound's 3D min distance ( min= " << dist << " ) "); +void FmodAudioSound:: +set_3d_min_distance(float dist) { + + audio_debug("FmodAudioSound::set_3d_min_distance() Setting the sound's 3D min distance ( min= " << dist << " ) "); - FMOD_RESULT result; + FMOD_RESULT result; - _min_dist = dist; + _min_dist = dist; - result = _sound->set3DMinMaxDistance( dist, _max_dist ); - ERRCHECK(result); + result = _sound->set3DMinMaxDistance( dist, _max_dist ); + ERRCHECK(result); } @@ -764,11 +771,12 @@ void FmodAudioSound::set_3d_min_distance(float dist) { // Access: public // Description: Get the distance that this sound begins to fall off //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_3d_min_distance() const { +float FmodAudioSound:: +get_3d_min_distance() const { - audio_debug("FmodAudioSound::get_3d_min_distance() "); + audio_debug("FmodAudioSound::get_3d_min_distance() "); - return _min_dist; + return _min_dist; } //////////////////////////////////////////////////////////////////// @@ -776,16 +784,17 @@ float FmodAudioSound::get_3d_min_distance() const { // Access: public // Description: Set the distance that this sound stops falling off //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_3d_max_distance(float dist) { +void FmodAudioSound:: +set_3d_max_distance(float dist) { - audio_debug("FmodAudioSound::set_3d_max_distance() Setting the sound's 3D max distance ( max= " << dist << " ) "); + audio_debug("FmodAudioSound::set_3d_max_distance() Setting the sound's 3D max distance ( max= " << dist << " ) "); - FMOD_RESULT result; + FMOD_RESULT result; - _max_dist = dist; + _max_dist = dist; - result = _sound->set3DMinMaxDistance( _min_dist, dist ); - ERRCHECK(result); + result = _sound->set3DMinMaxDistance( _min_dist, dist ); + ERRCHECK(result); } @@ -794,11 +803,12 @@ void FmodAudioSound::set_3d_max_distance(float dist) { // Access: public // Description: Get the distance that this sound stops falling off //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_3d_max_distance() const { - - audio_debug("FmodAudioSound::get_3d_max_distance() "); +float FmodAudioSound:: +get_3d_max_distance() const { + + audio_debug("FmodAudioSound::get_3d_max_distance() "); - return _max_dist; + return _max_dist; } @@ -808,45 +818,44 @@ float FmodAudioSound::get_3d_max_distance() const { // Function: FmodAudioSound::add_dsp // Access: Published // Description: This adds a DSP effect to a Sound's personal DSP Chain. -// DSPs set here will only affect it respective sound. -// +// DSPs set here will only affect it respective sound. +// //////////////////////////////////////////////////////////////////// -bool FmodAudioSound::add_dsp( PT(AudioDSP) x) { - // intentionally blank +bool FmodAudioSound:: +add_dsp( PT(AudioDSP) x) { + audio_debug("FmodAudioManager()::add_dsp"); - audio_debug("FmodAudioManager()::add_dsp"); + FMOD_RESULT result; + bool playingState; - FMOD_RESULT result; - bool playingState; + FmodAudioDSP *fdsp; + DCAST_INTO_R(fdsp, x, false); - FmodAudioDSP *fdsp; - DCAST_INTO_R(fdsp, x, false); + if ( fdsp->get_in_chain() ) { - if ( fdsp->get_in_chain() ) { + audio_debug("This DSP has already been assigned to the system or a sound."); - audio_debug("This DSP has already been assigned to the system or a sound."); + return false; - return false; + } else + { - } else - { + _sound_dsp.insert(fdsp); - _sound_dsp.insert(fdsp); + if ( _channel != 0 ) { + result = _channel->isPlaying( &playingState ); + ERRCHECK(result); + if ( playingState ) { + result = _channel->addDSP( fdsp->_dsp ); + ERRCHECK( result ); + } + } - if ( _channel != 0 ) { - result = _channel->isPlaying( &playingState ); - ERRCHECK(result); - if ( playingState ) { - result = _channel->addDSP( fdsp->_dsp ); - ERRCHECK( result ); - } - } + fdsp->set_in_chain(true); - fdsp->set_in_chain(true); + return true; - return true; - - } + } } @@ -855,61 +864,58 @@ bool FmodAudioSound::add_dsp( PT(AudioDSP) x) { // Access: Published // Description: Sets the DSPs on a prepared Sound channel. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::add_dsp_on_channel() { - // intentionally blank +void FmodAudioSound:: +add_dsp_on_channel() { + audio_debug("FmodAudioManager()::add_dsp_on_channel"); - audio_debug("FmodAudioManager()::add_dsp_on_channel"); + FMOD_RESULT result; - FMOD_RESULT result; + for (DSPSet::iterator i = _sound_dsp.begin(); i != _sound_dsp.end(); ++i) { - for (DSPSet::iterator i = _sound_dsp.begin(); i != _sound_dsp.end(); ++i) { - - result = _channel->addDSP( (*i)->_dsp ); - ERRCHECK( result ); - - } + result = _channel->addDSP( (*i)->_dsp ); + ERRCHECK( result ); + } } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::remove_dsp // Access: Published // Description: This will remove a DSP from a Sound's DSP Chain, but -// It will not destroy it! -// So in theory you could reuse the DSP for something else. -// In the Global Chain or another sound. +// It will not destroy it! +// So in theory you could reuse the DSP for something else. +// In the Global Chain or another sound. //////////////////////////////////////////////////////////////////// -bool FmodAudioSound::remove_dsp(PT(AudioDSP) x) { -// intentionally blank - - audio_debug("FmodAudioManager()::remove_dsp()"); +bool FmodAudioSound:: +remove_dsp(PT(AudioDSP) x) { + // intentionally blank + + audio_debug("FmodAudioManager()::remove_dsp()"); - FMOD_RESULT result; + FMOD_RESULT result; - FmodAudioDSP *fdsp; - DCAST_INTO_R(fdsp, x, false); + FmodAudioDSP *fdsp; + DCAST_INTO_R(fdsp, x, false); - if ( fdsp->get_in_chain() ) { + if ( fdsp->get_in_chain() ) { - result = fdsp->_dsp->remove(); - ERRCHECK( result ); + result = fdsp->_dsp->remove(); + ERRCHECK( result ); - _sound_dsp.erase(fdsp); + _sound_dsp.erase(fdsp); - fdsp->set_in_chain(false); + fdsp->set_in_chain(false); - return true; + return true; - } else - { - - audio_debug("FmodAudioManager()::remove_dsp()"); - audio_debug("This DSP doesn't exist in this chain."); - - return false; - - } + } else { + audio_debug("FmodAudioManager()::remove_dsp()"); + audio_debug("This DSP doesn't exist in this chain."); + + return false; + + } } @@ -917,125 +923,125 @@ bool FmodAudioSound::remove_dsp(PT(AudioDSP) x) { // Function: FmodAudioSound::get_speaker_mix // Access: Published // Description: In Multichannel Speaker systems [like Surround]. -// Can pass in the ID of a specific speaker and get itself Volume level. -// Currenly that is set to the Following: -// 1 = Front Left -// 2 = Front Right -// 3 = Center -// 4 = Subwoofer -// 5 = Back Left -// 6 = Back Right -// 7 = Side Left -// 8 = Side Right -// Speakers which don't exist in some systems will simply be ignored. -// IE So a quadsystem would only return values on 1,2,5,6. +// Can pass in the ID of a specific speaker and get itself Volume level. +// Currenly that is set to the Following: +// 1 = Front Left +// 2 = Front Right +// 3 = Center +// 4 = Subwoofer +// 5 = Back Left +// 6 = Back Right +// 7 = Side Left +// 8 = Side Right +// Speakers which don't exist in some systems will simply be ignored. +// IE So a quadsystem would only return values on 1,2,5,6. // -// But I haven't been able to test this yet, so I am jsut letting you know. +// But I haven't been able to test this yet, so I am jsut letting you know. // -// BTW This will also work in Stereo speaker systems, but since -// PANDA/FMOD has a balance [pan] function what is the point? +// BTW This will also work in Stereo speaker systems, but since +// PANDA/FMOD has a balance [pan] function what is the point? //////////////////////////////////////////////////////////////////// -float FmodAudioSound::get_speaker_mix(int speaker) { - // intentionally blank +float FmodAudioSound:: +get_speaker_mix(int speaker) { + // intentionally blank - audio_debug("FmodAudioSound::getSpeakerMix()"); + audio_debug("FmodAudioSound::getSpeakerMix()"); - FMOD_RESULT result; - float frontleft; - float frontright; - float center; - float sub; - float backleft; - float backright; - float sideleft; - float sideright; + FMOD_RESULT result; + float frontleft; + float frontright; + float center; + float sub; + float backleft; + float backright; + float sideleft; + float sideright; - float returnValue; + float returnValue; - switch(speaker) { - - case 1: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = frontleft; - break; - case 2: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = frontright; - break; - case 3: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = center; - break; - case 4: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = sub; - break; - case 5: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = backleft; - break; - case 6: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = backright; - break; - case 7: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = sideleft; - break; - case 8: - result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); - ERRCHECK(result); - returnValue = sideright; - break; - default: - cerr << "You specified a speaker which doesn't exist."; + switch(speaker) { + + case 1: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = frontleft; + break; + case 2: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = frontright; + break; + case 3: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = center; + break; + case 4: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = sub; + break; + case 5: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = backleft; + break; + case 6: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = backright; + break; + case 7: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = sideleft; + break; + case 8: + result = _channel->getSpeakerMix( &frontleft, &frontright, ¢er, &sub, &backleft, &backright, &sideleft, &sideright ); + ERRCHECK(result); + returnValue = sideright; + break; + default: + cerr << "You specified a speaker which doesn't exist."; + } - } - - - return returnValue; + return returnValue; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_speaker_mix // Access: Published // Description: This sets the speaker mix for Surround Sound sytems. -// It required 8 parameters which match up to the following: -// 1 = Front Left -// 2 = Front Right -// 3 = Center -// 4 = Subwoofer -// 5 = Back Left -// 6 = Back Right -// 7 = Side Left -// 8 = Side Right -// Speakers which don't exist in some systems will simply be ignored. +// It required 8 parameters which match up to the following: +// 1 = Front Left +// 2 = Front Right +// 3 = Center +// 4 = Subwoofer +// 5 = Back Left +// 6 = Back Right +// 7 = Side Left +// 8 = Side Right +// Speakers which don't exist in some systems will simply be ignored. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright) { - // intentionally blank +void FmodAudioSound:: +set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright) { + // intentionally blank - audio_debug("FmodAudioSound::setSpeakerMix()"); + audio_debug("FmodAudioSound::setSpeakerMix()"); - FMOD_RESULT result; + FMOD_RESULT result; - _frontleft = frontleft; - _frontright = frontright; - _center = center; - _sub = sub; - _backleft = backleft; - _backright = backright; - _sideleft = sideleft; - _sideright = sideright; + _frontleft = frontleft; + _frontright = frontright; + _center = center; + _sub = sub; + _backleft = backleft; + _backright = backright; + _sideleft = sideleft; + _sideright = sideright; - result = _channel->setSpeakerMix( _frontleft, _frontright, _center, _sub, _backleft, _backright, _sideleft, _sideright ); - ERRCHECK(result);; + result = _channel->setSpeakerMix( _frontleft, _frontright, _center, _sub, _backleft, _backright, _sideleft, _sideright ); + ERRCHECK(result);; } //////////////////////////////////////////////////////////////////// @@ -1043,15 +1049,16 @@ void FmodAudioSound::set_speaker_mix(float frontleft, float frontright, float ce // Access: Published // Description: Set the Speaker Mix for a sound on a prepared Sound channel. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_speaker_mix_on_channel() { - // intentionally blank +void FmodAudioSound:: +set_speaker_mix_on_channel() { + // intentionally blank - audio_debug("FmodAudioSound::setSpeakerMix()"); + audio_debug("FmodAudioSound::setSpeakerMix()"); - FMOD_RESULT result; + FMOD_RESULT result; - result = _channel->setSpeakerMix( _frontleft, _frontright, _center, _sub, _backleft, _backright, _sideleft, _sideright ); - ERRCHECK(result);; + result = _channel->setSpeakerMix( _frontleft, _frontright, _center, _sub, _backleft, _backright, _sideleft, _sideright ); + ERRCHECK(result);; } @@ -1060,40 +1067,41 @@ void FmodAudioSound::set_speaker_mix_on_channel() { // Function: FmodAudioSound::set_speaker_mix_or_balance_on_channel // Access: Private // Description: This is simply a safety catch. -// If you are using a Stero speaker setup Panda will only pay attention -// to 'set_balance()' command when setting speaker balances. -// Other wise it will use 'set_speaker_mix'. -// I put this in, because other wise you end up with a sitation, -// where 'set_speaker_mix()' or 'set_balace()' will override any -// previous speaker balance setups. It all depends on which was called last. +// If you are using a Stero speaker setup Panda will only pay attention +// to 'set_balance()' command when setting speaker balances. +// Other wise it will use 'set_speaker_mix'. +// I put this in, because other wise you end up with a sitation, +// where 'set_speaker_mix()' or 'set_balace()' will override any +// previous speaker balance setups. It all depends on which was called last. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_speaker_mix_or_balance_on_channel() { - // intentionally blank +void FmodAudioSound:: +set_speaker_mix_or_balance_on_channel() { + // intentionally blank - audio_debug("FmodAudioSound::set_speaker_mix_or_balance_on_channel()"); + audio_debug("FmodAudioSound::set_speaker_mix_or_balance_on_channel()"); - FMOD_RESULT result; - FMOD_MODE soundMode; + FMOD_RESULT result; + FMOD_MODE soundMode; - result = _sound->getMode(&soundMode); - ERRCHECK(result); + result = _sound->getMode(&soundMode); + ERRCHECK(result); - if ( _speakermode == FMOD_SPEAKERMODE_STEREO ) { + if ( _speakermode == FMOD_SPEAKERMODE_STEREO ) { - //FMOD Returns an error is you try and pan a sound in 3D Audio. - //Which makes sense. - //It is nothing serious, but might as well avoid it while we can. - if ( !( ( soundMode & FMOD_3D ) > 0 ) ) { - set_balance_on_channel(); - } + //FMOD Returns an error is you try and pan a sound in 3D Audio. + //Which makes sense. + //It is nothing serious, but might as well avoid it while we can. + if ( !( ( soundMode & FMOD_3D ) > 0 ) ) { + set_balance_on_channel(); + } - } else { + } else { - set_speaker_mix_on_channel(); + set_speaker_mix_on_channel(); - } + } } @@ -1102,31 +1110,33 @@ void FmodAudioSound::set_speaker_mix_or_balance_on_channel() { // Function: FmodAudioSound::get_priority // Access: Published // Description: Sets the priority of a sound. -// This is what FMOD uses to determine is a sound will -// play if all the other real channels have been used up. +// This is what FMOD uses to determine is a sound will +// play if all the other real channels have been used up. //////////////////////////////////////////////////////////////////// -int FmodAudioSound::get_priority() { - audio_debug("FmodAudioSound::get_priority()"); - return _priority; +int FmodAudioSound:: +get_priority() { + audio_debug("FmodAudioSound::get_priority()"); + return _priority; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_priority(int priority) // Access: Published // Description: Sets the Sound Priority [Whether is will be played -// over other sound when real audio channels become short. +// over other sound when real audio channels become short. //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_priority(int priority) { - // intentionally blank +void FmodAudioSound:: +set_priority(int priority) { + // intentionally blank - audio_debug("FmodAudioSound::set_priority()"); + audio_debug("FmodAudioSound::set_priority()"); - FMOD_RESULT result; + FMOD_RESULT result; - _priority = priority; + _priority = priority; - result = _sound->setDefaults( _sampleFrequency, _volume , _balance, _priority); - ERRCHECK(result); + result = _sound->setDefaults( _sampleFrequency, _volume , _balance, _priority); + ERRCHECK(result); } //////////////////////////////////////////////////////////////////// @@ -1134,32 +1144,33 @@ void FmodAudioSound::set_priority(int priority) { // Access: public // Description: Get status of the sound. //////////////////////////////////////////////////////////////////// -AudioSound::SoundStatus FmodAudioSound::status() const { -// If the stream's channel isn't playing anything, then the stream -// definitely isn't playing. - - audio_debug("FmodAudioSound::status() "); +AudioSound::SoundStatus FmodAudioSound:: +status() const { + // If the stream's channel isn't playing anything, then the stream + // definitely isn't playing. + + audio_debug("FmodAudioSound::status() "); - FMOD_RESULT result; - bool playingState; + FMOD_RESULT result; + bool playingState; - if ( _channel != 0 ) { - result = _channel->isPlaying( &playingState ); - ERRCHECK(result); - } + if ( _channel != 0 ) { + result = _channel->isPlaying( &playingState ); + ERRCHECK(result); + } - //audio_debug("If you get 'FMOD State: 32 An invalid object handle was used.' "); - //audio_debug("It doesn't mean there is a problem with FMOD or the sound."); - //audio_debug( "It just means your sound isn't playing." ); + //audio_debug("If you get 'FMOD State: 32 An invalid object handle was used.' "); + //audio_debug("It doesn't mean there is a problem with FMOD or the sound."); + //audio_debug( "It just means your sound isn't playing." ); - if (playingState) { - return PLAYING; - } else { - return READY; - } - - //return BAD; + if (playingState) { + return PLAYING; + } else { + return READY; + } + + //return BAD; } //////////////////////////////////////////////////////////////////// @@ -1167,11 +1178,12 @@ AudioSound::SoundStatus FmodAudioSound::status() const { // Access: public // Description: NOT USED ANYMORE!!! // -// +// //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_active(bool active) { - audio_debug( "set_active(active=" << active << ")" ); - audio_debug("NOT USED ANYMORE in FMOD-EX version of PANDA.") +void FmodAudioSound:: +set_active(bool active) { + audio_debug( "set_active(active=" << active << ")" ); + audio_debug("NOT USED ANYMORE in FMOD-EX version of PANDA."); } @@ -1179,60 +1191,60 @@ void FmodAudioSound::set_active(bool active) { // Function: FmodAudioSound::get_active // Access: public // Description: NOT 'REALLY' USED ANYMORE!!! -// This is actually an layover from the old version of the FMOD code. -// The old version used a weird cache system to keep track of the sounds' states. -// I just converted this method, to return if a sound is 'Playing' or not. -// This is not exactly how the orignal use of this function btu I figured I might -// as well get some use out of it. +// This is actually an layover from the old version of the FMOD code. +// The old version used a weird cache system to keep track of the sounds' states. +// I just converted this method, to return if a sound is 'Playing' or not. +// This is not exactly how the orignal use of this function btu I figured I might +// as well get some use out of it. //////////////////////////////////////////////////////////////////// -bool FmodAudioSound::get_active() const { - - audio_debug("FmodAudioSound::get_active() Going to get a sound's activity."); - audio_debug("NOT USED ANYMORE in FMOD-EX version of PANDA.") - - return false; +bool FmodAudioSound:: +get_active() const { + audio_debug("FmodAudioSound::get_active() Going to get a sound's activity."); + audio_debug("NOT USED ANYMORE in FMOD-EX version of PANDA."); + return false; } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::finished // Access: public // Description: NOT USED ANYMORE!!! -// Called by finishedCallback function when a sound +// Called by finishedCallback function when a sound // terminates (but doesn't loop). //////////////////////////////////////////////////////////////////// -void FmodAudioSound::finished() { - audio_debug("FmodAudioSound::finished()"); - audio_debug("NOT USED ANYMORE in FMOD-EX version of PANDA.") - stop(); - +void FmodAudioSound:: +finished() { + audio_debug("FmodAudioSound::finished()"); + audio_debug("NOT USED ANYMORE in FMOD-EX version of PANDA."); + stop(); } //////////////////////////////////////////////////////////////////// // Function: FmodAudioSound::set_finished_event // Access: public // Description: NOT USED ANYMORE!!! -// Assign a string for the finished event to be referenced +// Assign a string for the finished event to be referenced // by in python by an accept method // //////////////////////////////////////////////////////////////////// -void FmodAudioSound::set_finished_event(const string& event) { - audio_debug("FmodAudioSound::set_finished_event(event="< -#ifdef HAVE_FMOD //[ +#ifdef HAVE_FMODEX //[ #include "audioSound.h"