Skip to content

Commit 3930b02

Browse files
Add seq track input
1 parent 99a8396 commit 3930b02

File tree

14 files changed

+575
-8
lines changed

14 files changed

+575
-8
lines changed

scripts/vcpkg

src/audioCore/action/ActionAdd.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,48 @@ bool ActionAddMixerTrackInputFromDevice::undo() {
162162
ACTION_RESULT(false);
163163
}
164164

165+
ActionAddSequencerTrackInputFromDevice::ActionAddSequencerTrackInputFromDevice(
166+
int srcc, int dst, int dstc)
167+
: ACTION_DB{ srcc, dst, dstc } {
168+
}
169+
170+
bool ActionAddSequencerTrackInputFromDevice::doAction() {
171+
ACTION_CHECK_RENDERING(
172+
"Don't do this while rendering.");
173+
174+
ACTION_UNSAVE_PROJECT();
175+
176+
ACTION_WRITE_TYPE(ActionAddSequencerTrackInputFromDevice);
177+
ACTION_WRITE_DB();
178+
179+
if (auto graph = AudioCore::getInstance()->getGraph()) {
180+
graph->setAudioI2SrcConnection(
181+
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));
182+
183+
this->output("[Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + "\n");
184+
ACTION_RESULT(true);
185+
}
186+
ACTION_RESULT(false);
187+
}
188+
189+
bool ActionAddSequencerTrackInputFromDevice::undo() {
190+
ACTION_CHECK_RENDERING(
191+
"Don't do this while rendering.");
192+
193+
ACTION_UNSAVE_PROJECT();
194+
195+
ACTION_WRITE_TYPE_UNDO(ActionAddSequencerTrackInputFromDevice);
196+
197+
if (auto graph = AudioCore::getInstance()->getGraph()) {
198+
graph->removeAudioI2SrcConnection(
199+
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));
200+
201+
this->output("Undo [Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + "\n");
202+
ACTION_RESULT(true);
203+
}
204+
ACTION_RESULT(false);
205+
}
206+
165207
ActionAddMixerTrackOutput::ActionAddMixerTrackOutput(
166208
int src, int srcc, int dstc)
167209
: ACTION_DB{ src, srcc, dstc } {}
@@ -360,6 +402,46 @@ bool ActionAddMixerTrackMidiInput::undo() {
360402
ACTION_RESULT(false);
361403
}
362404

405+
ActionAddSequencerTrackMidiInput::ActionAddSequencerTrackMidiInput(int dst)
406+
: ACTION_DB{ dst } {
407+
}
408+
409+
bool ActionAddSequencerTrackMidiInput::doAction() {
410+
ACTION_CHECK_RENDERING(
411+
"Don't do this while rendering.");
412+
413+
ACTION_UNSAVE_PROJECT();
414+
415+
ACTION_WRITE_TYPE(ActionAddSequencerTrackMidiInput);
416+
ACTION_WRITE_DB();
417+
418+
if (auto graph = AudioCore::getInstance()->getGraph()) {
419+
graph->setMIDII2SrcConnection(ACTION_DATA(dst));
420+
421+
this->output(juce::String("[MIDI Input]") + " - " + juce::String(ACTION_DATA(dst)) + "\n");
422+
ACTION_RESULT(true);
423+
}
424+
ACTION_RESULT(false);
425+
}
426+
427+
bool ActionAddSequencerTrackMidiInput::undo() {
428+
ACTION_CHECK_RENDERING(
429+
"Don't do this while rendering.");
430+
431+
ACTION_UNSAVE_PROJECT();
432+
433+
ACTION_WRITE_TYPE_UNDO(ActionAddSequencerTrackMidiInput);
434+
ACTION_WRITE_DB();
435+
436+
if (auto graph = AudioCore::getInstance()->getGraph()) {
437+
graph->removeMIDII2SrcConnection(ACTION_DATA(dst));
438+
439+
this->output(juce::String("Undo [MIDI Input]") + " - " + juce::String(ACTION_DATA(dst)) + "\n");
440+
ACTION_RESULT(true);
441+
}
442+
ACTION_RESULT(false);
443+
}
444+
363445
ActionAddMixerTrackMidiOutput::ActionAddMixerTrackMidiOutput(int src)
364446
: ACTION_DB{ src } {}
365447

