diff options
Diffstat (limited to 'source/frontend/StarVoiceLuaBindings.cpp')
-rw-r--r-- | source/frontend/StarVoiceLuaBindings.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/frontend/StarVoiceLuaBindings.cpp b/source/frontend/StarVoiceLuaBindings.cpp new file mode 100644 index 0000000..e3271fd --- /dev/null +++ b/source/frontend/StarVoiceLuaBindings.cpp @@ -0,0 +1,29 @@ +#include "StarVoiceLuaBindings.hpp" +#include "StarVoice.hpp" + +namespace Star { + +LuaCallbacks LuaBindings::makeVoiceCallbacks(Voice* voice) { + LuaCallbacks callbacks; + + callbacks.registerCallback("speakers", [voice](Maybe<bool> onlyPlaying) -> List<Json> { + List<Json> list; + + for (auto& speaker : voice->speakers(onlyPlaying.value(true))) { + list.append(JsonObject{ + {"speakerId", speaker->speakerId }, + {"entityId", speaker->entityId }, + {"name", speaker->name }, + {"playing", (bool)speaker->playing }, + {"muted", (bool)speaker->muted }, + {"loudness", (float)speaker->decibelLevel }, + }); + } + + return list; + }); + + return callbacks; +} + +} |