Panda3D
 All Classes Functions Variables Enumerations
milesAudioSample.h
1 // Filename: milesAudioSample.h
2 // Created by: skyler (June 6, 2001)
3 // Prior system by: cary
4 //
5 ////////////////////////////////////////////////////////////////////
6 //
7 // PANDA 3D SOFTWARE
8 // Copyright (c) Carnegie Mellon University. All rights reserved.
9 //
10 // All use of this software is subject to the terms of the revised BSD
11 // license. You should have received a copy of this license along
12 // with this source code in a file named "LICENSE."
13 //
14 ////////////////////////////////////////////////////////////////////
15 
16 #ifndef MILESAUDIOSAMPLE_H
17 #define MILESAUDIOSAMPLE_H
18 
19 #include "pandabase.h"
20 #ifdef HAVE_RAD_MSS //[
21 
22 #include "milesAudioSound.h"
23 #include "milesAudioManager.h"
24 #include "mss.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : MilesAudioSample
28 // Description : A sound file, such as a WAV or MP3 file, that is
29 // preloaded into memory and played from memory.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_MILES_AUDIO MilesAudioSample : public MilesAudioSound {
32 private:
33  MilesAudioSample(MilesAudioManager *manager,
34  MilesAudioManager::SoundData *sd,
35  const string &file_name);
36 
37 public:
38  virtual ~MilesAudioSample();
39 
40  virtual void play();
41  virtual void stop();
42 
43  virtual PN_stdfloat get_time() const;
44 
45  virtual void set_volume(PN_stdfloat volume=1.0f);
46  virtual void set_balance(PN_stdfloat balance_right=0.0f);
47  virtual void set_play_rate(PN_stdfloat play_rate=1.0f);
48 
49  virtual PN_stdfloat length() const;
50 
51  virtual AudioSound::SoundStatus status() const;
52 
53  virtual void cleanup();
54  virtual void output(ostream &out) const;
55 
56  // 3D spatialized sound support.
57  // Spatialized sound was originally added for FMOD, so there are parts of the
58  // interface in the Miles implementation that are a little more awkward than
59  // they would be otherwise.
60  void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz);
61  void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz);
62  void set_3d_min_distance(PN_stdfloat dist);
63  PN_stdfloat get_3d_min_distance() const;
64  void set_3d_max_distance(PN_stdfloat dist);
65  PN_stdfloat get_3d_max_distance() const;
66 
67  virtual PN_stdfloat get_speaker_level(int index);
68  virtual void set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2=-1.0f, PN_stdfloat level3=-1.0f, PN_stdfloat level4=-1.0f, PN_stdfloat level5=-1.0f, PN_stdfloat level6=-1.0f, PN_stdfloat level7=-1.0f, PN_stdfloat level8=-1.0f, PN_stdfloat level9=-1.0f);
69 
70 private:
71  void internal_stop();
72  static void AILCALLBACK finish_callback(HSAMPLE sample);
73  void do_set_time(PN_stdfloat time);
74 
75  PT(MilesAudioManager::SoundData) _sd;
76  HSAMPLE _sample;
77  size_t _sample_index;
78  S32 _original_playback_rate;
79 
80 public:
81  static TypeHandle get_class_type() {
82  return _type_handle;
83  }
84  static void init_type() {
85  MilesAudioSound::init_type();
86  register_type(_type_handle, "MilesAudioSample",
87  MilesAudioSound::get_class_type());
88  }
89  virtual TypeHandle get_type() const {
90  return get_class_type();
91  }
92  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
93 
94 private:
95  static TypeHandle _type_handle;
96 
97  friend class GlobalMilesManager;
98  friend class MilesAudioManager;
99 };
100 
101 #include "milesAudioSample.I"
102 
103 #endif //]
104 
105 #endif /* MILESAUDIOSAMPLE_H */
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85