Assorted fmod fixes

This commit is contained in:
Josh Yelon 2006-09-18 23:11:31 +00:00
parent 0445017945
commit 02fa407aea
9 changed files with 1229 additions and 1203 deletions

View File

@ -23,7 +23,7 @@
#begin lib_target #begin lib_target
#define TARGET fmod_audio #define TARGET fmod_audio
#define BUILD_TARGET $[HAVE_FMOD] #define BUILD_TARGET $[HAVE_FMODEX]
#define USE_PACKAGES fmod #define USE_PACKAGES fmod
#define BUILDING_DLL BUILDING_FMOD_AUDIO #define BUILDING_DLL BUILDING_FMOD_AUDIO
#define LOCAL_LIBS audio event #define LOCAL_LIBS audio event

View File

@ -17,7 +17,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "pandabase.h" #include "pandabase.h"
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
#include "config_fmodAudio.h" #include "config_fmodAudio.h"

View File

@ -21,7 +21,7 @@
#include "pandabase.h" #include "pandabase.h"
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
#include "notifyCategoryProxy.h" #include "notifyCategoryProxy.h"
#include "dconfig.h" #include "dconfig.h"

View File

@ -20,7 +20,7 @@
#include "pandabase.h" #include "pandabase.h"
#include "dcast.h" #include "dcast.h"
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
//Panda Headers //Panda Headers
#include "config_audio.h" #include "config_audio.h"
@ -33,31 +33,29 @@ TypeHandle FmodAudioDSP::_type_handle;
// Function: FmodAudioDSP::FmodAudioDSP // Function: FmodAudioDSP::FmodAudioDSP
// Access: Protected // Access: Protected
// Description: Constructor // Description: Constructor
// This is a thin wrapper around FMOD-EX. // This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
FmodAudioDSP::FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat) { FmodAudioDSP::
FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat) {
// Intentionally blank. // 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. //Assign the values we need
FMOD_RESULT result; DCAST_INTO_V(_manager, manager);
//Assign the values we need FMOD_DSP_TYPE dsptype = (FMOD_DSP_TYPE)cat;
DCAST_INTO_V(_manager, manager);
FMOD_DSP_TYPE dsptype = (FMOD_DSP_TYPE)cat; result = _manager->_system->createDSPByType( dsptype, &_dsp);
ERRCHECK(result);
result = _manager->_system->createDSPByType( dsptype, &_dsp); set_in_chain(false);
ERRCHECK(result);
set_in_chain(false);
cerr << get_dsp_name() << endl;
audio_debug("DSP Loaded");
audio_debug("DSP Loaded");
} }
@ -68,21 +66,20 @@ FmodAudioDSP::FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat
// Access: Published, Virtual // Access: Published, Virtual
// Description: DESTRUCTOR!!! // 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. result = _dsp->remove();
FMOD_RESULT result; ERRCHECK(result);
result = _dsp->remove(); result = _dsp->release();
ERRCHECK(result); ERRCHECK(result);
result = _dsp->release(); audio_debug("DSP GONE");
ERRCHECK(result);
audio_debug("DSP GONE");
} }
@ -91,20 +88,19 @@ FmodAudioDSP::~FmodAudioDSP() {
// Access: Published, Virtual // Access: Published, Virtual
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // 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. result = _dsp->reset();
FMOD_RESULT result; ERRCHECK(result);
result = _dsp->reset();
ERRCHECK(result);
audio_debug("DSP Reset.");
audio_debug("DSP Reset.");
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -112,19 +108,19 @@ void FmodAudioDSP::reset() {
// Access: Published, Virtual // Access: Published, Virtual
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
// [This removes the DSP from an Effects Chain] // [This removes the DSP from an Effects Chain]
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioDSP::remove() { void FmodAudioDSP::
audio_debug("FmodAudioSound::remove() Removes a DSP from and effect chain." ); remove() {
audio_debug("FmodAudioSound::remove() Removes a DSP from and effect chain." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
result = _dsp->remove(); result = _dsp->remove();
ERRCHECK(result); ERRCHECK(result);
audio_debug("DSP Removed from relative effects chain.");
audio_debug("DSP Removed from relative effects chain.");
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -132,18 +128,19 @@ void FmodAudioDSP::remove() {
// Access: Published, Virtual // Access: Published, Virtual
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // 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) { void FmodAudioDSP::
audio_debug("FmodAudioSound::set_bypass() ." ); set_bypass(bool bypass) {
audio_debug("FmodAudioSound::set_bypass() ." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
result = _dsp->setBypass(bypass); result = _dsp->setBypass(bypass);
ERRCHECK(result); 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. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FmodAudioDSP::get_bypass() { bool FmodAudioDSP::
audio_debug("FmodAudioSound::get_bypass() ." ); get_bypass() {
audio_debug("FmodAudioSound::get_bypass() ." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
bool bypass; bool bypass;
result = _dsp->getBypass(&bypass); result = _dsp->getBypass(&bypass);
ERRCHECK(result); ERRCHECK(result);
return bypass;
return bypass;
} }
@ -175,19 +172,18 @@ bool FmodAudioDSP::get_bypass() {
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioDSP::set_parameter(const string &name, float value) { void FmodAudioDSP::
set_parameter(const string &name, float value) {
int parameterIndex = find_parameter(name); int parameterIndex = find_parameter(name);
if (parameterIndex < 0) { if (parameterIndex < 0) {
return; return;
} }
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
result = _dsp->setParameter(parameterIndex, value);
ERRCHECK(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. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
int FmodAudioDSP::get_num_parameters() { int FmodAudioDSP::
audio_debug("FmodAudioSound::get_num_parameters() ." ); get_num_parameters() {
audio_debug("FmodAudioSound::get_num_parameters() ." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
int numOfParameters; int numOfParameters;
result = _dsp->getNumParameters(&numOfParameters); result = _dsp->getNumParameters(&numOfParameters);
ERRCHECK(result); ERRCHECK(result);
return numOfParameters; return numOfParameters;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -217,30 +214,30 @@ int FmodAudioDSP::get_num_parameters() {
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
string FmodAudioDSP::get_parameter_name(int parameterIndex) { string FmodAudioDSP::
// intentionally blank get_parameter_name(int parameterIndex) {
audio_debug("FmodAudioSound::get_parameter_name()" ); audio_debug("FmodAudioSound::get_parameter_name()" );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
//int parameterIndex; //int parameterIndex;
char parameterName[32]; char parameterName[32];
char parameterLabel[32]; char parameterLabel[32];
char parameterDescription[32]; char parameterDescription[32];
int parameterDescriptionLength = 0; int parameterDescriptionLength = 0;
float parameterMin; float parameterMin;
float parameterMax; float parameterMax;
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax); result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax);
ERRCHECK(result); 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 // Access: Published, Virtual
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
// This Method actually returns FMOD's Parameter Label // This Method actually returns FMOD's Parameter Label
// Information, and not Description. // Information, and not Description.
// The reason is, that most of the FMOD's Description // The reason is, that most of the FMOD's Description
// Properties seem to be empty. // Properties seem to be empty.
// Also the Label sort of serves as as a description by // Also the Label sort of serves as as a description by
// return the type of unit the cooresponding parameter // return the type of unit the cooresponding parameter
// modifies for a DSP. // modifies for a DSP.
// IE. For the Echo. The first parameter is 'Delay' // IE. For the Echo. The first parameter is 'Delay'
// and the units for measuring the Delay is in Milliseconds. // and the units for measuring the Delay is in Milliseconds.
// The Label returns Milliseconds letting you know that. // The Label returns Milliseconds letting you know that.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
string FmodAudioDSP::get_parameter_description(int parameterIndex) { string FmodAudioDSP::
// intentionally blank get_parameter_description(int parameterIndex) {
// intentionally blank
audio_debug("FmodAudioSound::get_parameter_description()." ); audio_debug("FmodAudioSound::get_parameter_description()." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
//int parameterIndex; //int parameterIndex;
char parameterName[32]; char parameterName[32];
char parameterLabel[32]; char parameterLabel[32];
char parameterDescription[32]; char parameterDescription[32];
int parameterDescriptionLength = 0; int parameterDescriptionLength = 0;
float parameterMin; float parameterMin;
float parameterMax; float parameterMax;
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax); result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax);
ERRCHECK(result); 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. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioDSP::get_parameter_min(int parameterIndex) { float FmodAudioDSP::
get_parameter_min(int parameterIndex) {
audio_debug("FmodAudioSound::get_parameter_min()." );
audio_debug("FmodAudioSound::get_parameter_min()." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
//int parameterIndex; //int parameterIndex;
char parameterName[32]; char parameterName[32];
char parameterLabel[32]; char parameterLabel[32];
char parameterDescription[32]; char parameterDescription[32];
int parameterDescriptionLength = 0; int parameterDescriptionLength = 0;
float parameterMin; float parameterMin;
float parameterMax; float parameterMax;
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax); result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax);
ERRCHECK(result); 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. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioDSP::get_parameter_max(int parameterIndex) { float FmodAudioDSP::
get_parameter_max(int parameterIndex) {
audio_debug("FmodAudioSound::get_parameter_min()." );
audio_debug("FmodAudioSound::get_parameter_min()." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
//int parameterIndex; //int parameterIndex;
char parameterName[32]; char parameterName[32];
char parameterLabel[32]; char parameterLabel[32];
char parameterDescription[32]; char parameterDescription[32];
int parameterDescriptionLength = 0; int parameterDescriptionLength = 0;
float parameterMin; float parameterMin;
float parameterMax; float parameterMax;
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax); result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, &parameterMin, &parameterMax);
ERRCHECK(result); 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. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioDSP::get_parameter_value(const string &name) { float FmodAudioDSP::
get_parameter_value(const string &name) {
int parameterIndex = find_parameter(name);
if (parameterIndex < 0) { int parameterIndex = find_parameter(name);
return 0.0; if (parameterIndex < 0) {
} return 0.0;
}
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
float parameterValue; float parameterValue;
char valuestr[32]; char valuestr[32];
int valuestrlen = 32; int valuestrlen = 32;
result = _dsp->getParameter(parameterIndex, &parameterValue, valuestr, valuestrlen); result = _dsp->getParameter(parameterIndex, &parameterValue, valuestr, valuestrlen);
ERRCHECK(result); ERRCHECK(result);
return parameterValue; return parameterValue;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -370,17 +371,18 @@ float FmodAudioDSP::get_parameter_value(const string &name) {
// Access: Private // Access: Private
// Description: Convert a parameter name to an fmod parameter index. // Description: Convert a parameter name to an fmod parameter index.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
int FmodAudioDSP::find_parameter(const string &name) { int FmodAudioDSP::
int np = get_num_parameters(); find_parameter(const string &name) {
for (int i=0; i<np; i++) { int np = get_num_parameters();
if ( name == get_parameter_name(i) ) { for (int i=0; i<np; i++) {
if ( name == get_parameter_name(i) ) {
audio_debug("FmodAudioSound::find_parameter() returning: " << get_parameter_name(i) << " " << i ); audio_debug("FmodAudioSound::find_parameter() returning: " << get_parameter_name(i) << " " << i );
return i; return i;
} }
} }
return -1; return -1;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -389,28 +391,27 @@ int FmodAudioDSP::find_parameter(const string &name) {
// Description: This is a thin wrapper around FMOD-EX. // Description: This is a thin wrapper around FMOD-EX.
// See the FMOD-EX documentation. // See the FMOD-EX documentation.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
string FmodAudioDSP::get_dsp_name() { string FmodAudioDSP::
get_dsp_name() {
audio_debug("FmodAudioSound::get_dsp_name()." ); audio_debug("FmodAudioSound::get_dsp_name()." );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
char name[32]; char name[32];
unsigned int version; unsigned int version;
int channels; int channels;
int configwidth; int configwidth;
int configheight; int configheight;
result = _dsp->getInfo(name, &version, &channels, &configwidth, &configheight); result = _dsp->getInfo(name, &version, &channels, &configwidth, &configheight);
ERRCHECK(result); ERRCHECK(result);
string returnInfo = (name); string returnInfo = (name);
//returnInfo.append(" Version: "); //returnInfo.append(" Version: ");
//returnInfo.append(version); //returnInfo.append(version);
//returnInfo.append("\n"); //returnInfo.append("\n");
return returnInfo;
return returnInfo;
} }
@ -418,17 +419,15 @@ string FmodAudioDSP::get_dsp_name() {
// Function: FmodAudioDSP::get_in_chain() // Function: FmodAudioDSP::get_in_chain()
// Access: Published, Virtual // Access: Published, Virtual
// Description: This is a functiont to query if a DSP have been assigned // Description: This is a functiont to query if a DSP have been assigned
// to the GLOBAL or a SOUND's effect chain. // to the GLOBAL or a SOUND's effect chain.
// This is to make sure you 'remove' an effect from a chain // This is to make sure you 'remove' an effect from a chain
// before you move it somewhere else or destroy it. // before you move it somewhere else or destroy it.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FmodAudioDSP::get_in_chain() { bool FmodAudioDSP::
get_in_chain() {
audio_debug("FmodAudioSound::get_in_chain()." ); audio_debug("FmodAudioSound::get_in_chain()." );
return _in_chain;
return _in_chain;
} }
@ -436,16 +435,14 @@ bool FmodAudioDSP::get_in_chain() {
// Function: FmodAudioDSP::set_in_chain() // Function: FmodAudioDSP::set_in_chain()
// Access: Published, Virtual // Access: Published, Virtual
// Description: This is a functiont to set if a DSP have been assigned // 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) { void FmodAudioDSP::
set_in_chain(bool chain_state) {
audio_debug("FmodAudioSound::set_in_chain()." ); audio_debug("FmodAudioSound::set_in_chain()." );
_in_chain = chain_state;
_in_chain = chain_state;
} }
#endif //] #endif //]

View File

@ -72,7 +72,7 @@
#include <pandabase.h> #include <pandabase.h>
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
#include "audioManager.h" #include "audioManager.h"
#include "audioDSP.h" #include "audioDSP.h"

View File

@ -23,7 +23,7 @@
#include "config_audio.h" #include "config_audio.h"
#include "dcast.h" #include "dcast.h"
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
//Panda headers. //Panda headers.
#include "config_audio.h" #include "config_audio.h"
@ -61,13 +61,13 @@ TypeHandle FmodAudioManager::_type_handle;
// Python Prompt // Python Prompt
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
void ERRCHECK(FMOD_RESULT result){ 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() { PT(AudioManager) Create_AudioManager() {
audio_debug("Create_AudioManager() Fmod."); audio_debug("Create_AudioManager() Fmod.");
return new FmodAudioManager; return new FmodAudioManager;
} }
@ -76,92 +76,91 @@ PT(AudioManager) Create_AudioManager() {
// Access: Public // Access: Public
// Description: Constructor // Description: Constructor
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
FmodAudioManager::FmodAudioManager() { FmodAudioManager::
FmodAudioManager() {
//OK Lets create the FMOD Audio Manager. //OK Lets create the FMOD Audio Manager.
audio_debug("FmodAudioManager::FmodAudioManager()"); audio_debug("FmodAudioManager::FmodAudioManager()");
FMOD_RESULT result; FMOD_RESULT result;
//We need a varible temporary to check the FMOD Version. //We need a varible temporary to check the FMOD Version.
unsigned int version; unsigned int version;
//Init 3D attributes //Init 3D attributes
_position.x = 0; _position.x = 0;
_position.y = 0; _position.y = 0;
_position.z = 0; _position.z = 0;
_velocity.x = 0; _velocity.x = 0;
_velocity.y = 0; _velocity.y = 0;
_velocity.z = 0; _velocity.z = 0;
_forward.x = 0; _forward.x = 0;
_forward.y = 0; _forward.y = 0;
_forward.z = 0; _forward.z = 0;
_up.x = 0; _up.x = 0;
_up.y = 0; _up.y = 0;
_up.z = 0; _up.z = 0;
audio_debug("FMOD::System_Create()"); audio_debug("FMOD::System_Create()");
result = FMOD::System_Create(&_system); result = FMOD::System_Create(&_system);
ERRCHECK(result); ERRCHECK(result);
// Let check the Version of FMOD to make sure the Headers and Libraries are correct. // Let check the Version of FMOD to make sure the Headers and Libraries are correct.
audio_debug("FMOD::System_Create()"); audio_debug("FMOD::System_Create()");
result = _system->getVersion(&version); result = _system->getVersion(&version);
ERRCHECK(result); ERRCHECK(result);
audio_debug("FMOD VERSION:" << hex << version ); audio_debug("FMOD VERSION:" << hex << version );
audio_debug("FMOD - Getting Version"); audio_debug("FMOD - Getting Version");
if (version < FMOD_VERSION){ if (version < FMOD_VERSION){
audio_debug("Error! You are using an old version of FMOD. This program requires:" << 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) { //Now we Initialize the System.
audio_debug("Setting FMOD to use 5.1 Surround Sound.")
result = _system->setSpeakerMode( FMOD_SPEAKERMODE_5POINT1 );
ERRCHECK(result);
}
//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"); if (result == FMOD_OK){
result = _system->init(fmod_number_of_sound_channels, FMOD_INIT_NORMAL, 0); audio_debug("FMOD Intialized OK, We are good to go Houston!");
ERRCHECK(result); _is_valid = true;
} else {
audio_debug("Something is still wrong with FMOD! Check source.");
_is_valid = false;
}
if (result == FMOD_OK){ // This sets the distance factor for 3D audio to use feet.
audio_debug("FMOD Intialized OK, We are good to go Houston!"); // FMOD uses meters by default.
_is_valid = true; // Since Panda use feet we need to compensate for that with a factor of 3.28
} else { //
audio_debug("Something is still wrong with FMOD! Check source."); // This can be over written. You just need to call
_is_valid = false; // 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. audio_debug("Setting 3D Audio settings: Doppler Factor, Distance Factor, Drop Off Factor");
// 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"); 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 // Access: Public
// Description: DESTRCUTOR !!! // Description: DESTRCUTOR !!!
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
FmodAudioManager::~FmodAudioManager() { FmodAudioManager::
// Be sure to delete associated sounds before deleting the manager! ~FmodAudioManager() {
audio_debug("~FmodAudioManager(): Closing Down"); // Be sure to delete associated sounds before deleting the manager!
audio_debug("~FmodAudioManager(): Closing Down");
FMOD_RESULT result; FMOD_RESULT result;
//Release DSPs First //Release DSPs First
_system_dsp.clear(); _system_dsp.clear();
//Release Sounds Next //Release Sounds Next
_all_sounds.clear(); _all_sounds.clear();
//result = _system->close(); //result = _system->close();
//ERRCHECK(result); //ERRCHECK(result);
result = _system->release(); result = _system->release();
ERRCHECK(result); ERRCHECK(result);
audio_debug("~FmodAudioManager(): System Down."); audio_debug("~FmodAudioManager(): System Down.");
} }
@ -196,11 +196,12 @@ FmodAudioManager::~FmodAudioManager() {
// Function: FmodAudioManager::is_valid // Function: FmodAudioManager::is_valid
// Access: Public // Access: Public
// Description: This just check to make sure the FMOD System is // Description: This just check to make sure the FMOD System is
// up and running correctly. // up and running correctly.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FmodAudioManager::is_valid() { bool FmodAudioManager::
audio_debug("FmodAudioManager::is_valid() = " << _is_valid ); is_valid() {
return _is_valid; audio_debug("FmodAudioManager::is_valid() = " << _is_valid );
return _is_valid;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -208,23 +209,24 @@ bool FmodAudioManager::is_valid() {
// Access: Public // Access: Public
// Description: This is what creates a sound instance. // 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=\""<<file_name<<"\")"); audio_debug("FmodAudioManager::get_sound(file_name=\""<<file_name<<"\")");
//Needed so People use Panda's Generic UNIX Style Paths for Filename. //Needed so People use Panda's Generic UNIX Style Paths for Filename.
//path.to_os_specific() converts it back to the proper OS version later on. //path.to_os_specific() converts it back to the proper OS version later on.
Filename path = file_name; Filename path = file_name;
// Build a new AudioSound from the audio data. // Build a new AudioSound from the audio data.
PT(AudioSound) audioSound = 0; PT(AudioSound) audioSound = 0;
PT(FmodAudioSound) fmodAudioSound = new FmodAudioSound(this, path.to_os_specific(), positional ); PT(FmodAudioSound) fmodAudioSound = new FmodAudioSound(this, path.to_os_specific(), positional );
_all_sounds.insert(fmodAudioSound); _all_sounds.insert(fmodAudioSound);
audioSound = fmodAudioSound; audioSound = fmodAudioSound;
return audioSound; return audioSound;
} }
@ -234,14 +236,14 @@ PT(AudioSound) FmodAudioManager::get_sound(const string &file_name, bool positio
// Access: Published // Access: Published
// Description: This is what creates a DSP instance. // Description: This is what creates a DSP instance.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PT(AudioDSP) FmodAudioManager::create_dsp(DSP_category index) { PT(AudioDSP) FmodAudioManager::
audio_debug("FmodAudioManager()::create_dsp"); create_dsp(DSP_category index) {
audio_debug("FmodAudioManager()::create_dsp");
// Build a new AudioSound from the audio data.
PT(FmodAudioDSP) fmodAudioDSP = new FmodAudioDSP(this, index); // Build a new AudioSound from the audio data.
PT(FmodAudioDSP) fmodAudioDSP = new FmodAudioDSP(this, index);
return (AudioDSP*)fmodAudioDSP;
return (AudioDSP*)fmodAudioDSP;
} }
@ -249,37 +251,38 @@ PT(AudioDSP) FmodAudioManager::create_dsp(DSP_category index) {
// Function: FmodAudioManager::add_dsp() // Function: FmodAudioManager::add_dsp()
// Access: Published // Access: Published
// Description: This stick the DSP in the Global Effect Chain // Description: This stick the DSP in the Global Effect Chain
// DSP effects here, affect all the SOUNDS being played // DSP effects here, affect all the SOUNDS being played
// in panda. // in panda.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FmodAudioManager::add_dsp( PT(AudioDSP) x) { bool FmodAudioManager::
// intentionally blank add_dsp( PT(AudioDSP) x) {
// intentionally blank
FMOD_RESULT result; FMOD_RESULT result;
FmodAudioDSP *fdsp; FmodAudioDSP *fdsp;
DCAST_INTO_R(fdsp, x, false); DCAST_INTO_R(fdsp, x, false);
if ( fdsp->get_in_chain() ) { if ( fdsp->get_in_chain() ) {
audio_debug("FmodAudioManager()::add_dsp"); audio_debug("FmodAudioManager()::add_dsp");
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
{ {
result = _system->addDSP( fdsp->_dsp ); result = _system->addDSP( fdsp->_dsp );
ERRCHECK( result ); 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 // Access: Published
// Description: This removes the DSP from the Global Effect chain but does not destroy it. // 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 // 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:: bool FmodAudioManager::
remove_dsp(PT(AudioDSP) x) { remove_dsp(PT(AudioDSP) x) {
// intentionally blank // intentionally blank
FMOD_RESULT result; FMOD_RESULT result;
FmodAudioDSP *fdsp; FmodAudioDSP *fdsp;
DCAST_INTO_R(fdsp, x, false); DCAST_INTO_R(fdsp, x, false);
if ( fdsp->get_in_chain() ) { if ( fdsp->get_in_chain() ) {
result = fdsp->_dsp->remove(); result = fdsp->_dsp->remove();
ERRCHECK( result ); 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("FmodAudioManager()::remove_dsp()");
audio_debug("This DSP doesn't exist in this chain."); 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:: int FmodAudioManager::
getSpeakerSetup() { getSpeakerSetup() {
// intentionally blank // intentionally blank
FMOD_RESULT result; FMOD_RESULT result;
FMOD_SPEAKERMODE speakerMode; FMOD_SPEAKERMODE speakerMode;
int returnMode; int returnMode;
result = _system->getSpeakerMode( &speakerMode ); result = _system->getSpeakerMode( &speakerMode );
ERRCHECK( result ); ERRCHECK( result );
switch (speakerMode) { switch (speakerMode) {
case FMOD_SPEAKERMODE_RAW: case FMOD_SPEAKERMODE_RAW:
returnMode = 0; returnMode = 0;
break; break;
case FMOD_SPEAKERMODE_MONO: case FMOD_SPEAKERMODE_MONO:
returnMode = 1; returnMode = 1;
break; break;
case FMOD_SPEAKERMODE_STEREO: case FMOD_SPEAKERMODE_STEREO:
returnMode = 2; returnMode = 2;
break; break;
case FMOD_SPEAKERMODE_QUAD: case FMOD_SPEAKERMODE_QUAD:
returnMode = 3; returnMode = 3;
break; break;
case FMOD_SPEAKERMODE_SURROUND: case FMOD_SPEAKERMODE_SURROUND:
returnMode = 4; returnMode = 4;
break; break;
case FMOD_SPEAKERMODE_5POINT1: case FMOD_SPEAKERMODE_5POINT1:
returnMode = 5; returnMode = 5;
break; break;
case FMOD_SPEAKERMODE_7POINT1: case FMOD_SPEAKERMODE_7POINT1:
returnMode = 6; returnMode = 6;
break; break;
case FMOD_SPEAKERMODE_PROLOGIC: case FMOD_SPEAKERMODE_PROLOGIC:
returnMode = 7; returnMode = 7;
break; break;
case FMOD_SPEAKERMODE_MAX: case FMOD_SPEAKERMODE_MAX:
returnMode = 8; returnMode = 8;
break; break;
default: default:
returnMode = -1; returnMode = -1;
} }
return returnMode; return returnMode;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: FmodAudioManager::setSpeakerSetup() // Function: FmodAudioManager::setSpeakerSetup()
// Access: Published // Access: Published
// Description: This is to set up FMOD to use a MultiChannel Setup. // Description: This is to set up FMOD to use a MultiChannel Setup.
// This method is pretty much useless. // This method is pretty much useless.
// To set a speaker setup in FMOD for Surround Sound, // To set a speaker setup in FMOD for Surround Sound,
// stereo, or whatever you have to set the SpeakerMode // stereo, or whatever you have to set the SpeakerMode
// BEFORE you Initialize FMOD. // BEFORE you Initialize FMOD.
// Since Panda Inits the FmodAudioManager right when you // Since Panda Inits the FmodAudioManager right when you
// Start it up, you are never given an oppertunity to call // Start it up, you are never given an oppertunity to call
// this function. // this function.
// That is why I stuck a BOOL in the CONFIG.PRC file, whichs // 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. // lets you flag if you want to use a Multichannel or not.
// That will set the speaker setup when an instance of this // That will set the speaker setup when an instance of this
// class is constructed. // class is constructed.
// Still I put this here as a measure of good faith, since you // Still I put this here as a measure of good faith, since you
// can query the speaker setup after everything in Init. // can query the speaker setup after everything in Init.
// Also, maybe someone will completely hack Panda someday, in which // Also, maybe someone will completely hack Panda someday, in which
// one can init or re-init the AudioManagers after Panda is running. // one can init or re-init the AudioManagers after Panda is running.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager:: void FmodAudioManager::
setSpeakerSetup(AudioManager::SPEAKERMODE_category cat) { setSpeakerSetup(AudioManager::SPEAKERMODE_category cat) {
// intentionally blank // intentionally blank
audio_debug("FmodAudioSound::setSpeakerSetup() " ); audio_debug("FmodAudioSound::setSpeakerSetup() " );
//Local Variables that are needed. //Local Variables that are needed.
FMOD_RESULT result; FMOD_RESULT result;
FMOD_SPEAKERMODE speakerModeType = (FMOD_SPEAKERMODE)cat; FMOD_SPEAKERMODE speakerModeType = (FMOD_SPEAKERMODE)cat;
result = _system->setSpeakerMode( speakerModeType); result = _system->setSpeakerMode( speakerModeType);
ERRCHECK(result); 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) // Function: FmodAudioManager::set_volume(float volume)
// Access: Public // Access: Public
// Description: // Description:
// There isn't a specific system volume function in FMOD-EX, // There isn't a specific system volume function in FMOD-EX,
// so this function is moot now. // so this function is moot now.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::set_volume(float volume) { void FmodAudioManager::set_volume(float volume) {
audio_debug("FmodAudioManager::set_volume()" ); audio_debug("FmodAudioManager::set_volume()" );
audio_debug("This function has no effect in this version." ) audio_debug("This function has no effect in this version." );
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: FmodAudioManager::get_volume() // Function: FmodAudioManager::get_volume()
// Access: Public // Access: Public
// Description: // Description:
// There isn't a specific system volume function in FMOD-EX, // There isn't a specific system volume function in FMOD-EX,
// so this function is moot now. // so this function is moot now.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioManager::get_volume() const { float FmodAudioManager::
audio_debug("FmodAudioManager::get_volume() returning "); get_volume() const {
audio_debug("This function has no effect in this version." ) audio_debug("FmodAudioManager::get_volume() returning ");
return 0; audio_debug("This function has no effect in this version." );
return 0;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: FmodAudioManager::set_active(bool active) // Function: FmodAudioManager::set_active(bool active)
// Access: Public // Access: Public
// Description: Turn on/off // 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) { void FmodAudioManager::
audio_debug("FmodAudioManager::set_active(flag="<<active<<")"); set_active(bool active) {
audio_debug("FmodAudioManager::set_active(flag="<<active<<")");
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -454,9 +457,10 @@ void FmodAudioManager::set_active(bool active) {
// Access: Public // Access: Public
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FmodAudioManager::get_active() const { bool FmodAudioManager::
audio_debug("FmodAudioManager::get_active() returning "<<_active); get_active() const {
return _active; audio_debug("FmodAudioManager::get_active() returning "<<_active);
return _active;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -464,16 +468,13 @@ bool FmodAudioManager::get_active() const {
// Access: Public // Access: Public
// Description: Stop playback on all sounds managed by this manager. // Description: Stop playback on all sounds managed by this manager.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::stop_all_sounds() { void FmodAudioManager::
stop_all_sounds() {
audio_debug("FmodAudioManager::stop_all_sounds()" ); audio_debug("FmodAudioManager::stop_all_sounds()" );
for (SoundSet::iterator i = _all_sounds.begin(); i != _all_sounds.end(); ++i) {
(*i)->stop();
}
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 // positioned sounds. Normally, you'd want to call this
// once per iteration of your main loop. // once per iteration of your main loop.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::audio_3d_update() { void FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_update()"); audio_3d_update() {
audio_debug("Calling FMOD's update function"); 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 // Function: FmodAudioManager::audio_3d_set_listener_attributes
// Access: Public // Access: Public
// Description: Set position of the "ear" that picks up 3d sounds // Description: Set position of the "ear" that picks up 3d sounds
// NOW LISTEN UP!!! THIS IS IMPORTANT! // NOW LISTEN UP!!! THIS IS IMPORTANT!
// Both Panda3D and FMOD use a left handed coordinate system. // Both Panda3D and FMOD use a left handed coordinate system.
// But there is a major difference! // But there is a major difference!
// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. // 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. // 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 // The solution is simple, we just flip the Y and Z axis, as we move coordinates
// from Panda to FMOD and back. // from Panda to FMOD and back.
// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. // 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. // 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. // 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) { void FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_set_listener_attributes()"); 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; FMOD_RESULT result;
_position.x = px; _position.x = px;
_position.y = pz; _position.y = pz;
_position.z = py; _position.z = py;
_velocity.x = vx; _velocity.x = vx;
_velocity.y = vz; _velocity.y = vz;
_velocity.z = vy; _velocity.z = vy;
_forward.x = fx; _forward.x = fx;
_forward.y = fz; _forward.y = fz;
_forward.z = fy; _forward.z = fy;
_up.x = ux; _up.x = ux;
_up.y = uz; _up.y = uz;
_up.z = uy; _up.z = uy;
result = _system->set3DListenerAttributes( 0, &_position, &_velocity, &_forward, &_up); result = _system->set3DListenerAttributes( 0, &_position, &_velocity, &_forward, &_up);
ERRCHECK( result ); ERRCHECK( result );
} }
@ -537,8 +540,9 @@ void FmodAudioManager::audio_3d_set_listener_attributes(float px, float py, floa
// Access: Public // Access: Public
// Description: Get position of the "ear" that picks up 3d sounds // 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) { void FmodAudioManager::
audio_error("audio3dGetListenerAttributes: currently unimplemented. Get the attributes of the attached object"); 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 // Description: Set units per meter (Fmod uses meters internally for
// its sound-spacialization calculations) // its sound-spacialization calculations)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::audio_3d_set_distance_factor(float factor) { void FmodAudioManager::
audio_debug( "FmodAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")" ); audio_3d_set_distance_factor(float factor) {
audio_debug( "FmodAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")" );
FMOD_RESULT result;
FMOD_RESULT result;
_distance_factor = factor; _distance_factor = factor;
result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor);
ERRCHECK( result ); 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 // Description: Gets units per meter (Fmod uses meters internally for
// its sound-spacialization calculations) // its sound-spacialization calculations)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioManager::audio_3d_get_distance_factor() const { float FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_get_distance_factor()"); 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. // Description: Exaggerates or diminishes the Doppler effect.
// Defaults to 1.0 // Defaults to 1.0
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::audio_3d_set_doppler_factor(float factor) { void FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_set_doppler_factor(factor="<<factor<<")"); audio_3d_set_doppler_factor(float factor) {
audio_debug("FmodAudioManager::audio_3d_set_doppler_factor(factor="<<factor<<")");
FMOD_RESULT result; FMOD_RESULT result;
_doppler_factor = factor; _doppler_factor = factor;
result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor);
ERRCHECK( result ); ERRCHECK( result );
} }
@ -597,10 +604,11 @@ void FmodAudioManager::audio_3d_set_doppler_factor(float factor) {
// Access: Public // Access: Public
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioManager::audio_3d_get_doppler_factor() const { float FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_get_doppler_factor()"); 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. // Description: Control the effect distance has on audability.
// Defaults to 1.0 // Defaults to 1.0
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::audio_3d_set_drop_off_factor(float factor) { void FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_set_drop_off_factor("<<factor<<")"); audio_3d_set_drop_off_factor(float factor) {
audio_debug("FmodAudioManager::audio_3d_set_drop_off_factor("<<factor<<")");
FMOD_RESULT result; FMOD_RESULT result;
_drop_off_factor = factor; _drop_off_factor = factor;
result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor); result = _system->set3DSettings( _doppler_factor, _distance_factor, _drop_off_factor);
ERRCHECK( result ); ERRCHECK( result );
} }
@ -626,10 +635,11 @@ void FmodAudioManager::audio_3d_set_drop_off_factor(float factor) {
// Access: Public // Access: Public
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
float FmodAudioManager::audio_3d_get_drop_off_factor() const { float FmodAudioManager::
audio_debug("FmodAudioManager::audio_3d_get_drop_off_factor()"); 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 // Access: Public
// Description: NOT USED FOR FMOD-EX!!! // 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 // Access: Public
// Description: NOT USED FOR FMOD-EX!!! // Description: NOT USED FOR FMOD-EX!!!
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
unsigned int FmodAudioManager::get_concurrent_sound_limit() const { unsigned int FmodAudioManager::
return 0; get_concurrent_sound_limit() const {
return 1000000;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -658,7 +670,8 @@ unsigned int FmodAudioManager::get_concurrent_sound_limit() const {
// Access: Private // Access: Private
// Description: NOT USED FOR FMOD-EX!!! // 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 // Function: FmodAudioManager::uncache_sound
// Access: Public // Access: Public
// Description: NOT USED FOR FMOD-EX!!! // 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) { void FmodAudioManager::
audio_debug("FmodAudioManager::uncache_sound(\""<<file_name<<"\")"); uncache_sound(const string& file_name) {
audio_debug("FmodAudioManager::uncache_sound(\""<<file_name<<"\")");
} }
@ -679,21 +693,23 @@ void FmodAudioManager::uncache_sound(const string& file_name) {
// Function: FmodAudioManager::clear_cache // Function: FmodAudioManager::clear_cache
// Access: Public // Access: Public
// Description: NOT USED FOR FMOD-EX!!! // Description: NOT USED FOR FMOD-EX!!!
// Clear out the sound cache. // Clear out the sound cache.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::clear_cache() { void FmodAudioManager::
audio_debug("FmodAudioManager::clear_cache()"); clear_cache() {
audio_debug("FmodAudioManager::clear_cache()");
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: FmodAudioManager::set_cache_limit // Function: FmodAudioManager::set_cache_limit
// Access: Public // Access: Public
// Description: NOT USED FOR FMOD-EX!!! // Description: NOT USED FOR FMOD-EX!!!
// Set the number of sounds that the cache can hold. // Set the number of sounds that the cache can hold.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FmodAudioManager::set_cache_limit(unsigned int count) { void FmodAudioManager::
audio_debug("FmodAudioManager::set_cache_limit(count="<<count<<")"); set_cache_limit(unsigned int count) {
audio_debug("FmodAudioManager::set_cache_limit(count="<<count<<")");
} }
@ -701,12 +717,13 @@ void FmodAudioManager::set_cache_limit(unsigned int count) {
// Function: FmodAudioManager::get_cache_limit // Function: FmodAudioManager::get_cache_limit
// Access: Public // Access: Public
// Description: NOT USED FOR FMOD-EX!!! // Description: NOT USED FOR FMOD-EX!!!
// Gets the number of sounds that the cache can hold. // Gets the number of sounds that the cache can hold.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
unsigned int FmodAudioManager::get_cache_limit() const { unsigned int FmodAudioManager::
audio_debug("FmodAudioManager::get_cache_limit() returning "); get_cache_limit() const {
//return _cache_limit; audio_debug("FmodAudioManager::get_cache_limit() returning ");
return 0; //return _cache_limit;
return 0;
} }

View File

@ -71,7 +71,7 @@
#include "pandabase.h" #include "pandabase.h"
#include "pset.h" #include "pset.h"
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
#include "audioManager.h" #include "audioManager.h"

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@
#include <pandabase.h> #include <pandabase.h>
#ifdef HAVE_FMOD //[ #ifdef HAVE_FMODEX //[
#include "audioSound.h" #include "audioSound.h"