diff --git a/scripts/vcpkg b/scripts/vcpkg index 10e07ac..020bf73 160000 --- a/scripts/vcpkg +++ b/scripts/vcpkg @@ -1 +1 @@ -Subproject commit 10e07acf18cf05a09e3b487e37d5973e57eedd52 +Subproject commit 020bf73487b729cafed2edbd7bf6de79cdd5f8a8 diff --git a/src/audioCore/action/ActionSet.cpp b/src/audioCore/action/ActionSet.cpp index 158e51a..da1c29a 100644 --- a/src/audioCore/action/ActionSet.cpp +++ b/src/audioCore/action/ActionSet.cpp @@ -1747,8 +1747,8 @@ bool ActionSetAudioSaveQualityOptionIndex::doAction() { } ActionSetSequencerTrackRecording::ActionSetSequencerTrackRecording( - int track, bool recording) - : ACTION_DB{ track, recording } {} + int track, quickAPI::RecordState recordState) + : ACTION_DB{ track, recordState } {} bool ActionSetSequencerTrackRecording::doAction() { ACTION_CHECK_RENDERING( @@ -1761,11 +1761,11 @@ bool ActionSetSequencerTrackRecording::doAction() { if (auto graph = AudioCore::getInstance()->getGraph()) { if (auto track = graph->getSourceProcessor(ACTION_DATA(track))) { - ACTION_DATA(oldRecording) = track->getRecording(); + ACTION_DATA(oldRecordState) = track->getRecording(); - track->setRecording(ACTION_DATA(recording)); + track->setRecording(ACTION_DATA(recordState)); - this->output("Sequencer Track Recording: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ track->getRecording() ? "ON" : "OFF" } + "\n"); + this->output("Sequencer Track Recording: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ track->getRecording() } + "\n"); ACTION_RESULT(true); } } @@ -1783,9 +1783,9 @@ bool ActionSetSequencerTrackRecording::undo() { if (auto graph = AudioCore::getInstance()->getGraph()) { if (auto track = graph->getSourceProcessor(ACTION_DATA(track))) { - track->setRecording(ACTION_DATA(oldRecording)); + track->setRecording(ACTION_DATA(oldRecordState)); - this->output("Undo sequencer Track Recording: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ track->getRecording() ? "ON" : "OFF" } + "\n"); + this->output("Undo sequencer Track Recording: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ track->getRecording() } + "\n"); ACTION_RESULT(true); } } diff --git a/src/audioCore/action/ActionSet.h b/src/audioCore/action/ActionSet.h index f27632d..1cb3fac 100644 --- a/src/audioCore/action/ActionSet.h +++ b/src/audioCore/action/ActionSet.h @@ -969,7 +969,7 @@ class ActionSetSequencerTrackRecording final : public ActionUndoableBase { public: ActionSetSequencerTrackRecording() = delete; ActionSetSequencerTrackRecording( - int track, bool recording); + int track, quickAPI::RecordState recordState); bool doAction() override; bool undo() override; @@ -980,9 +980,9 @@ class ActionSetSequencerTrackRecording final : public ActionUndoableBase { private: ACTION_DATABLOCK{ const int track; - const bool recording; + const quickAPI::RecordState recordState; - bool oldRecording = false; + quickAPI::RecordState oldRecordState = quickAPI::RecordState::NotRecording; } ACTION_DB; JUCE_LEAK_DETECTOR(ActionSetSequencerTrackRecording) diff --git a/src/audioCore/command/CommandSet.cpp b/src/audioCore/command/CommandSet.cpp index 6eb1175..09fc440 100644 --- a/src/audioCore/command/CommandSet.cpp +++ b/src/audioCore/command/CommandSet.cpp @@ -222,7 +222,7 @@ AUDIOCORE_FUNC(setAudioSaveQualityOptionIndex) { AUDIOCORE_FUNC(setSequencerTrackRecording) { auto action = std::unique_ptr(new ActionSetSequencerTrackRecording{ - (int)luaL_checkinteger(L, 1), (bool)lua_toboolean(L, 2) }); + (int)luaL_checkinteger(L, 1), (quickAPI::RecordState)luaL_checkinteger(L, 2) }); ActionDispatcher::getInstance()->dispatch(std::move(action)); return CommandFuncResult{ true, "" }; } diff --git a/src/audioCore/graph/SeqSourceProcessor.cpp b/src/audioCore/graph/SeqSourceProcessor.cpp index ee9e04e..49a0a33 100644 --- a/src/audioCore/graph/SeqSourceProcessor.cpp +++ b/src/audioCore/graph/SeqSourceProcessor.cpp @@ -515,19 +515,20 @@ int SeqSourceProcessor::getTotalMIDITrackNum() const { return SourceManager::getInstance()->getMIDITrackNum(this->midiSourceRef); } -void SeqSourceProcessor::setRecording(bool recording) { - this->recordingFlag = recording; - +void SeqSourceProcessor::setRecording(RecordState recordState) { /** Sync ARA */ - if (!recording) { + if (this->recordingFlag != RecordState::NotRecording + && this->recordingFlag != recordState) { this->syncARAContext(); } + + this->recordingFlag = recordState; /** Callback */ UICallbackAPI::invoke(UICallbackType::SeqRecChanged, this->index); } -bool SeqSourceProcessor::getRecording() const { +SeqSourceProcessor::RecordState SeqSourceProcessor::getRecording() const { return this->recordingFlag; } @@ -597,7 +598,7 @@ void SeqSourceProcessor::processBlock( if (!position->getIsPlaying()) { isPlaying = false; } /** Clear MIDI Buffer */ - if ((isPlaying && position->getIsRecording()) || (!this->recordingFlag)) { + if ((isPlaying && position->getIsRecording()) || (this->recordingFlag == RecordState::NotRecording)) { midiMessages.clear(); } @@ -744,7 +745,7 @@ bool SeqSourceProcessor::parse( } this->setCurrentMIDITrack(mes->miditrack()); - this->setRecording(mes->recording()); + this->setRecording(static_cast(mes->recordstate())); this->setMute(mes->muted()); return true; @@ -794,7 +795,7 @@ std::unique_ptr SeqSourceProcessor::serialize( } mes->set_miditrack(this->getCurrentMIDITrack()); - mes->set_recording(this->getRecording()); + mes->set_recordstate(static_cast(this->getRecording())); mes->set_muted(this->getMute()); return std::unique_ptr(mes.release()); diff --git a/src/audioCore/graph/SeqSourceProcessor.h b/src/audioCore/graph/SeqSourceProcessor.h index a98213e..d1ac90f 100644 --- a/src/audioCore/graph/SeqSourceProcessor.h +++ b/src/audioCore/graph/SeqSourceProcessor.h @@ -69,8 +69,18 @@ class SeqSourceProcessor final : public juce::AudioProcessorGraph, int getCurrentMIDITrack() const; int getTotalMIDITrackNum() const; - void setRecording(bool recording); - bool getRecording() const; + enum RecordState { + NotRecording = 0, + + MIDINewTrackMode = 0x01, + MIDIInsertMode = 0x02, + MIDICoverMode = 0x03, + + AudioInsertMode = 0x10, + AudioCoverMode = 0x20 + }; + void setRecording(RecordState recordState); + RecordState getRecording() const; void setMute(bool mute); bool getMute() const; @@ -138,7 +148,7 @@ class SeqSourceProcessor final : public juce::AudioProcessorGraph, uint64_t audioSourceRef = 0, midiSourceRef = 0; std::atomic_int currentMIDITrack = 0; - std::atomic_bool recordingFlag = false; + std::atomic recordingFlag = RecordState::NotRecording; std::atomic_bool isMute = false; diff --git a/src/audioCore/misc/RecordTemp.cpp b/src/audioCore/misc/RecordTemp.cpp index 0600f07..99f77b2 100644 --- a/src/audioCore/misc/RecordTemp.cpp +++ b/src/audioCore/misc/RecordTemp.cpp @@ -56,6 +56,32 @@ void RecordTemp::recordData(double timeSec, } } +void RecordTemp::setRecordMIDI(bool recordMIDI) { + juce::GenericScopedLock locker(this->lock); + this->recordMIDI = recordMIDI; + if (!recordMIDI) { + this->clearMIDI(); + } +} + +void RecordTemp::setRecordAudio(bool recordAudio) { + juce::GenericScopedLock locker(this->lock); + this->recordAudio = recordAudio; + if (!recordAudio) { + this->clearAudio(); + } +} + +bool RecordTemp::isRecordMIDI() const { + juce::GenericScopedLock locker(this->lock); + return this->recordMIDI; +} + +bool RecordTemp::isRecordAudio() const { + juce::GenericScopedLock locker(this->lock); + return this->recordAudio; +} + void RecordTemp::clearAll() { juce::GenericScopedLock locker(this->lock); this->clearAudio(); diff --git a/src/audioCore/misc/RecordTemp.h b/src/audioCore/misc/RecordTemp.h index dc9c2ec..87cb515 100644 --- a/src/audioCore/misc/RecordTemp.h +++ b/src/audioCore/misc/RecordTemp.h @@ -11,6 +11,11 @@ class RecordTemp final : private juce::DeletedAtShutdown { void recordData(double timeSec, const juce::AudioBuffer& buffer, const juce::MidiBuffer& midiMessages); + void setRecordMIDI(bool recordMIDI); + void setRecordAudio(bool recordAudio); + bool isRecordMIDI() const; + bool isRecordAudio() const; + void clearAll(); void clearMIDI(); void clearAudio(); diff --git a/src/audioCore/quickAPI/QuickGet.cpp b/src/audioCore/quickAPI/QuickGet.cpp index 6a4595c..fe34cd2 100644 --- a/src/audioCore/quickAPI/QuickGet.cpp +++ b/src/audioCore/quickAPI/QuickGet.cpp @@ -634,13 +634,13 @@ namespace quickAPI { return false; } - bool getSeqTrackRecording(int index) { + RecordState getSeqTrackRecording(int index) { if (auto graph = AudioCore::getInstance()->getGraph()) { if (auto track = graph->getSourceProcessor(index)) { return track->getRecording(); } } - return false; + return RecordState::NotRecording; } const juce::Array getSeqTrackOutputLevel(int index) { diff --git a/src/audioCore/quickAPI/QuickGet.h b/src/audioCore/quickAPI/QuickGet.h index 31c7063..4dcc1ae 100644 --- a/src/audioCore/quickAPI/QuickGet.h +++ b/src/audioCore/quickAPI/QuickGet.h @@ -2,6 +2,7 @@ #include #include "../graph/PluginDecorator.h" +#include "../graph/SeqSourceProcessor.h" #include "../source/SourceMIDITemp.h" #include "../Utils.h" @@ -116,6 +117,7 @@ namespace quickAPI { const juce::AudioChannelSet getEffectChannelSet(int trackIndex, int index); int getEffectInputChannelNum(int trackIndex, int index); + using RecordState = SeqSourceProcessor::RecordState; int getSeqTrackNum(); const juce::String getSeqTrackName(int index); const juce::Colour getSeqTrackColor(int index); @@ -126,7 +128,7 @@ namespace quickAPI { const juce::Array getSeqTrackMIDIOutputToMixer(int index); const juce::Array getSeqTrackAudioOutputToMixer(int index); bool getSeqTrackMute(int index); - bool getSeqTrackRecording(int index); + RecordState getSeqTrackRecording(int index); const juce::Array getSeqTrackOutputLevel(int index); const juce::String getSeqTrackType(int index); bool isSeqTrackHasAudioData(int index); diff --git a/src/ui/component/sequencer/SeqTrackRecComponent.cpp b/src/ui/component/sequencer/SeqTrackRecComponent.cpp index 0a818e9..ca6423f 100644 --- a/src/ui/component/sequencer/SeqTrackRecComponent.cpp +++ b/src/ui/component/sequencer/SeqTrackRecComponent.cpp @@ -21,10 +21,10 @@ void SeqTrackRecComponent::paint(juce::Graphics& g) { /** Color */ auto& laf = this->getLookAndFeel(); - juce::Colour backgroundColor = laf.findColour(this->rec + juce::Colour backgroundColor = laf.findColour((this->rec > 0) ? juce::TextButton::ColourIds::buttonOnColourId : juce::TextButton::ColourIds::buttonColourId); - juce::Colour iconColor = laf.findColour(this->rec + juce::Colour iconColor = laf.findColour((this->rec > 0) ? juce::TextButton::ColourIds::textColourOnId : juce::TextButton::ColourIds::textColourOffId); @@ -96,5 +96,7 @@ void SeqTrackRecComponent::update(int index) { } void SeqTrackRecComponent::changeRec() { - CoreActions::setSeqRec(this->index, !(this->rec)); + /** TODO Change Recording State */ + CoreActions::setSeqRec(this->index, + static_cast((this->rec > 0) ? 0 : 0x12)); } diff --git a/src/ui/component/sequencer/SeqTrackRecComponent.h b/src/ui/component/sequencer/SeqTrackRecComponent.h index acdf0c3..33ef64e 100644 --- a/src/ui/component/sequencer/SeqTrackRecComponent.h +++ b/src/ui/component/sequencer/SeqTrackRecComponent.h @@ -18,7 +18,7 @@ class SeqTrackRecComponent final private: int index = -1; - bool rec = false; + int rec = 0; void changeRec(); diff --git a/src/ui/misc/CoreActions.cpp b/src/ui/misc/CoreActions.cpp index 28c7bc1..e86ed82 100644 --- a/src/ui/misc/CoreActions.cpp +++ b/src/ui/misc/CoreActions.cpp @@ -427,7 +427,7 @@ void CoreActions::setSeqMuteAll(bool mute) { } } -void CoreActions::setSeqRec(int index, bool rec) { +void CoreActions::setSeqRec(int index, quickAPI::RecordState rec) { auto action = std::unique_ptr(new ActionSetSequencerTrackRecording{ index, rec }); ActionDispatcher::getInstance()->dispatch(std::move(action)); } diff --git a/src/ui/misc/CoreActions.h b/src/ui/misc/CoreActions.h index c0bcbc2..d547c11 100644 --- a/src/ui/misc/CoreActions.h +++ b/src/ui/misc/CoreActions.h @@ -90,7 +90,7 @@ class CoreActions final { static void setSeqMute(int index, bool mute); static void setSeqSolo(int index); static void setSeqMuteAll(bool mute); - static void setSeqRec(int index, bool rec); + static void setSeqRec(int index, quickAPI::RecordState rec); static void setSeqMIDITrack(int index, int midiTrack); static void setSeqAudioRef(int index, const juce::String& path, const std::function& callback = {}); diff --git a/test/testSource.lua b/test/testSource.lua index 8ec9923..4336acc 100644 --- a/test/testSource.lua +++ b/test/testSource.lua @@ -29,7 +29,7 @@ AC.addSequencerBlock(0, 0, 300, 0); AC.removeSequencerBlock(0, 0); -- Seq Recording -AC.setSequencerTrackRecording(0, true); +AC.setSequencerTrackRecording(0, 0x21); -- Audio Save Config AC.setAudioSaveBitsPerSample(".wav", 32);