Skip to content

Commit

Permalink
Dont allow change of instrument clip to/from kit type if not empty (#…
Browse files Browse the repository at this point in the history
…1533)

Restrict change of instrument clip types if instrument clip is not empty

Only applies if changing to/from kit clip type
  • Loading branch information
seangoodvibes authored and m-m-adams committed Mar 21, 2024
1 parent 55e146d commit 83a6850
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ here: [Community Features](https://github.com/SynthstromAudible/DelugeFirmware/b
- Mod (Gold) Encoder LED indicators are now Bipolar for Bipolar params (e.g. Param, Pitch, Patch Cables). Positive values illuminate the top two LEDs. Negative values illuminate the bottom two LEDs. The middle value doesn't light up any LEDs.
- The play button now blinks when the the CPU Usage of the Deluge is high and synth voices/sample playback are being culled.
- Removed ability to convert an Audio Clip to an Instrument Clip (Synth / Kit / MIDI / CV) as this conversion process is error/bug prone.
- Restricted changing Synth/MIDI/CV Instrument CLip types to the Kit Instrument Clip Type and vice versa if the clip is not empty.

In addition, a number of improvements have been made to how the OLED display is used:

Expand Down
7 changes: 7 additions & 0 deletions src/deluge/gui/views/instrument_clip_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,13 @@ void InstrumentClipView::changeOutputType(OutputType newOutputType) {
return;
}

// don't allow clip type change if clip is not empty
// only impose this restriction if switching to/from kit clip
if (((getCurrentOutputType() == OutputType::KIT) || (newOutputType == OutputType::KIT))
&& !getCurrentInstrumentClip()->isEmpty()) {
return;
}

InstrumentClipMinder::changeOutputType(newOutputType);

recalculateColours();
Expand Down
11 changes: 9 additions & 2 deletions src/deluge/gui/views/session_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@ ActionResult SessionView::buttonAction(deluge::hid::Button b, bool on, bool inCa
InstrumentClip* instrumentClip = (InstrumentClip*)clip;
Instrument* instrument = (Instrument*)instrumentClip->output;

// don't allow clip type change if clip is not empty
// only impose this restriction if switching to/from kit clip
if (((getCurrentOutputType() == OutputType::KIT) || (newOutputType == OutputType::KIT))
&& !instrumentClip->isEmpty()) {
return ActionResult::DEALT_WITH;
}

// If load button held, go into LoadInstrumentPresetUI
if (Buttons::isButtonPressed(deluge::hid::button::LOAD)) {

Expand Down Expand Up @@ -1603,9 +1610,9 @@ void SessionView::replaceInstrumentClipWithAudioClip(Clip* clip) {
return;
}

// don't allow clip type change if clip is not empty
InstrumentClip* instrumentClip = (InstrumentClip*)clip;
if (instrumentClip->containsAnyNotes() || instrumentClip->output->clipHasInstance(clip)) {
display->displayPopup(deluge::l10n::get(deluge::l10n::String::STRING_FOR_CLIP_NOT_EMPTY));
if (!instrumentClip->isEmpty()) {
return;
}

Expand Down
9 changes: 9 additions & 0 deletions src/deluge/model/clip/instrument_clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "model/clip/instrument_clip.h"
#include "definitions_cxx.hpp"
#include "gui/l10n/l10n.h"
#include "gui/ui/browser/browser.h"
#include "gui/ui/load/load_instrument_preset_ui.h"
#include "gui/views/arranger_view.h"
Expand Down Expand Up @@ -3690,6 +3691,14 @@ bool InstrumentClip::isScrollWithinRange(int32_t scrollAmount, int32_t newYNote)
return true;
}

bool InstrumentClip::isEmpty() {
if (containsAnyNotes() || output->clipHasInstance(this)) {
display->displayPopup(deluge::l10n::get(deluge::l10n::String::STRING_FOR_CLIP_NOT_EMPTY));
return false;
}
return true;
}

bool InstrumentClip::containsAnyNotes() {
for (int32_t i = 0; i < noteRows.getNumElements(); i++) {
NoteRow* thisNoteRow = noteRows.getElement(i);
Expand Down
1 change: 1 addition & 0 deletions src/deluge/model/clip/instrument_clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class InstrumentClip final : public Clip {
NoteRow* getNoteRowFromId(int32_t id);
/// Return true if successfully shifted. Instrument clips always succeed
bool shiftHorizontally(ModelStackWithTimelineCounter* modelStack, int32_t amount);
bool isEmpty();
bool containsAnyNotes();
ModelStackWithNoteRow* getNoteRowOnScreen(int32_t yDisplay, ModelStackWithTimelineCounter* modelStack);
NoteRow* getNoteRowOnScreen(int32_t yDisplay, Song* song, int32_t* getIndex = NULL);
Expand Down
9 changes: 7 additions & 2 deletions src/deluge/model/clip/instrument_clip_minder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,13 @@ ActionResult InstrumentClipMinder::buttonAction(deluge::hid::Button b, bool on,
else if (b == MIDI) {
out = OutputType::MIDI_OUT;
}
loadInstrumentPresetUI.setupLoadInstrument(out, getCurrentInstrument(), getCurrentInstrumentClip());
openUI(&loadInstrumentPresetUI);
// don't allow clip type change if clip is not empty
// only impose this restriction if switching to/from kit clip
if (!(((getCurrentOutputType() == OutputType::KIT) || (out == OutputType::KIT))
&& !getCurrentInstrumentClip()->isEmpty())) {
loadInstrumentPresetUI.setupLoadInstrument(out, getCurrentInstrument(), getCurrentInstrumentClip());
openUI(&loadInstrumentPresetUI);
}
}

// Select button, without shift
Expand Down

0 comments on commit 83a6850

Please sign in to comment.