Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/audiotraits/milesAudioSound.h

Go to the documentation of this file.
00001 // Filename: milesAudioSound.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 __MILES_AUDIO_SOUND_H__
00021 #define __MILES_AUDIO_SOUND_H__
00022 
00023 #include <pandabase.h>
00024 #ifdef HAVE_RAD_MSS //[
00025 
00026 #include "audioSound.h"
00027 #include "milesAudioManager.h"
00028 #include "mss.h"
00029 
00030 class EXPCL_MILES_AUDIO MilesAudioSound : public AudioSound {
00031 public:
00032   ~MilesAudioSound();
00033   
00034   // For best compatability, set the loop_count,
00035   // volume, and balance, prior to calling play().  You may
00036   // set them while they're playing, but it's implementation
00037   // specific whether you get the results.
00038   // - Calling play() a second time on the same sound before it is
00039   //   finished will start the sound again (creating a skipping or
00040   //   stuttering effect).
00041   void play();
00042   void stop();
00043 
00044   // loop: false = play once; true = play forever.
00045   // inits to false.
00046   void set_loop(bool loop=true);
00047   bool get_loop() const;
00048   
00049   // loop_count: 0 = forever; 1 = play once; n = play n times.
00050   // inits to 1.
00051   void set_loop_count(unsigned long loop_count=1);
00052   unsigned long get_loop_count() const;
00053   
00054   // Control time position within the sound.
00055   // This is similar (in concept) to the seek position within
00056   // a file.
00057   // time in seconds: 0 = beginning; length() = end.
00058   // inits to 0.0.
00059   // - Unlike the other get_* and set_* calls for a sound, the
00060   //   current time position will change while the sound is playing.
00061   //   To play the same sound from a time offset a second time,
00062   //   explicitly set the time position again.  When looping, the
00063   //   second and later loops will start from the beginning of the
00064   //   sound.
00065   // - If a sound is playing, calling get_time() repeatedly will
00066   //   return different results over time.  e.g.:
00067   //   float percent_complete = s.get_time() / s.length();
00068   void set_time(float time=0.0f);
00069   float get_time() const;
00070   
00071   // 0 = minimum; 1.0 = maximum.
00072   // inits to 1.0.
00073   void set_volume(float volume=1.0f);
00074   float get_volume() const;
00075   
00076   // -1.0 is hard left
00077   // 0.0 is centered
00078   // 1.0 is hard right
00079   // inits to 0.0.
00080   void set_balance(float balance_right=0.0f);
00081   float get_balance() const;
00082 
00083   // inits to manager's state.
00084   void set_active(bool active=true);
00085   bool get_active() const;
00086   
00087   const string& get_name() const;
00088   
00089   // return: playing time in seconds.
00090   float length() const;
00091 
00092   AudioSound::SoundStatus status() const;
00093 
00094 protected:
00095     // halt is like stop(), except it should not be called by the user.
00096     // halt() does not change the "paused" status of a sound, it just stops 
00097     // it from playing.  This is useful when the sound needs to be deactivated
00098     void halt(void);
00099 
00100 private:
00101   HAUDIO _audio;
00102   PT(MilesAudioManager) _manager;
00103   float _volume; // 0..1.0
00104   float _balance; // -1..1
00105   mutable float _length; // in seconds.
00106   unsigned long _loop_count;
00107   string _file_name;
00108   bool _active;
00109   bool _paused;
00110 
00111   MilesAudioSound(MilesAudioManager* manager, 
00112       HAUDIO audio, string file_name, float length=0.0f);
00113 
00114 
00115   friend class MilesAudioManager;
00116 };
00117 
00118 #include "milesAudioSound.I"
00119 
00120 #endif //]
00121 
00122 #endif /* __MILES_AUDIO_SOUND_H__ */

Generated on Fri May 2 00:34:33 2003 for Panda by doxygen1.3