42 auto sourceEditor = editor::addScriptClass<ScriptAudioSourceEditor>(table,
"AudioSourceEditor");
44 editor::registerEditorWorkspace<ScriptAudioSourceEditor>(sourceEditor, bind,
45 "audio source editor and workspace must not be null");
46 sourceEditor.addFunc(
"setViewportWidth", [bind](ScriptAudioSourceEditor* self,
float width) {
47 return bind.checked(self,
"audio source editor must not be null",
48 [&] {
return self->editor().setViewportWidth(
width); });
50 sourceEditor.addFunc(
"seekX", [bind](ScriptAudioSourceEditor* self,
float x) {
51 return bind.checked(self,
"audio source editor must not be null", [&] {
return self->editor().seekX(
x); });
53 sourceEditor.addFunc(
"seekSeconds", [bind](ScriptAudioSourceEditor* self,
float seconds) {
54 return bind.checked(self,
"audio source editor must not be null",
55 [&] {
return self->editor().seekSeconds(
static_cast<double>(seconds)); });
57 sourceEditor.addFunc(
"setFloat", [bind](ScriptAudioSourceEditor* self,
const std::string&
path,
float value) {
58 return bind.checked(self,
"audio source editor must not be null", [&] {
62 sourceEditor.addFunc(
"setBool", [bind](ScriptAudioSourceEditor* self,
const std::string&
path,
bool value) {
63 return bind.checked(self,
"audio source editor must not be null",
66 editor::registerEditorHistory<ScriptAudioSourceEditor>(sourceEditor, bind,
67 "audio source editor must not be null");
68 sourceEditor.addFunc(
"play", [bind](ScriptAudioSourceEditor* self) {
69 return bind.checked(self,
"audio source editor must not be null", [&] {
return self->editor().play(); });
71 sourceEditor.addFunc(
"pause", [bind](ScriptAudioSourceEditor* self) {
72 return bind.checked(self,
"audio source editor must not be null", [&] {
return self->editor().pause(); });
74 sourceEditor.addFunc(
"stop", [bind](ScriptAudioSourceEditor* self) {
75 return bind.checked(self,
"audio source editor must not be null", [&] {
return self->editor().stop(); });
77 sourceEditor.addFunc(
"update", [bind](ScriptAudioSourceEditor* self,
float deltaSeconds) {
79 auto result = self->editor().update(
static_cast<double>(deltaSeconds));
82 sourceEditor.addFunc(
"attachLiveAudition", [bind](ScriptAudioSourceEditor* self) {
83 return bind.checked(self,
"audio source editor must not be null",
84 [&] {
return self->editor().attachLiveAudition(); });
86 sourceEditor.addFunc(
"isPlaying", [](ScriptAudioSourceEditor* self) {
return self && self->editor().isPlaying(); });
87 sourceEditor.addFunc(
"getDuration", [](ScriptAudioSourceEditor* self) {
88 return self ?
static_cast<float>(self->editor().duration()) : 0.0f;
90 sourceEditor.addFunc(
"getPlayhead", [](ScriptAudioSourceEditor* self) {
91 return self ?
static_cast<float>(self->editor().playhead()) : 0.0f;
93 sourceEditor.addFunc(
"getLayoutWidth", [](ScriptAudioSourceEditor* self) {
94 return self ? self->editor().layoutWidth() : 0.0f;
96 sourceEditor.addFunc(
"getPlayheadX", [](ScriptAudioSourceEditor* self) {
97 return self ? self->editor().playheadX() : 0.0f;
99 sourceEditor.addFunc(
"getLoopStartX", [](ScriptAudioSourceEditor* self) {
100 return self ? self->editor().loopStartX() : 0.0f;
102 sourceEditor.addFunc(
"getLoopEndX", [](ScriptAudioSourceEditor* self) {
103 return self ? self->editor().loopEndX() : 0.0f;
105 sourceEditor.addFunc(
"getBucketCount", [](ScriptAudioSourceEditor* self) {
106 return self ? self->editor().bucketCount() : 0;
108 sourceEditor.addFunc(
"getBucketMin", [](ScriptAudioSourceEditor* self,
int index) {
109 if (!self)
return 0.0f;
113 sourceEditor.addFunc(
"getBucketMax", [](ScriptAudioSourceEditor* self,
int index) {
114 if (!self)
return 0.0f;
118 sourceEditor.addFunc(
"getTransportState", [](ScriptAudioSourceEditor* self) {
119 return std::string(self ? transportLabel(self->editor().transport().state) :
"stopped");
121 sourceEditor.addFunc(
"getFloat", [](ScriptAudioSourceEditor* self,
const std::string&
path) {
122 if (!self)
return 0.0f;
124 if (
const auto* real =
value.value.getIf<
double>())
return static_cast<float>(*real);
125 if (
const auto* integer =
value.value.getIf<std::int64_t>())
return static_cast<float>(*integer);
128 sourceEditor.addFunc(
"getBool", [](ScriptAudioSourceEditor* self,
const std::string&
path) {
129 if (!self)
return false;
131 const auto* flag =
value.value.getIf<
bool>();
132 return flag ? *flag :
false;
134 sourceEditor.addFunc(
"getString", [](ScriptAudioSourceEditor* self,
const std::string&
path) {
135 if (!self)
return std::string{};
137 const auto*
text =
value.value.getIf<std::string>();
138 return text ? *
text : std::string{};
141 editor::registerEditorOwnedCreate<ScriptAudioSourceEditor, AudioEditorModule>(
142 moduleClass, bind,
"audio source target id must not be empty");