Panda3D

milesAudioSample.h

00001 // Filename: milesAudioSample.h
00002 // Created by:  skyler (June 6, 2001)
00003 // Prior system by: cary
00004 //
00005 ////////////////////////////////////////////////////////////////////
00006 //
00007 // PANDA 3D SOFTWARE
00008 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00009 //
00010 // All use of this software is subject to the terms of the revised BSD
00011 // license.  You should have received a copy of this license along
00012 // with this source code in a file named "LICENSE."
00013 //
00014 ////////////////////////////////////////////////////////////////////
00015 
00016 #ifndef MILESAUDIOSAMPLE_H
00017 #define MILESAUDIOSAMPLE_H
00018 
00019 #include "pandabase.h"
00020 #ifdef HAVE_RAD_MSS //[
00021 
00022 #include "milesAudioSound.h"
00023 #include "milesAudioManager.h"
00024 #include "mss.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : MilesAudioSample
00028 // Description : A sound file, such as a WAV or MP3 file, that is
00029 //               preloaded into memory and played from memory.
00030 ////////////////////////////////////////////////////////////////////
00031 class EXPCL_MILES_AUDIO MilesAudioSample : public MilesAudioSound {
00032 private:
00033   MilesAudioSample(MilesAudioManager *manager, 
00034                    MilesAudioManager::SoundData *sd,
00035                    const string &file_name);
00036 
00037 public:
00038   virtual ~MilesAudioSample();
00039   
00040   virtual void play();
00041   virtual void stop();
00042   
00043   virtual float get_time() const;
00044   
00045   virtual void set_volume(float volume=1.0f);
00046   virtual void set_balance(float balance_right=0.0f);
00047   virtual void set_play_rate(float play_rate=1.0f);
00048   
00049   virtual float length() const;
00050 
00051   virtual AudioSound::SoundStatus status() const;
00052 
00053   virtual void cleanup();
00054   virtual void output(ostream &out) const;
00055 
00056   // 3D spatialized sound support.
00057   // Spatialized sound was originally added for FMOD, so there are parts of the
00058   // interface in the Miles implementation that are a little more awkward than
00059   // they would be otherwise.
00060   void set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz);
00061   void get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz);
00062   void set_3d_min_distance(float dist);
00063   float get_3d_min_distance() const;
00064   void set_3d_max_distance(float dist);
00065   float get_3d_max_distance() const;
00066 
00067   virtual float get_speaker_level(int index);
00068   virtual void set_speaker_levels(float level1, float level2=-1.0f, float level3=-1.0f, float level4=-1.0f, float level5=-1.0f, float level6=-1.0f, float level7=-1.0f, float level8=-1.0f, float level9=-1.0f);
00069 
00070 private:
00071   void internal_stop();
00072   static void AILCALLBACK finish_callback(HSAMPLE sample);
00073   void do_set_time(float time);
00074 
00075   PT(MilesAudioManager::SoundData) _sd;
00076   HSAMPLE _sample;
00077   size_t _sample_index;
00078   S32 _original_playback_rate;
00079 
00080 public:
00081   static TypeHandle get_class_type() {
00082     return _type_handle;
00083   }
00084   static void init_type() {
00085     MilesAudioSound::init_type();
00086     register_type(_type_handle, "MilesAudioSample",
00087                   MilesAudioSound::get_class_type());
00088   }
00089   virtual TypeHandle get_type() const {
00090     return get_class_type();
00091   }
00092   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00093 
00094 private:
00095   static TypeHandle _type_handle;
00096 
00097   friend class GlobalMilesManager;
00098   friend class MilesAudioManager;
00099 };
00100 
00101 #include "milesAudioSample.I"
00102 
00103 #endif //]
00104 
00105 #endif  /* MILESAUDIOSAMPLE_H */
 All Classes Functions Variables Enumerations