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

panda/src/audio/audioSound.h

Go to the documentation of this file.
00001 // Filename: audioSound.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 __AUDIOSOUND_H__
00021 #define __AUDIOSOUND_H__
00022 
00023 #include "config_audio.h"
00024 #include <referenceCount.h>
00025 #include <namable.h>
00026 #include <pointerTo.h>
00027 
00028 
00029 class AudioManager;
00030 
00031 class EXPCL_PANDA AudioSound : public ReferenceCount {
00032 PUBLISHED:
00033   virtual ~AudioSound() {}
00034   
00035   // For best compatability, set the loop_count,
00036   // volume, and balance, prior to calling play().  You may
00037   // set them while they're playing, but it's implementation
00038   // specific whether you get the results.
00039   // - Calling play() a second time on the same sound before it is
00040   //   finished will start the sound again (creating a skipping or
00041   //   stuttering effect).
00042   virtual void play() = 0;
00043   virtual void stop() = 0;
00044   
00045   // loop: false = play once; true = play forever.
00046   // inits to false.
00047   virtual void set_loop(bool loop=true) = 0;
00048   virtual bool get_loop() const = 0;
00049   
00050   // loop_count: 0 = forever; 1 = play once; n = play n times.
00051   // inits to 1.
00052   virtual void set_loop_count(unsigned long loop_count=1) = 0;
00053   virtual unsigned long get_loop_count() const = 0;
00054   
00055   // Control time position within the sound.
00056   // This is similar (in concept) to the seek position within
00057   // a file.
00058   // time in seconds: 0 = beginning; length() = end.
00059   // inits to 0.0.
00060   // - Unlike the other get_* and set_* calls for a sound, the
00061   //   current time position will change while the sound is playing.
00062   //   To play the same sound from a time offset a second time,
00063   //   explicitly set the time position again.  When looping, the
00064   //   second and later loops will start from the beginning of the
00065   //   sound.
00066   // - If a sound is playing, calling get_time() repeatedly will
00067   //   return different results over time.  e.g.:
00068   //   float percent_complete = s.get_time() / s.length();
00069   virtual void set_time(float start_time=0.0) = 0;
00070   virtual float get_time() const = 0;
00071   
00072   // 0 = minimum; 1.0 = maximum.
00073   // inits to 1.0.
00074   virtual void set_volume(float volume=1.0) = 0;
00075   virtual float get_volume() const = 0;
00076   
00077   // -1.0 is hard left
00078   // 0.0 is centered
00079   // 1.0 is hard right
00080   // inits to 0.0.
00081   virtual void set_balance(float balance_right=0.0) = 0;
00082   virtual float get_balance() const = 0;
00083 
00084   // inits to manager's state.
00085   virtual void set_active(bool flag=true) = 0;
00086   virtual bool get_active() const = 0;
00087   
00088   // There is no set_name(), this is intentional.
00089   virtual const string& get_name() const = 0;
00090   
00091   // return: playing time in seconds.
00092   virtual float length() const = 0;
00093 
00094   enum SoundStatus { BAD, READY, PLAYING };
00095   virtual SoundStatus status() const = 0;
00096 
00097 protected:
00098   AudioSound() {
00099     // Intentionally blank.
00100   }
00101 
00102   friend class AudioManager;
00103 };
00104 
00105 #endif /* __AUDIOSOUND_H__ */

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