Panda3D
 All Classes Functions Variables Enumerations
milesAudioSound.h
1 // Filename: milesAudioSound.h
2 // Created by: drose (30Jul07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MILESAUDIOSOUND_H
16 #define MILESAUDIOSOUND_H
17 
18 #include "pandabase.h"
19 #ifdef HAVE_RAD_MSS //[
20 
21 #include "audioSound.h"
22 #include "milesAudioManager.h"
23 #include "mss.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : MilesAudioSound
27 // Description : The base class for both MilesAudioStream and
28 // MilesAudioSample.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_MILES_AUDIO MilesAudioSound : public AudioSound {
31 protected:
32  MilesAudioSound(MilesAudioManager *manager, const string &file_name);
33 
34 public:
35  virtual void set_loop(bool loop=true);
36  virtual bool get_loop() const;
37 
38  virtual void set_loop_count(unsigned long loop_count=1);
39  virtual unsigned long get_loop_count() const;
40 
41  virtual PN_stdfloat get_volume() const;
42  virtual PN_stdfloat get_balance() const;
43  virtual PN_stdfloat get_play_rate() const;
44 
45  virtual void set_time(PN_stdfloat start_time=0.0);
46 
47  virtual void set_active(bool active=true);
48  virtual bool get_active() const;
49 
50  virtual void set_finished_event(const string &event);
51  virtual const string &get_finished_event() const;
52 
53  virtual const string &get_name() const;
54 
55  virtual void cleanup();
56 
57 protected:
58  PT(MilesAudioManager) _manager;
59  string _file_name;
60 
61  PN_stdfloat _volume; // 0..1.0
62  PN_stdfloat _balance; // -1..1
63  PN_stdfloat _play_rate; // 0..1.0
64  unsigned long _loop_count;
65 
66  // _active is for things like a 'turn off sound effects' in
67  // a preferences pannel.
68  // _active is not about whether a sound is currently playing.
69  // Use status() for info on whether the sound is playing.
70  bool _active;
71 
72  // _paused is not like the Pause button on a cd/dvd player.
73  // It is used as a flag to say that the sound was looping when
74  // it was set inactive.
75  bool _paused;
76 
77  // This is the string that throw_event() will throw when the sound
78  // finishes playing. It is not triggered when the sound is stopped
79  // with stop(). Note: no longer implemented.
80  string _finished_event;
81 
82  // This is set whenever we call set_time(). Calling play() will
83  // respect this if it is set, and then reset it.
84  PN_stdfloat _start_time;
85  bool _got_start_time;
86 
87 public:
88  static TypeHandle get_class_type() {
89  return _type_handle;
90  }
91  static void init_type() {
92  AudioSound::init_type();
93  register_type(_type_handle, "MilesAudioSound",
94  AudioSound::get_class_type());
95  }
96  virtual TypeHandle get_type() const {
97  return get_class_type();
98  }
99  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
100 
101 private:
102  static TypeHandle _type_handle;
103 
104  friend class MilesAudioManager;
105 };
106 
107 #include "milesAudioSound.I"
108 
109 #endif //]
110 
111 #endif
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85