Panda3D
Loading...
Searching...
No Matches
milesAudioSound.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 milesAudioSound.h
10 * @author drose
11 * @date 2007-07-30
12 */
13
14#ifndef MILESAUDIOSOUND_H
15#define MILESAUDIOSOUND_H
16
17#include "pandabase.h"
18#ifdef HAVE_RAD_MSS //[
19
20#include "audioSound.h"
21#include "milesAudioManager.h"
22
23#include <mss.h>
24
25/**
26 * The base class for both MilesAudioStream and MilesAudioSample.
27 */
28class EXPCL_MILES_AUDIO MilesAudioSound : public AudioSound {
29protected:
30 MilesAudioSound(MilesAudioManager *manager, const std::string &file_name);
31
32public:
33 virtual void set_loop(bool loop=true);
34 virtual bool get_loop() const;
35
36 virtual void set_loop_count(unsigned long loop_count=1);
37 virtual unsigned long get_loop_count() const;
38
39 virtual PN_stdfloat get_volume() const;
40 virtual PN_stdfloat get_balance() const;
41 virtual PN_stdfloat get_play_rate() const;
42
43 virtual void set_time(PN_stdfloat start_time=0.0);
44
45 virtual void set_active(bool active=true);
46 virtual bool get_active() const;
47
48 virtual void set_finished_event(const std::string &event);
49 virtual const std::string &get_finished_event() const;
50
51 virtual const std::string &get_name() const;
52
53 virtual void cleanup();
54
55protected:
56 PT(MilesAudioManager) _manager;
57 std::string _file_name;
58
59 PN_stdfloat _volume; // 0..1.0
60 PN_stdfloat _balance; // -1..1
61 PN_stdfloat _play_rate; // 0..1.0
62 unsigned long _loop_count;
63
64 // _active is for things like a 'turn off sound effects' in a preferences
65 // pannel. _active is not about whether a sound is currently playing. Use
66 // status() for info on whether the sound is playing.
67 bool _active;
68
69 // _paused is not like the Pause button on a cddvd player. It is used as a
70 // flag to say that the sound was looping when it was set inactive.
71 bool _paused;
72
73 // This is the string that throw_event() will throw when the sound finishes
74 // playing. It is not triggered when the sound is stopped with stop().
75 // Note: no longer implemented.
76 std::string _finished_event;
77
78 // This is set whenever we call set_time(). Calling play() will respect
79 // this if it is set, and then reset it.
80 PN_stdfloat _start_time;
81 bool _got_start_time;
82
83public:
84 static TypeHandle get_class_type() {
85 return _type_handle;
86 }
87 static void init_type() {
88 AudioSound::init_type();
89 register_type(_type_handle, "MilesAudioSound",
90 AudioSound::get_class_type());
91 }
92 virtual TypeHandle get_type() const {
93 return get_class_type();
94 }
95 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
96
97private:
98 static TypeHandle _type_handle;
99
100 friend class MilesAudioManager;
101};
102
103#include "milesAudioSound.I"
104
105#endif //]
106
107#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void set_time(PN_stdfloat start_time=0.0)=0
Control time position within the sound, in seconds.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...