2023-07-18 07:36:51 +00:00
|
|
|
#include "StarVoiceLuaBindings.hpp"
|
|
|
|
#include "StarVoice.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
LuaCallbacks LuaBindings::makeVoiceCallbacks(Voice* voice) {
|
|
|
|
LuaCallbacks callbacks;
|
|
|
|
|
2023-07-19 08:15:49 +00:00
|
|
|
callbacks.registerCallback("getSettings", [voice]() -> Json { return voice->saveJson(); });
|
|
|
|
callbacks.registerCallback("mergeSettings", [voice](Json const& settings) { voice->loadJson(settings); });
|
|
|
|
|
2023-07-18 07:36:51 +00:00
|
|
|
callbacks.registerCallback("speakers", [voice](Maybe<bool> onlyPlaying) -> List<Json> {
|
|
|
|
List<Json> list;
|
|
|
|
|
|
|
|
for (auto& speaker : voice->speakers(onlyPlaying.value(true))) {
|
|
|
|
list.append(JsonObject{
|
2023-07-19 08:15:49 +00:00
|
|
|
{"speakerId", speaker->speakerId },
|
|
|
|
{"entityId", speaker->entityId },
|
|
|
|
{"name", speaker->name },
|
|
|
|
{"playing", (bool)speaker->playing },
|
|
|
|
{"muted", (bool)speaker->muted },
|
|
|
|
{"decibels", (float)speaker->decibelLevel },
|
|
|
|
{"smoothDecibels", (float)speaker->smoothDb },
|
2023-07-18 07:36:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
});
|
|
|
|
|
|
|
|
return callbacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|