Panda3D
|
00001 // Filename: milesAudioSound.h 00002 // Created by: drose (30Jul07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef MILESAUDIOSOUND_H 00016 #define MILESAUDIOSOUND_H 00017 00018 #include "pandabase.h" 00019 #ifdef HAVE_RAD_MSS //[ 00020 00021 #include "audioSound.h" 00022 #include "milesAudioManager.h" 00023 #include "mss.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : MilesAudioSound 00027 // Description : The base class for both MilesAudioStream and 00028 // MilesAudioSample. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_MILES_AUDIO MilesAudioSound : public AudioSound { 00031 protected: 00032 MilesAudioSound(MilesAudioManager *manager, const string &file_name); 00033 00034 public: 00035 virtual void set_loop(bool loop=true); 00036 virtual bool get_loop() const; 00037 00038 virtual void set_loop_count(unsigned long loop_count=1); 00039 virtual unsigned long get_loop_count() const; 00040 00041 virtual PN_stdfloat get_volume() const; 00042 virtual PN_stdfloat get_balance() const; 00043 virtual PN_stdfloat get_play_rate() const; 00044 00045 virtual void set_time(PN_stdfloat start_time=0.0); 00046 00047 virtual void set_active(bool active=true); 00048 virtual bool get_active() const; 00049 00050 virtual void set_finished_event(const string &event); 00051 virtual const string &get_finished_event() const; 00052 00053 virtual const string &get_name() const; 00054 00055 virtual void cleanup(); 00056 00057 protected: 00058 PT(MilesAudioManager) _manager; 00059 string _file_name; 00060 00061 PN_stdfloat _volume; // 0..1.0 00062 PN_stdfloat _balance; // -1..1 00063 PN_stdfloat _play_rate; // 0..1.0 00064 unsigned long _loop_count; 00065 00066 // _active is for things like a 'turn off sound effects' in 00067 // a preferences pannel. 00068 // _active is not about whether a sound is currently playing. 00069 // Use status() for info on whether the sound is playing. 00070 bool _active; 00071 00072 // _paused is not like the Pause button on a cd/dvd player. 00073 // It is used as a flag to say that the sound was looping when 00074 // it was set inactive. 00075 bool _paused; 00076 00077 // This is the string that throw_event() will throw when the sound 00078 // finishes playing. It is not triggered when the sound is stopped 00079 // with stop(). Note: no longer implemented. 00080 string _finished_event; 00081 00082 // This is set whenever we call set_time(). Calling play() will 00083 // respect this if it is set, and then reset it. 00084 PN_stdfloat _start_time; 00085 bool _got_start_time; 00086 00087 public: 00088 static TypeHandle get_class_type() { 00089 return _type_handle; 00090 } 00091 static void init_type() { 00092 AudioSound::init_type(); 00093 register_type(_type_handle, "MilesAudioSound", 00094 AudioSound::get_class_type()); 00095 } 00096 virtual TypeHandle get_type() const { 00097 return get_class_type(); 00098 } 00099 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00100 00101 private: 00102 static TypeHandle _type_handle; 00103 00104 friend class MilesAudioManager; 00105 }; 00106 00107 #include "milesAudioSound.I" 00108 00109 #endif //] 00110 00111 #endif