Moved some audio code around because the previous organisation was confusing, there was some SFX code among the music code
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5227 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c70a8536d2
commit
c12618a48a
@ -512,6 +512,26 @@ const std::string SFXManager::getErrorString(int err)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void SFXManager::positionListener(const Vec3 &position, const Vec3 &front)
|
||||||
|
{
|
||||||
|
if (!UserConfigParams::m_sfx || !m_initialized) return;
|
||||||
|
|
||||||
|
//forward vector
|
||||||
|
m_listenerVec[0] = front.getX();
|
||||||
|
m_listenerVec[1] = front.getY();
|
||||||
|
m_listenerVec[2] = front.getZ();
|
||||||
|
|
||||||
|
//up vector
|
||||||
|
m_listenerVec[3] = 0;
|
||||||
|
m_listenerVec[4] = 0;
|
||||||
|
m_listenerVec[5] = 1;
|
||||||
|
|
||||||
|
alListener3f(AL_POSITION, position.getX(), position.getY(), position.getZ());
|
||||||
|
alListenerfv(AL_ORIENTATION, m_listenerVec);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void SFXManager::quickSound(const char* soundType)
|
void SFXManager::quickSound(const char* soundType)
|
||||||
{
|
{
|
||||||
if(!sfxAllowed()) return;
|
if(!sfxAllowed()) return;
|
||||||
|
@ -110,6 +110,9 @@ private:
|
|||||||
/** To play non-positional sounds without having to create a new object for each */
|
/** To play non-positional sounds without having to create a new object for each */
|
||||||
static std::map<std::string, SFXBase*> m_quick_sounds;
|
static std::map<std::string, SFXBase*> m_quick_sounds;
|
||||||
|
|
||||||
|
/** listener vector (position vector + up vector) */
|
||||||
|
float m_listenerVec[6];
|
||||||
|
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
float m_master_gain;
|
float m_master_gain;
|
||||||
|
|
||||||
@ -142,6 +145,8 @@ public:
|
|||||||
static bool checkError(const std::string &context);
|
static bool checkError(const std::string &context);
|
||||||
static const std::string getErrorString(int err);
|
static const std::string getErrorString(int err);
|
||||||
|
|
||||||
|
void positionListener(const Vec3 &position, const Vec3 &front);
|
||||||
|
|
||||||
/** Positional sound is cool, but creating a new object just to play a simple
|
/** Positional sound is cool, but creating a new object just to play a simple
|
||||||
menu sound is not. This function allows for 'quick sounds' in a single call.*/
|
menu sound is not. This function allows for 'quick sounds' in a single call.*/
|
||||||
void quickSound(const char* soundName);
|
void quickSound(const char* soundName);
|
||||||
|
@ -166,6 +166,7 @@ void SoundManager::setMasterMusicVolume(float gain)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
MusicInformation* SoundManager::getMusicInformation(const std::string& filename)
|
MusicInformation* SoundManager::getMusicInformation(const std::string& filename)
|
||||||
{
|
{
|
||||||
if(filename=="")
|
if(filename=="")
|
||||||
@ -185,19 +186,3 @@ MusicInformation* SoundManager::getMusicInformation(const std::string& filename)
|
|||||||
} // getMusicInformation
|
} // getMusicInformation
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void SoundManager::positionListener(const Vec3 &position, const Vec3 &front)
|
|
||||||
{
|
|
||||||
if(!UserConfigParams::m_sfx || !m_initialized) return;
|
|
||||||
|
|
||||||
//forward vector
|
|
||||||
m_listenerVec[0] = front.getX();
|
|
||||||
m_listenerVec[1] = front.getY();
|
|
||||||
m_listenerVec[2] = front.getZ();
|
|
||||||
//up vector
|
|
||||||
m_listenerVec[3] = 0;
|
|
||||||
m_listenerVec[4] = 0;
|
|
||||||
m_listenerVec[5] = 1;
|
|
||||||
|
|
||||||
alListener3f(AL_POSITION, position.getX(), position.getY(), position.getZ());
|
|
||||||
alListenerfv(AL_ORIENTATION, m_listenerVec);
|
|
||||||
}
|
|
||||||
|
@ -43,14 +43,12 @@ private:
|
|||||||
m_allMusic;
|
m_allMusic;
|
||||||
|
|
||||||
void loadMusicInformation();
|
void loadMusicInformation();
|
||||||
float m_listenerVec[6];
|
|
||||||
float m_masterGain;
|
float m_masterGain;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundManager();
|
SoundManager();
|
||||||
virtual ~SoundManager();
|
virtual ~SoundManager();
|
||||||
|
|
||||||
void positionListener(const Vec3 &position, const Vec3 &front);
|
|
||||||
void startMusic(MusicInformation* mi);
|
void startMusic(MusicInformation* mi);
|
||||||
void stopMusic();
|
void stopMusic();
|
||||||
bool initialized() const {return m_initialized; }
|
bool initialized() const {return m_initialized; }
|
||||||
|
@ -201,9 +201,10 @@ void Camera::smoothMoveCamera(float dt, const Vec3 &wanted_position,
|
|||||||
m_camera->setPosition(current_position);
|
m_camera->setPosition(current_position);
|
||||||
m_camera->setTarget(current_target);
|
m_camera->setTarget(current_target);
|
||||||
|
|
||||||
if(race_manager->getNumLocalPlayers() < 2)
|
if (race_manager->getNumLocalPlayers() < 2)
|
||||||
sound_manager->positionListener(current_position,
|
{
|
||||||
current_target - current_position);
|
sfx_manager->positionListener(current_position, current_target - current_position);
|
||||||
|
}
|
||||||
|
|
||||||
// The following settings give a debug camera which shows the track from
|
// The following settings give a debug camera which shows the track from
|
||||||
// high above the kart straight down.
|
// high above the kart straight down.
|
||||||
|
@ -213,7 +213,7 @@ void AbstractStateManager::resetAndGoToScreen(Screen* screen)
|
|||||||
input_manager->setMode(InputManager::MENU);
|
input_manager->setMode(InputManager::MENU);
|
||||||
m_menu_stack.push_back(name);
|
m_menu_stack.push_back(name);
|
||||||
setGameState(MENU);
|
setGameState(MENU);
|
||||||
sound_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
sfx_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
||||||
switchToScreen(name.c_str());
|
switchToScreen(name.c_str());
|
||||||
getCurrentScreen()->init();
|
getCurrentScreen()->init();
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ void AbstractStateManager::resetAndSetStack(Screen* screens[])
|
|||||||
|
|
||||||
setGameState(MENU);
|
setGameState(MENU);
|
||||||
|
|
||||||
sound_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
sfx_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
||||||
switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
|
switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
|
||||||
getCurrentScreen()->init();
|
getCurrentScreen()->init();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user