Skip to content

Commit

Permalink
Catch Notes setting to allow not catching existing notes. (#221)
Browse files Browse the repository at this point in the history
* Add on/off setting for Catch Notes to allow not catching late notes.

* Formatting

---------

Co-authored-by: weavermedia <dan@Dweaver.media>
  • Loading branch information
weavermedia and weavermedia committed Jul 21, 2023
1 parent 1952142 commit 6b17091
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/deluge/gui/menu_item/runtime_feature/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ Setting menuMasterCompressorFx(RuntimeFeatureSettingType::MasterCompressorFx);
Setting menuFineTempo(RuntimeFeatureSettingType::FineTempoKnob);
Setting menuQuantize(RuntimeFeatureSettingType::Quantize);
Setting menuPatchCableResolution(RuntimeFeatureSettingType::PatchCableResolution);
Setting menuCatchNotes(RuntimeFeatureSettingType::CatchNotes);

std::array<MenuItem*, RuntimeFeatureSettingType::MaxElement + 1> subMenuEntries{
&menuDrumRandomizer,
&menuMasterCompressorFx,
&menuFineTempo,
&menuQuantize,
&menuPatchCableResolution,
&menuCatchNotes,

nullptr,
};
Expand Down
47 changes: 26 additions & 21 deletions src/deluge/model/note/note_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "io/midi/midi_device.h"
#include "gui/views/view.h"
#include "gui/views/instrument_clip_view.h"
#include "model/settings/runtime_feature_settings.h"

extern "C" {
#include "RZA1/uart/sio_char.h"
Expand Down Expand Up @@ -238,15 +239,17 @@ uint8_t NoteRow::getSquareType(int32_t squareStart, int32_t squareWidth, Note**
if (clipCurrentlyPlaying && !muted) {
((InstrumentClip*)modelStack->getTimelineCounter())->expectEvent();

// If the play-pos is inside this note, see if we'd like to attempt a late-start of it
int actualPlayPos = getLivePos(modelStack);
if ((runtimeFeatureSettings.get(RuntimeFeatureSettingType::CatchNotes) == RuntimeFeatureStateToggle::On)) {
// If the play-pos is inside this note, see if we'd like to attempt a late-start of it
int actualPlayPos = getLivePos(modelStack);

int howFarIntoNote = actualPlayPos - newNote->pos;
if (howFarIntoNote < 0) {
howFarIntoNote += effectiveLength;
}
if (howFarIntoNote < newNote->getLength()) {
attemptLateStartOfNextNoteToPlay(modelStack, newNote);
int howFarIntoNote = actualPlayPos - newNote->pos;
if (howFarIntoNote < 0) {
howFarIntoNote += effectiveLength;
}
if (howFarIntoNote < newNote->getLength()) {
attemptLateStartOfNextNoteToPlay(modelStack, newNote);
}
}
}

Expand Down Expand Up @@ -2687,20 +2690,22 @@ void NoteRow::resumePlayback(ModelStackWithNoteRow* modelStack, bool clipMayMake

int32_t effectiveActualCurrentPos = getLivePos(modelStack);

// See if our play-pos is inside of a note, which we might want to try playing...
int i = notes.search(effectiveActualCurrentPos, LESS);
bool wrapping = (i == -1);
if (wrapping) {
i = notes.getNumElements() - 1;
}
Note* note = notes.getElement(i);
int noteEnd = note->pos + note->length;
if (wrapping) {
noteEnd -= modelStack->getLoopLength();
}
if ((runtimeFeatureSettings.get(RuntimeFeatureSettingType::CatchNotes) == RuntimeFeatureStateToggle::On)) {
// See if our play-pos is inside of a note, which we might want to try playing...
int i = notes.search(effectiveActualCurrentPos, LESS);
bool wrapping = (i == -1);
if (wrapping) {
i = notes.getNumElements() - 1;
}
Note* note = notes.getElement(i);
int noteEnd = note->pos + note->length;
if (wrapping) {
noteEnd -= modelStack->getLoopLength();
}

if (noteEnd > effectiveActualCurrentPos) {
attemptLateStartOfNextNoteToPlay(modelStack, note);
if (noteEnd > effectiveActualCurrentPos) {
attemptLateStartOfNextNoteToPlay(modelStack, note);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/deluge/model/settings/runtime_feature_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ void RuntimeFeatureSettings::init() {
// PatchCableResolution
SetupOnOffSetting(settings[RuntimeFeatureSettingType::PatchCableResolution], "Mod. depth decimals",
"ModDepthDecimals", RuntimeFeatureStateToggle::On);
// CatchNotes
SetupOnOffSetting(settings[RuntimeFeatureSettingType::CatchNotes], "CatchNotes", "catchNotes",
RuntimeFeatureStateToggle::On);
}

void RuntimeFeatureSettings::readSettingsFromFile() {
Expand Down
1 change: 1 addition & 0 deletions src/deluge/model/settings/runtime_feature_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum RuntimeFeatureSettingType : uint32_t {
Quantize,
FineTempoKnob,
PatchCableResolution,
CatchNotes,
MaxElement // Keep as boundary
};

Expand Down

0 comments on commit 6b17091

Please sign in to comment.