src/audioCore/action/ActionAdd.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ class ActionAddMixerTrackInputFromDevice final : public ActionUndoableBase {
9494
JUCE_LEAK_DETECTOR(ActionAddMixerTrackInputFromDevice)
9595
};
9696

97+
class ActionAddSequencerTrackInputFromDevice final : public ActionUndoableBase {
98+
public:
99+
ActionAddSequencerTrackInputFromDevice() = delete;
100+
ActionAddSequencerTrackInputFromDevice(
101+
int srcc, int dst, int dstc);
102+
103+
bool doAction() override;
104+
bool undo() override;
105+
const juce::String getName() override {
106+
return "Add Sequencer Track Input From Device";
107+
};
108+
109+
private:
110+
ACTION_DATABLOCK{
111+
const int srcc, dst, dstc;
112+
} ACTION_DB;
113+
114+
JUCE_LEAK_DETECTOR(ActionAddSequencerTrackInputFromDevice)
115+
};
116+
97117
class ActionAddMixerTrackOutput final : public ActionUndoableBase {
98118
public:
99119
ActionAddMixerTrackOutput() = delete;
@@ -176,6 +196,25 @@ class ActionAddMixerTrackMidiInput final : public ActionUndoableBase {
176196
JUCE_LEAK_DETECTOR(ActionAddMixerTrackMidiInput)
177197
};
178198

199+
class ActionAddSequencerTrackMidiInput final : public ActionUndoableBase {
200+
public:
201+
ActionAddSequencerTrackMidiInput() = delete;
202+
ActionAddSequencerTrackMidiInput(int dst);
203+
204+
bool doAction() override;
205+
bool undo() override;
206+
const juce::String getName() override {
207+
return "Add Sequencer Track Midi Input";
208+
};
209+
210+
private:
211+
ACTION_DATABLOCK{
212+
const int dst;
213+
} ACTION_DB;
214+
215+
JUCE_LEAK_DETECTOR(ActionAddSequencerTrackMidiInput)
216+
};
217+
179218
class ActionAddMixerTrackMidiOutput final : public ActionUndoableBase {
180219
public:
181220
ActionAddMixerTrackMidiOutput() = delete;

src/audioCore/action/ActionRemove.cpp

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,54 @@ bool ActionRemoveMixerTrackInputFromDevice::undo() {
372372
ACTION_RESULT(false);
373373
}
374374

375+
ActionRemoveSequencerTrackInputFromDevice::ActionRemoveSequencerTrackInputFromDevice(
376+
int srcc, int dst, int dstc)
377+
: ACTION_DB{ srcc, dst, dstc } {
378+
}
379+
380+
bool ActionRemoveSequencerTrackInputFromDevice::doAction() {
381+
ACTION_CHECK_RENDERING(
382+
"Don't do this while rendering.");
383+
384+
ACTION_UNSAVE_PROJECT();
385+
386+
ACTION_WRITE_TYPE(ActionRemoveSequencerTrackInputFromDevice);
387+
ACTION_WRITE_DB();
388+
389+
if (auto graph = AudioCore::getInstance()->getGraph()) {
390+
if (!graph->isAudioI2SrcConnected(
391+
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc))) {
392+
ACTION_RESULT(false);
393+
}
394+
395+
graph->removeAudioI2SrcConnection(
396+
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));
397+
398+
this->output("[Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + " (Removed)\n");
399+
ACTION_RESULT(true);
400+
}
401+
ACTION_RESULT(false);
402+
}
403+
404+
bool ActionRemoveSequencerTrackInputFromDevice::undo() {
405+
ACTION_CHECK_RENDERING(
406+
"Don't do this while rendering.");
407+
408+
ACTION_UNSAVE_PROJECT();
409+
410+
ACTION_WRITE_TYPE_UNDO(ActionRemoveSequencerTrackInputFromDevice);
411+
ACTION_WRITE_DB();
412+
413+
if (auto graph = AudioCore::getInstance()->getGraph()) {
414+
graph->setAudioI2SrcConnection(
415+
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));
416+
417+
this->output("Undo [Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + " (Removed)\n");
418+
ACTION_RESULT(true);
419+
}
420+
ACTION_RESULT(false);
421+
}
422+
375423
ActionRemoveMixerTrackOutput::ActionRemoveMixerTrackOutput(
376424
int src, int srcc, int dstc)
377425
: ACTION_DB{ src, srcc, dstc } {}
@@ -771,6 +819,50 @@ bool ActionRemoveMixerTrackMidiInput::undo() {
771819
ACTION_RESULT(false);
772820
}
773821

822+
ActionRemoveSequencerTrackMidiInput::ActionRemoveSequencerTrackMidiInput(int index)
823+
: ACTION_DB{ index } {
824+
}
825+
826+
bool ActionRemoveSequencerTrackMidiInput::doAction() {
827+
ACTION_CHECK_RENDERING(
828+
"Don't do this while rendering.");
829+
830+
ACTION_UNSAVE_PROJECT();
831+
832+
ACTION_WRITE_TYPE(ActionRemoveSequencerTrackMidiInput);
833+
ACTION_WRITE_DB();
834+
835+
if (auto graph = AudioCore::getInstance()->getGraph()) {
836+
if (!graph->isMIDII2SrcConnected(ACTION_DATA(index))) {
837+
ACTION_RESULT(false);
838+
}
839+
840+
graph->removeMIDII2SrcConnection(ACTION_DATA(index));
841+
842+
this->output(juce::String("[MIDI Input]") + " - " + juce::String(ACTION_DATA(index)) + " (Removed)\n");
843+
ACTION_RESULT(true);
844+
}
845+
ACTION_RESULT(false);
846+
}
847+
848+
bool ActionRemoveSequencerTrackMidiInput::undo() {
849+
ACTION_CHECK_RENDERING(
850+
"Don't do this while rendering.");
851+
852+
ACTION_UNSAVE_PROJECT();
853+
854+
ACTION_WRITE_TYPE_UNDO(ActionRemoveSequencerTrackMidiInput);
855+
ACTION_WRITE_DB();
856+
857+
if (auto graph = AudioCore::getInstance()->getGraph()) {
858+
graph->setMIDII2SrcConnection(ACTION_DATA(index));
859+
860+
this->output(juce::String("Undo [MIDI Input]") + " - " + juce::String(ACTION_DATA(index)) + " (Removed)\n");
861+
ACTION_RESULT(true);
862+
}
863+
ACTION_RESULT(false);
864+
}
865+
774866
ActionRemoveMixerTrackMidiOutput::ActionRemoveMixerTrackMidiOutput(int index)
775867
: ACTION_DB{ index } {}
776868

src/audioCore/action/ActionRemove.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ class ActionRemoveMixerTrackInputFromDevice final : public ActionUndoableBase {
105105
JUCE_LEAK_DETECTOR(ActionRemoveMixerTrackInputFromDevice)
106106
};
107107

108+
class ActionRemoveSequencerTrackInputFromDevice final : public ActionUndoableBase {
109+
public:
110+
ActionRemoveSequencerTrackInputFromDevice() = delete;
111+
ActionRemoveSequencerTrackInputFromDevice(
112+
int srcc, int dst, int dstc);
113+
114+
bool doAction() override;
115+
bool undo() override;
116+
const juce::String getName() override {
117+
return "Remove Sequencer Track Input From Device";
118+
};
119+
120+
private:
121+
ACTION_DATABLOCK{
122+
const int srcc, dst, dstc;
123+
} ACTION_DB;
124+
125+
JUCE_LEAK_DETECTOR(ActionRemoveSequencerTrackInputFromDevice)
126+
};
127+
108128
class ActionRemoveMixerTrackOutput final : public ActionUndoableBase {
109129
public:
110130
ActionRemoveMixerTrackOutput() = delete;
@@ -246,6 +266,25 @@ class ActionRemoveMixerTrackMidiInput final : public ActionUndoableBase {
246266
JUCE_LEAK_DETECTOR(ActionRemoveMixerTrackMidiInput)
247267
};
248268

269+
class ActionRemoveSequencerTrackMidiInput final : public ActionUndoableBase {
270+
public:
271+
ActionRemoveSequencerTrackMidiInput() = delete;
272+
ActionRemoveSequencerTrackMidiInput(int index);
273+
274+
bool doAction() override;
275+
bool undo() override;
276+
const juce::String getName() override {
277+
return "Remove Sequencer Track Midi Input";
278+
};
279+
280+
private:
281+
ACTION_DATABLOCK{
282+
const int index;
283+
} ACTION_DB;
284+
285+
JUCE_LEAK_DETECTOR(ActionRemoveSequencerTrackMidiInput)
286+
};
287+
249288
class ActionRemoveMixerTrackMidiOutput final : public ActionUndoableBase {
250289
public:
251290
ActionRemoveMixerTrackMidiOutput() = delete;

src/audioCore/command/CommandAdd.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ AUDIOCORE_FUNC(addSequencerTrackOutput) {
9898
return CommandFuncResult{ true, "" };
9999
}
100100

101+
AUDIOCORE_FUNC(addSequencerTrackInputFromDevice) {
102+
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerTrackInputFromDevice{
103+
(int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2),
104+
(int)luaL_checkinteger(L, 3) });
105+
ActionDispatcher::getInstance()->dispatch(std::move(action));
106+
return CommandFuncResult{ true, "" };
107+
}
108+
109+
AUDIOCORE_FUNC(addSequencerTrackMidiInput) {
110+
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerTrackMidiInput{
111+
(int)luaL_checkinteger(L, 1) });
112+
ActionDispatcher::getInstance()->dispatch(std::move(action));
113+
return CommandFuncResult{ true, "" };
114+
}
115+
101116
AUDIOCORE_FUNC(addSequencerBlock) {
102117
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerBlock{
103118
(int)luaL_checkinteger(L, 1), (double)luaL_checknumber(L, 2),
@@ -120,5 +135,7 @@ void regCommandAdd(lua_State* L) {
120135
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrack);
121136
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackMidiOutputToMixer);
122137
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackOutput);
138+
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackInputFromDevice);
139+
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackMidiInput);
123140
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerBlock);
124141
}

