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