00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- 00002 00003 this file is part of rcssserver3D 00004 Fri May 9 2003 00005 Copyright (C) 2002,2003 Koblenz University 00006 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group 00007 $Id: soundserver.h,v 1.6 2004/03/22 11:18:03 rollmark Exp $ 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; version 2 of the License. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 */ 00022 #ifndef KEROSIN_SOUNDSERVER_H 00023 #define KEROSIN_SOUNDSERVER_H 00024 00025 /* $Id: soundserver.h,v 1.6 2004/03/22 11:18:03 rollmark Exp $ 00026 00027 SoundServer 00028 00029 The SoundServer is the engine object which lets the application satisfy 00030 its audio needs. The SoundServer is an access layer to a specific SoundSystem. 00031 Another purpose of the SoundServer is managing a cache of SoundObjects. Actually, 00032 we use three distinctive caches, one for effects, one for modules and one for 00033 streams. 00034 00035 NOTE: 00036 00037 HISTORY: 00038 18.09.01 - MK 00039 - Initial version 00040 20.09.01 - MK 00041 - Added caching 00042 11.10.01 - MK 00043 - Made singleton functionality more secure 00044 00045 TODO: 00046 - expose more functionality 00047 00048 TOFIX: 00049 */ 00050 00051 #include <list> 00052 #include <zeitgeist/class.h> 00053 #include <zeitgeist/leaf.h> 00054 00055 namespace kerosin 00056 { 00057 00058 // forward declarations 00059 class SoundSystem; 00060 class SoundObject; 00061 class SoundEffect; 00062 class SoundStream; 00063 class SoundModule; 00064 class SystemWindow; 00065 00066 class SoundServer : public zeitgeist::Leaf 00067 { 00068 // 00069 // Types 00070 // 00071 public: 00072 // sound quality levels 00073 enum ESoundQuality 00074 { 00075 SOUNDQUALITY_BEST = 48000, // above CD quality (slowest) 00076 SOUNDQUALITY_GOOD = 44100, // CD quality 00077 SOUNDQUALITY_AVERAGE = 22000, // radio quality 00078 SOUNDQUALITY_BAD = 11000, // bad quality 00079 SOUNDQUALITY_VERYBAD = 8000 // very bad quality (fastest) 00080 }; 00081 private: 00082 #ifdef HAVE_HASH_MAP 00083 typedef std::hash_map<std::string, boost::shared_ptr<SoundObject> > TSoundHashMap; 00084 #else 00085 typedef std::map<std::string, boost::shared_ptr<SoundObject> > TSoundHashMap; 00086 #endif 00087 00088 // 00089 // Methods 00090 // 00091 public: 00092 SoundServer(); 00093 virtual ~SoundServer(); 00094 00095 bool Init(const std::string &sndSysName); 00096 00097 float GetCPU(); 00098 00099 boost::shared_ptr<SoundEffect> LoadEffect(const std::string& inName); 00100 boost::shared_ptr<SoundStream> LoadStream(const std::string& inName); 00101 boost::shared_ptr<SoundModule> LoadModule(const std::string& inName); 00102 00103 // 00104 // Members 00105 // 00106 private: 00108 void Reset(); 00109 00111 bool LoadSoundObject(const std::string& inName, const TSoundHashMap& map, boost::shared_ptr<SoundObject> &soundObject) const; 00112 00113 boost::shared_ptr<SoundSystem> mSoundSystem; 00114 00115 TSoundHashMap mEffects; 00116 TSoundHashMap mModules; 00117 TSoundHashMap mStreams; 00118 00119 00120 ESoundQuality mQuality; // the frequency which will be used [default=SOUNDQUALITY_BEST] 00121 00122 // make singleton functionality more secure 00123 SoundServer(const SoundServer&); 00124 SoundServer& operator=(const SoundServer&); 00125 }; 00126 00127 DECLARE_CLASS(SoundServer); 00128 00129 } //namespace kerosin 00130 00131 #endif //KEROSIN_SOUNDSERVER_H