15 #ifndef __MILES_AUDIO_MANAGER_H__ //[ 16 #define __MILES_AUDIO_MANAGER_H__ 19 #ifdef HAVE_RAD_MSS //[ 34 class MilesAudioSound;
36 class EXPCL_MILES_AUDIO MilesAudioManager:
public AudioManager {
41 virtual ~MilesAudioManager();
45 virtual bool is_valid();
47 virtual PT(
AudioSound) get_sound(
const Filename &file_name,
bool positional =
false,
int mode=SM_heuristic);
48 virtual PT(
AudioSound) get_sound(
MovieAudio *sound,
bool positional =
false,
int mode=SM_heuristic);
49 virtual void uncache_sound(
const Filename &file_name);
50 virtual void clear_cache();
51 virtual void set_cache_limit(
unsigned int count);
52 virtual unsigned int get_cache_limit()
const;
54 virtual void set_volume(PN_stdfloat volume);
55 virtual PN_stdfloat get_volume()
const;
57 void set_play_rate(PN_stdfloat play_rate);
58 PN_stdfloat get_play_rate()
const;
60 virtual void set_active(
bool active);
61 virtual bool get_active()
const;
63 virtual void set_concurrent_sound_limit(
unsigned int limit = 0);
64 virtual unsigned int get_concurrent_sound_limit()
const;
66 virtual void reduce_sounds_playing_to(
unsigned int count);
67 virtual void stop_all_sounds();
72 void release_sound(MilesAudioSound *audioSound);
78 virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat xy, PN_stdfloat xz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz);
79 virtual void audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz);
80 virtual void audio_3d_set_distance_factor(PN_stdfloat factor);
81 virtual PN_stdfloat audio_3d_get_distance_factor()
const;
82 virtual void audio_3d_set_doppler_factor(PN_stdfloat factor);
83 virtual PN_stdfloat audio_3d_get_doppler_factor()
const;
84 virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor);
85 virtual PN_stdfloat audio_3d_get_drop_off_factor()
const;
86 virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=
nullptr, LVecBase3 *speaker3=
nullptr, LVecBase3 *speaker4=
nullptr, LVecBase3 *speaker5=
nullptr, LVecBase3 *speaker6=
nullptr, LVecBase3 *speaker7=
nullptr, LVecBase3 *speaker8=
nullptr, LVecBase3 *speaker9=
nullptr);
88 virtual void output(std::ostream &out)
const;
89 virtual void write(std::ostream &out)
const;
93 void do_reduce_sounds_playing_to(
unsigned int count);
94 void do_clear_cache();
96 void start_service_stream(HSTREAM stream);
97 void stop_service_stream(HSTREAM stream);
99 void most_recently_used(
const std::string &path);
100 void uncache_a_sound();
102 void starting_sound(MilesAudioSound *audio);
103 void stopping_sound(MilesAudioSound *audio);
106 PT(SoundData) load(
const Filename &file_name);
108 void thread_main(
volatile bool &keep_running);
109 void do_service_streams();
112 class StreamThread :
public Thread {
114 StreamThread(MilesAudioManager *mgr);
115 virtual void thread_main();
117 MilesAudioManager *_mgr;
118 volatile bool _keep_running;
126 PN_stdfloat get_length();
127 void set_length(PN_stdfloat length);
131 vector_uchar _raw_data;
135 typedef pmap<std::string, PT(SoundData) > SoundMap;
140 AudioSet _sounds_on_loan;
144 SoundsPlaying _sounds_playing;
151 PN_stdfloat _play_rate;
154 bool _cleanup_required;
155 unsigned int _concurrent_sound_limit;
162 bool _sounds_finished;
165 PT(StreamThread) _stream_thread;
174 static void init_type() {
175 AudioManager::init_type();
177 AudioManager::get_class_type());
180 return get_class_type();
182 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
187 friend class MilesAudioSound;
188 friend class MilesAudioSample;
189 friend class MilesAudioSequence;
190 friend class MilesAudioStream;
193 EXPCL_MILES_AUDIO
AudioManager *Create_MilesAudioManager();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL map.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight reentrant mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A standard mutex, or mutual exclusion lock.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL deque.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
A condition variable, usually used to communicate information about changing state to a thread that i...
virtual void update()
Must be called every frame.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void shutdown()
Call this at exit time to shut down the audio system.
A base class for all things that want to be reference-counted.
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL set.
TypeHandle is the identifier used to differentiate C++ class types.
A MovieAudio is actually any source that provides a sequence of audio samples.
virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr)
For use only with Miles.