stk-code_catmod/src/sound_manager.hpp
hikerstk 39eae930da For music that doesn't have a faster version specified in the music
information files, the pitch is increased creating a somewhat faster
version. The maximum pitch can be specified in the information files
(keyword 'max-pitch', defaults to 0.1), and the duration over which
the pitch is increased as 'faster-time' (default: 1 second).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1725 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-24 03:07:53 +00:00

86 lines
3.3 KiB
C++

// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 Patrick Ammann <pammann@aro.ch>
// Copyright (C) 2008 Patrick Ammann <pammann@aro.ch>, Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_SOUNDMANAGER_H
#define HEADER_SOUNDMANAGER_H
#include <map>
#include <vector>
#include <string>
#include "music.hpp"
#include "music_information.hpp"
#include "sfx.hpp"
enum enumSFX {SOUND_UGH, SOUND_WINNER, SOUND_CRASH, SOUND_GRAB,
SOUND_SHOT, SOUND_WEE, SOUND_EXPLOSION,
SOUND_BZZT, SOUND_BEEP,
SOUND_BACK_MENU, SOUND_USE_ANVIL, SOUND_USE_PARACHUTE,
SOUND_SELECT_MENU, SOUND_MOVE_MENU, SOUND_FULL,
SOUND_PRESTART, SOUND_START, SOUND_MISSILE_LOCK,
NUM_SOUNDS};
class SoundManager
{
private:
typedef std::vector<SFX*> SFXsType;
SFXsType m_sfxs;
Music *m_normal_music,
*m_fast_music;
MusicInformation const *m_music_information;
bool m_initialized; //If the sound could not be initialized, e.g.
//if the player doesn't has a sound card, we want
//to avoid anything sound related so we crash the game.
std::map<std::string, const MusicInformation*>
m_allMusic;
void loadMusicInformation();
enum {SOUND_NORMAL, // normal music is played
SOUND_FADING, // normal music fading out, faster music fading in
SOUND_FASTER, // change pitch of normal music (i.e. no faster avail)
SOUND_FAST} // playing faster music or max pitch reached
m_mode;
float m_time_since_faster;
public:
SoundManager();
virtual ~SoundManager();
void update(float dt);
void playSfx(unsigned int id);
void playMusic(const MusicInformation* mi);
void stopMusic();
void pauseMusic();
void resumeMusic();
void switchToFastMusic();
const MusicInformation* getCurrentMusic() {return m_music_information; }
const MusicInformation* getMusicInformation(const std::string& filename);
void loadMusicFromOneDir(const std::string& dir);
void addMusicToTracks() const;
};
extern SoundManager* sound_manager;
#endif // HEADER_SOUNDMANAGER_H