Toast Engine
Loading...
Searching...
No Matches
audio_emitter.hpp
1
8
9#pragma once
10#include "../assets.hpp"
11
12#include <toast/export.hpp>
13#include <toast/world/node.hpp>
14
15namespace toast {
16
17class TOAST_API [[ToastNode, Color("Beige"), Icon("AudioStreamPlayer")]] AudioEmitter : public Node {
18public:
19 [[Button]]
20 void play();
21
22 [[Button]]
23 void stop();
24
25 void pause(bool value);
26 void setParameter(std::string_view name, float value);
27 void setParameter(std::string_view, bool value);
28 auto isPlaying() -> bool;
29
30 void event(std::string_view path);
31 void event(toast::UID uid);
32 void playOnEnable(bool value);
33 void volume(float value);
34 void pitch(float value);
35 void allowFadeout(bool value);
37 signals::Signal<std::string_view> audio_started;
38 signals::Signal<std::string_view> audio_stopped;
39 signals::Signal<bool> audio_paused;
40
41private:
42 void updateInspectorMessages() override;
43 void onEnable();
44 void onDisable();
45
46 [[Reflect, Name("Audio Event")]]
48
49 [[Reflect]]
50 bool m_play_on_enable = false;
51
52 [[Reflect, Range(0.0, 1.0)]]
53 float m_volume = 1.0f;
54
55 [[Reflect, Range(0.5, 2.0)]]
56 float m_pitch = 1.0f;
57
58 [[Reflect]]
59 bool m_allow_fadeout = true;
60};
61
62}
Type-safe smart pointer for assets.
Definition core_types.hpp:149
Definition audio_emitter.hpp:17
auto isPlaying() -> bool
Definition audio_emitter.cpp:69
void setParameter(std::string_view name, float value)
Changes a parameter by name.
Definition audio_emitter.cpp:55
void pitch(float value)
Definition audio_emitter.cpp:95
void pause(bool value)
Pauses and resumes in a location.
Definition audio_emitter.cpp:47
void stop()
Stops the event using the allowFadeout().
Definition audio_emitter.cpp:39
void playOnEnable(bool value)
If true, will play every time the node is enabled.
Definition audio_emitter.cpp:84
void event(std::string_view path)
Sets the event by URI.
Definition audio_emitter.cpp:76
void allowFadeout(bool value)
Definition audio_emitter.cpp:102
void volume(float value)
Definition audio_emitter.cpp:88
void play()
Fires the event.
Definition audio_emitter.cpp:24
auto name() const noexcept -> std::string_view
Display name. Siblings may share one - this is not an identifier.
Definition node.cpp:45
auto uid() const noexcept -> const UID &
Stable unique identifier, assigned at construction or deserialization. Never changes.
Definition node.cpp:37
Definition reflect.hpp:244
Base object type for the scene graph.
Definition uid.hpp:20