Skip to content

Commit

Permalink
Bugfix - Don't allow converting audio clip to instrument clip (#1532)
Browse files Browse the repository at this point in the history
* Don't allow converting audio clip to instrument clip

Converting audio clip to instrument is very problematic, thus it is better to eliminate this behaviour and instead direct users to delete the audio clip and create a new clip instead of going through the "nice to have" conversion process.

* Document change

* Address feedback
  • Loading branch information
seangoodvibes authored and m-m-adams committed Mar 21, 2024
1 parent e5667a1 commit 614cdbf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 98 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ here: [Community Features](https://github.com/SynthstromAudible/DelugeFirmware/b
- Added a feature save user-defined pad brightness level and restore it at startup.
- 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.

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

Expand Down
99 changes: 2 additions & 97 deletions src/deluge/gui/views/session_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,10 @@ ActionResult SessionView::buttonAction(deluge::hid::Button b, bool on, bool inCa
Clip* clip = getClipForLayout();

if (clip != nullptr) {
// If AudioClip, we have to convert back to an InstrumentClip
// Don't allow converting audio clip to instrument clip
if (clip->type == ClipType::AUDIO) {
actionLogger.deleteAllLogs();
replaceAudioClipWithInstrumentClip(clip, newOutputType);
display->displayPopup(l10n::get(l10n::String::STRING_FOR_CANT_CONVERT_TYPE));
}

// Or if already an InstrumentClip, changing Instrument type is easier
else {

InstrumentClip* instrumentClip = (InstrumentClip*)clip;
Expand Down Expand Up @@ -1592,98 +1589,6 @@ Clip* SessionView::createNewInstrumentClip(int32_t yDisplay) {
return newClip;
}

void SessionView::replaceAudioClipWithInstrumentClip(Clip* clip, OutputType outputType) {
int32_t clipIndex = currentSong->sessionClips.getIndexForClip(clip);

if (!clip || clip->type != ClipType::AUDIO) {
return;
}

if (currentSong->sessionLayout == SessionLayoutType::SessionLayoutTypeGrid
&& currentSong->getClipWithOutput(clip->output, false, clip)) {
display->displayPopup(deluge::l10n::get(
deluge::l10n::String::STRING_FOR_AUDIO_TRACKS_WITH_CLIPS_CANT_BE_TURNED_INTO_AN_INSTRUMENT));
return;
}

AudioClip* audioClip = (AudioClip*)clip;
if (audioClip->sampleHolder.audioFile || audioClip->getCurrentlyRecordingLinearly()) {
display->displayPopup(deluge::l10n::get(deluge::l10n::String::STRING_FOR_CLIP_NOT_EMPTY));
return;
}

// Allocate memory for InstrumentClip
void* clipMemory = GeneralMemoryAllocator::get().allocMaxSpeed(sizeof(InstrumentClip));
if (!clipMemory) {
ramError:
display->displayError(Error::INSUFFICIENT_RAM);
return;
}

// Create the audio clip and ParamManager
InstrumentClip* newClip = new (clipMemory) InstrumentClip(currentSong);

// Give the new clip its stuff
newClip->cloneFrom(clip);
newClip->colourOffset = random(72);

bool instrumentAlreadyInSong;
Error error;

if (outputType == OutputType::SYNTH || outputType == OutputType::KIT) {

error = setPresetOrNextUnlaunchedOne(newClip, outputType, &instrumentAlreadyInSong);
if (error != Error::NONE) {
gotError:
display->displayError(error);
gotErrorDontDisplay:
newClip->~InstrumentClip();
delugeDealloc(clipMemory);
return;
}
}

else {
Instrument* newInstrument = currentSong->getNonAudioInstrumentToSwitchTo(
outputType, Availability::INSTRUMENT_UNUSED, 0, -1, &instrumentAlreadyInSong);
if (!newInstrument) {
goto gotErrorDontDisplay;
}

error = newClip->setNonAudioInstrument(newInstrument, currentSong);
if (error != Error::NONE) {
// TODO: we'd really want to deallocate the Instrument
goto gotError;
}
}

if (!instrumentAlreadyInSong) {
currentSong->addOutput(newClip->output);
}

// Possibly want to set this as the active Clip...
if (!newClip->output->activeClip) {

char modelStackMemory[MODEL_STACK_MAX_SIZE];
ModelStack* modelStack = setupModelStackWithSong(modelStackMemory, currentSong);

ModelStackWithTimelineCounter* modelStackWithTimelineCounter = modelStack->addTimelineCounter(newClip);

newClip->output->setActiveClip(modelStackWithTimelineCounter);
}

newClip->output->colour = clip->output->colour;

currentSong->swapClips(newClip, clip, clipIndex);

view.setActiveModControllableTimelineCounter(newClip);
view.displayOutputName(newClip->output, true, newClip);

if (display->haveOLED()) {
deluge::hid::display::OLED::sendMainImage();
}
}

void SessionView::replaceInstrumentClipWithAudioClip(Clip* clip) {
int32_t clipIndex = currentSong->sessionClips.getIndexForClip(clip);

Expand Down
1 change: 0 additions & 1 deletion src/deluge/gui/views/session_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class SessionView final : public ClipNavigationTimelineView {
Clip* createNewInstrumentClip(int32_t yDisplay);
void goToArrangementEditor();
void replaceInstrumentClipWithAudioClip(Clip* clip);
void replaceAudioClipWithInstrumentClip(Clip* clip, OutputType outputType);
void rowNeedsRenderingDependingOnSubMode(int32_t yDisplay);
void setCentralLEDStates();

Expand Down

0 comments on commit 614cdbf

Please sign in to comment.