00001 // Filename: audioManager.h 00002 // Created by: skyler (June 6, 2001) 00003 // Prior system by: cary 00004 // 00005 //////////////////////////////////////////////////////////////////// 00006 // 00007 // PANDA 3D SOFTWARE 00008 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00009 // 00010 // All use of this software is subject to the terms of the Panda 3d 00011 // Software license. You should have received a copy of this license 00012 // along with this source code; you will also find a current copy of 00013 // the license at http://www.panda3d.org/license.txt . 00014 // 00015 // To contact the maintainers of this program write to 00016 // panda3d@yahoogroups.com . 00017 // 00018 //////////////////////////////////////////////////////////////////// 00019 00020 #ifndef __AUDIO_MANAGER_H__ 00021 #define __AUDIO_MANAGER_H__ 00022 00023 #include "config_audio.h" 00024 #include "audioSound.h" 00025 00026 typedef PT(AudioManager) Create_AudioManager_proc(); 00027 00028 00029 class EXPCL_PANDA AudioManager : public ReferenceCount { 00030 PUBLISHED: 00031 // Create an AudioManager for each category of sounds you have. 00032 // E.g. 00033 // MySoundEffects = create_AudioManager::AudioManager(); 00034 // MyMusicManager = create_AudioManager::AudioManager(); 00035 // ... 00036 // my_sound = MySoundEffects.get_sound("neatSfx.mp3"); 00037 // my_music = MyMusicManager.get_sound("introTheme.mid"); 00038 00039 static PT(AudioManager) create_AudioManager(); 00040 virtual ~AudioManager() {} 00041 virtual bool is_valid() = 0; 00042 00043 // Get a sound: 00044 virtual PT(AudioSound) get_sound(const string& file_name) = 0; 00045 PT(AudioSound) get_null_sound(); 00046 00047 // Tell the AudioManager there is no need to keep this one cached. 00048 // This doesn't break any connection between AudioSounds that have 00049 // already given by get_sound() from this manager. It's 00050 // only affecting whether the AudioManager keeps a copy of the sound 00051 // in its pool/cache. 00052 virtual void uncache_sound(const string& file_name) = 0; 00053 virtual void clear_cache() = 0; 00054 virtual void set_cache_limit(int count) = 0; 00055 virtual int get_cache_limit() = 0; 00056 00057 // if set, turn off any currently-playing sounds before playing 00058 // a new one (useful for midi songs) 00059 void set_mutually_exclusive(bool bExclusive); 00060 00061 // Control volume: 00062 // FYI: 00063 // If you start a sound with the volume off and turn the volume 00064 // up later, you'll hear the sound playing at that late point. 00065 // 0 = minimum; 1.0 = maximum. 00066 // inits to 1.0. 00067 virtual void set_volume(float volume) = 0; 00068 virtual float get_volume() = 0; 00069 00070 // Turn the manager on or off. 00071 // If you play a sound while the manager is inactive, it won't start. 00072 // If you deactivate the manager while sounds are playing, they'll 00073 // stop. 00074 // If you activate the manager while looping sounds are playing 00075 // (those that have a loop_count of zero), 00076 // they will start playing from the begining of their loop. 00077 // inits to true. 00078 virtual void set_active(bool flag) = 0; 00079 virtual bool get_active() = 0; 00080 00081 public: 00082 static void register_AudioManager_creator(Create_AudioManager_proc* proc); 00083 00084 protected: 00085 static Create_AudioManager_proc* _create_AudioManager; 00086 bool _bExclusive; 00087 PT(AudioSound) _null_sound; 00088 00089 AudioManager() { 00090 // intentionally blank. 00091 } 00092 }; 00093 00094 #endif /* __AUDIO_MANAGER_H__ */