7 #include "../generic/managed.h"
8 #include "../generic/range_value.h"
10 #include "../math/vec3.h"
17 typedef uint32_t AudioBufferID;
18 typedef uint32_t AudioSourceID;
20 typedef std::function<int32_t (AudioBufferID)> StreamFunc;
22 typedef std::size_t PlayingSoundID;
30 DISTANCE_MODEL_POSITIONAL,
31 DISTANCE_MODEL_AMBIENT,
32 DISTANCE_MODEL_DEFAULT = DISTANCE_MODEL_POSITIONAL
41 static PlayingSoundID counter_;
47 AudioSourceID source_;
48 std::vector<AudioBufferID> buffers_;
49 std::weak_ptr<Sound> sound_;
50 StreamFunc stream_func_;
52 AudioRepeat loop_stream_;
57 bool first_update_ =
true;
63 PlayingSound(
AudioSource& parent, std::weak_ptr<Sound> sound, AudioRepeat loop_stream, DistanceModel model=DISTANCE_MODEL_POSITIONAL);
66 PlayingSoundID id()
const {
70 void update(
float dt);
73 bool is_playing()
const;
77 void set_stream_func(StreamFunc func) { stream_func_ = func; }
79 bool is_dead()
const {
return is_dead_; }
83 void set_reference_distance(
float dist);
90 std::weak_ptr<PlayingSound> ptr_;
105 auto lk = ptr_.lock();
113 bool is_valid()
const {
114 return bool(ptr_.lock());
117 operator bool()
const {