Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
audio_emitter_base.hpp
Go to the documentation of this file.
1
8
#pragma once
9
#include "
../assets.hpp
"
10
11
#include <
toast/export.hpp
>
12
#include <
toast/world/node_3d.hpp
>
13
14
namespace
toast {
15
23
class
TOAST_API [[ToastNode, Hidden, Color(
"Beige"
), Icon(
"AudioStreamPlayer"
)]]
AudioEmitterBase
:
public
Node3D
{
24
public
:
25
[[Button]]
26
void
play();
27
28
[[Button]]
29
void
stop();
30
31
void
pause(
bool
value);
32
void
setParameter(std::string_view
name
,
float
value)
const
;
33
void
setParameter(std::string_view
name
,
bool
value)
const
;
34
[[nodiscard]]
35
auto
isPlaying()
const
-> bool;
36
37
void
event(std::string_view path);
38
void
event(
toast::UID
uid
);
39
void
playOnEnable(
bool
value);
40
void
volume(
float
value);
41
void
pitch(
float
value);
42
void
allowFadeout(
bool
value);
43
44
void
dopplerScale(
float
value);
45
void
calculateVelocity(
bool
value);
46
void
overrideAttenuation(
bool
value);
47
void
minDistance(
float
value);
48
void
maxDistance(
float
value);
49
50
signals::Signal<std::string_view> audio_started;
51
signals::Signal<std::string_view> audio_stopped;
52
signals::Signal<bool> audio_paused;
53
54
protected
:
55
virtual
auto
emitterPosition
(
const
glm::vec3&
listener
)
56
-> glm::vec3;
57
virtual
auto
emitterForward() -> glm::vec3;
58
virtual
auto
emitterUp() -> glm::vec3;
59
60
private
:
61
void
updateInspectorMessages()
override
;
62
void
onEnable();
63
void
onDisable();
64
void
begin();
65
void
lateTick();
66
void
update3DState();
67
void
applyProperties()
const
;
68
69
[[
Reflect
, Name(
"Audio Event"
)]]
70
assets::Handle<assets::AudioEvent>
m_event;
71
72
[[
Reflect
]]
73
bool
m_play_on_enable =
false
;
74
75
[[
Reflect
, Range(0.0, 1.0)]]
76
float
m_volume = 1.0f;
77
78
[[
Reflect
, Range(0.5, 2.0)]]
79
float
m_pitch = 1.0f;
80
81
[[
Reflect
]]
82
bool
m_allow_fadeout =
true
;
83
84
[[
Reflect
, Range(0.0, 5.0)]]
85
float
m_doppler_scale = 1.0f;
86
87
[[
Reflect
]]
88
bool
m_calculate_velocity =
true
;
89
90
[[
Reflect
, Group(
"Override Attenuation"
)]]
91
bool
m_override_attenuation =
false
;
92
93
[[
Reflect
, Group(
"Override Attenuation"
)]]
94
float
m_min_distance = 1.0f;
95
96
[[
Reflect
, Group(
"Override Attenuation"
)]]
97
float
m_max_distance = 20.0f;
98
99
uint64_t m_instance_id = 0;
100
glm::vec3 m_last_position {0.f};
101
};
102
103
}
assets.hpp
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
toast::AudioEmitterBase
Base class for shape-based audio emitters.
Definition
audio_emitter_base.hpp:23
toast::AudioEmitterBase::emitterPosition
virtual auto emitterPosition(const glm::vec3 &listener) -> glm::vec3
override this to project listener to the shape's nearest surface
Definition
audio_emitter_base.cpp:222
toast::Node3D
Definition
node_3d.hpp:25
toast::Node::name
auto name() const noexcept -> std::string_view
Display name. Siblings may share one - this is not an identifier.
Definition
node.cpp:45
toast::Node::uid
auto uid() const noexcept -> const UID &
Stable unique identifier, assigned at construction or deserialization. Never changes.
Definition
node.cpp:37
toast::Node::listener
auto listener() noexcept -> event::Listener &
The event Listener owned by this node. Lazy-allocated, freed only with the node.
Definition
node.cpp:204
toast::Reflect
Definition
reflect.hpp:244
export.hpp
node_3d.hpp
Node with 3D spatial transforms.
toast::UID
Definition
uid.hpp:20
engine
src
toast
audio
nodes
audio_emitter_base.hpp
Generated by
1.17.0