src/audioCore/command/CommandRemove.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ AUDIOCORE_FUNC(removeSequencerTrackOutput) {
110110
return CommandFuncResult{ true, "" };
111111
}
112112

113+
AUDIOCORE_FUNC(removeSequencerTrackInputFromDevice) {
114+
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerTrackInputFromDevice{
115+
(int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2),
116+
(int)luaL_checkinteger(L, 3) });
117+
ActionDispatcher::getInstance()->dispatch(std::move(action));
118+
return CommandFuncResult{ true, "" };
119+
}
120+
121+
AUDIOCORE_FUNC(removeSequencerTrackMidiInput) {
122+
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerTrackMidiInput{
123+
(int)luaL_checkinteger(L, 1) });
124+
ActionDispatcher::getInstance()->dispatch(std::move(action));
125+
return CommandFuncResult{ true, "" };
126+
}
127+
113128
AUDIOCORE_FUNC(removeSequencerBlock) {
114129
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerBlock{
115130
(int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2) });
@@ -133,5 +148,7 @@ void regCommandRemove(lua_State* L) {
133148
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrack);
134149
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackMidiOutputToMixer);
135150
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackOutput);
151+
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackInputFromDevice);
152+
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackMidiInput);
136153
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerBlock);
137154
}

0 commit comments

Comments
 (0)