Skip to content

Commit

Permalink
Add seq track input
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Nov 28, 2024
1 parent 99a8396 commit 3930b02
Show file tree
Hide file tree
Showing 14 changed files with 575 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scripts/vcpkg
82 changes: 82 additions & 0 deletions src/audioCore/action/ActionAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,48 @@ bool ActionAddMixerTrackInputFromDevice::undo() {
ACTION_RESULT(false);
}

ActionAddSequencerTrackInputFromDevice::ActionAddSequencerTrackInputFromDevice(
int srcc, int dst, int dstc)
: ACTION_DB{ srcc, dst, dstc } {
}

bool ActionAddSequencerTrackInputFromDevice::doAction() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE(ActionAddSequencerTrackInputFromDevice);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
graph->setAudioI2SrcConnection(
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));

this->output("[Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + "\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

bool ActionAddSequencerTrackInputFromDevice::undo() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE_UNDO(ActionAddSequencerTrackInputFromDevice);

if (auto graph = AudioCore::getInstance()->getGraph()) {
graph->removeAudioI2SrcConnection(
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));

this->output("Undo [Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + "\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

ActionAddMixerTrackOutput::ActionAddMixerTrackOutput(
int src, int srcc, int dstc)
: ACTION_DB{ src, srcc, dstc } {}
Expand Down Expand Up @@ -360,6 +402,46 @@ bool ActionAddMixerTrackMidiInput::undo() {
ACTION_RESULT(false);
}

ActionAddSequencerTrackMidiInput::ActionAddSequencerTrackMidiInput(int dst)
: ACTION_DB{ dst } {
}

bool ActionAddSequencerTrackMidiInput::doAction() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE(ActionAddSequencerTrackMidiInput);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
graph->setMIDII2SrcConnection(ACTION_DATA(dst));

this->output(juce::String("[MIDI Input]") + " - " + juce::String(ACTION_DATA(dst)) + "\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

bool ActionAddSequencerTrackMidiInput::undo() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE_UNDO(ActionAddSequencerTrackMidiInput);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
graph->removeMIDII2SrcConnection(ACTION_DATA(dst));

this->output(juce::String("Undo [MIDI Input]") + " - " + juce::String(ACTION_DATA(dst)) + "\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

ActionAddMixerTrackMidiOutput::ActionAddMixerTrackMidiOutput(int src)
: ACTION_DB{ src } {}

Expand Down
39 changes: 39 additions & 0 deletions src/audioCore/action/ActionAdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ class ActionAddMixerTrackInputFromDevice final : public ActionUndoableBase {
JUCE_LEAK_DETECTOR(ActionAddMixerTrackInputFromDevice)
};

class ActionAddSequencerTrackInputFromDevice final : public ActionUndoableBase {
public:
ActionAddSequencerTrackInputFromDevice() = delete;
ActionAddSequencerTrackInputFromDevice(
int srcc, int dst, int dstc);

bool doAction() override;
bool undo() override;
const juce::String getName() override {
return "Add Sequencer Track Input From Device";
};

private:
ACTION_DATABLOCK{
const int srcc, dst, dstc;
} ACTION_DB;

JUCE_LEAK_DETECTOR(ActionAddSequencerTrackInputFromDevice)
};

class ActionAddMixerTrackOutput final : public ActionUndoableBase {
public:
ActionAddMixerTrackOutput() = delete;
Expand Down Expand Up @@ -176,6 +196,25 @@ class ActionAddMixerTrackMidiInput final : public ActionUndoableBase {
JUCE_LEAK_DETECTOR(ActionAddMixerTrackMidiInput)
};

class ActionAddSequencerTrackMidiInput final : public ActionUndoableBase {
public:
ActionAddSequencerTrackMidiInput() = delete;
ActionAddSequencerTrackMidiInput(int dst);

bool doAction() override;
bool undo() override;
const juce::String getName() override {
return "Add Sequencer Track Midi Input";
};

private:
ACTION_DATABLOCK{
const int dst;
} ACTION_DB;

JUCE_LEAK_DETECTOR(ActionAddSequencerTrackMidiInput)
};

class ActionAddMixerTrackMidiOutput final : public ActionUndoableBase {
public:
ActionAddMixerTrackMidiOutput() = delete;
Expand Down
92 changes: 92 additions & 0 deletions src/audioCore/action/ActionRemove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,54 @@ bool ActionRemoveMixerTrackInputFromDevice::undo() {
ACTION_RESULT(false);
}

ActionRemoveSequencerTrackInputFromDevice::ActionRemoveSequencerTrackInputFromDevice(
int srcc, int dst, int dstc)
: ACTION_DB{ srcc, dst, dstc } {
}

bool ActionRemoveSequencerTrackInputFromDevice::doAction() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE(ActionRemoveSequencerTrackInputFromDevice);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
if (!graph->isAudioI2SrcConnected(
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc))) {
ACTION_RESULT(false);
}

graph->removeAudioI2SrcConnection(
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));

this->output("[Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + " (Removed)\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

bool ActionRemoveSequencerTrackInputFromDevice::undo() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE_UNDO(ActionRemoveSequencerTrackInputFromDevice);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
graph->setAudioI2SrcConnection(
ACTION_DATA(dst), ACTION_DATA(srcc), ACTION_DATA(dstc));

this->output("Undo [Device] " + juce::String(ACTION_DATA(srcc)) + " - " + juce::String(ACTION_DATA(dst)) + ", " + juce::String(ACTION_DATA(dstc)) + " (Removed)\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

ActionRemoveMixerTrackOutput::ActionRemoveMixerTrackOutput(
int src, int srcc, int dstc)
: ACTION_DB{ src, srcc, dstc } {}
Expand Down Expand Up @@ -771,6 +819,50 @@ bool ActionRemoveMixerTrackMidiInput::undo() {
ACTION_RESULT(false);
}

ActionRemoveSequencerTrackMidiInput::ActionRemoveSequencerTrackMidiInput(int index)
: ACTION_DB{ index } {
}

bool ActionRemoveSequencerTrackMidiInput::doAction() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE(ActionRemoveSequencerTrackMidiInput);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
if (!graph->isMIDII2SrcConnected(ACTION_DATA(index))) {
ACTION_RESULT(false);
}

graph->removeMIDII2SrcConnection(ACTION_DATA(index));

this->output(juce::String("[MIDI Input]") + " - " + juce::String(ACTION_DATA(index)) + " (Removed)\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

bool ActionRemoveSequencerTrackMidiInput::undo() {
ACTION_CHECK_RENDERING(
"Don't do this while rendering.");

ACTION_UNSAVE_PROJECT();

ACTION_WRITE_TYPE_UNDO(ActionRemoveSequencerTrackMidiInput);
ACTION_WRITE_DB();

if (auto graph = AudioCore::getInstance()->getGraph()) {
graph->setMIDII2SrcConnection(ACTION_DATA(index));

this->output(juce::String("Undo [MIDI Input]") + " - " + juce::String(ACTION_DATA(index)) + " (Removed)\n");
ACTION_RESULT(true);
}
ACTION_RESULT(false);
}

ActionRemoveMixerTrackMidiOutput::ActionRemoveMixerTrackMidiOutput(int index)
: ACTION_DB{ index } {}

Expand Down
39 changes: 39 additions & 0 deletions src/audioCore/action/ActionRemove.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ class ActionRemoveMixerTrackInputFromDevice final : public ActionUndoableBase {
JUCE_LEAK_DETECTOR(ActionRemoveMixerTrackInputFromDevice)
};

class ActionRemoveSequencerTrackInputFromDevice final : public ActionUndoableBase {
public:
ActionRemoveSequencerTrackInputFromDevice() = delete;
ActionRemoveSequencerTrackInputFromDevice(
int srcc, int dst, int dstc);

bool doAction() override;
bool undo() override;
const juce::String getName() override {
return "Remove Sequencer Track Input From Device";
};

private:
ACTION_DATABLOCK{
const int srcc, dst, dstc;
} ACTION_DB;

JUCE_LEAK_DETECTOR(ActionRemoveSequencerTrackInputFromDevice)
};

class ActionRemoveMixerTrackOutput final : public ActionUndoableBase {
public:
ActionRemoveMixerTrackOutput() = delete;
Expand Down Expand Up @@ -246,6 +266,25 @@ class ActionRemoveMixerTrackMidiInput final : public ActionUndoableBase {
JUCE_LEAK_DETECTOR(ActionRemoveMixerTrackMidiInput)
};

class ActionRemoveSequencerTrackMidiInput final : public ActionUndoableBase {
public:
ActionRemoveSequencerTrackMidiInput() = delete;
ActionRemoveSequencerTrackMidiInput(int index);

bool doAction() override;
bool undo() override;
const juce::String getName() override {
return "Remove Sequencer Track Midi Input";
};

private:
ACTION_DATABLOCK{
const int index;
} ACTION_DB;

JUCE_LEAK_DETECTOR(ActionRemoveSequencerTrackMidiInput)
};

class ActionRemoveMixerTrackMidiOutput final : public ActionUndoableBase {
public:
ActionRemoveMixerTrackMidiOutput() = delete;
Expand Down
17 changes: 17 additions & 0 deletions src/audioCore/command/CommandAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ AUDIOCORE_FUNC(addSequencerTrackOutput) {
return CommandFuncResult{ true, "" };
}

AUDIOCORE_FUNC(addSequencerTrackInputFromDevice) {
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerTrackInputFromDevice{
(int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2),
(int)luaL_checkinteger(L, 3) });
ActionDispatcher::getInstance()->dispatch(std::move(action));
return CommandFuncResult{ true, "" };
}

AUDIOCORE_FUNC(addSequencerTrackMidiInput) {
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerTrackMidiInput{
(int)luaL_checkinteger(L, 1) });
ActionDispatcher::getInstance()->dispatch(std::move(action));
return CommandFuncResult{ true, "" };
}

AUDIOCORE_FUNC(addSequencerBlock) {
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerBlock{
(int)luaL_checkinteger(L, 1), (double)luaL_checknumber(L, 2),
Expand All @@ -120,5 +135,7 @@ void regCommandAdd(lua_State* L) {
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrack);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackMidiOutputToMixer);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackOutput);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackInputFromDevice);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerTrackMidiInput);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, addSequencerBlock);
}
17 changes: 17 additions & 0 deletions src/audioCore/command/CommandRemove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ AUDIOCORE_FUNC(removeSequencerTrackOutput) {
return CommandFuncResult{ true, "" };
}

AUDIOCORE_FUNC(removeSequencerTrackInputFromDevice) {
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerTrackInputFromDevice{
(int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2),
(int)luaL_checkinteger(L, 3) });
ActionDispatcher::getInstance()->dispatch(std::move(action));
return CommandFuncResult{ true, "" };
}

AUDIOCORE_FUNC(removeSequencerTrackMidiInput) {
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerTrackMidiInput{
(int)luaL_checkinteger(L, 1) });
ActionDispatcher::getInstance()->dispatch(std::move(action));
return CommandFuncResult{ true, "" };
}

AUDIOCORE_FUNC(removeSequencerBlock) {
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerBlock{
(int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2) });
Expand All @@ -133,5 +148,7 @@ void regCommandRemove(lua_State* L) {
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrack);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackMidiOutputToMixer);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackOutput);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackInputFromDevice);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerTrackMidiInput);
LUA_ADD_AUDIOCORE_FUNC_DEFAULT_NAME(L, removeSequencerBlock);
}
Loading

0 comments on commit 3930b02

Please sign in to comment.