Skip to content

Commit

Permalink
Fix #633
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulFreund committed Nov 9, 2023
1 parent de38ac9 commit 080e492
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/deluge/model/clip/instrument_clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,9 @@ void InstrumentClip::clear(Action* action, ModelStackWithTimelineCounter* modelS
modelStack->addNoteRow(getNoteRowId(thisNoteRow, i), thisNoteRow);
thisNoteRow->clear(action, modelStackWithNoteRow);
}

// Paul: Note rows were lingering, delete them immediately instead of relying they get deleted along the way
noteRows.deleteNoteRowAtIndex(0, noteRows.getNumElements());
}

bool InstrumentClip::doesProbabilityExist(int32_t apartFromPos, int32_t probability, int32_t secondProbability) {
Expand Down
19 changes: 14 additions & 5 deletions src/deluge/modulation/params/param_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ int32_t ParamManager::cloneParamCollectionsFrom(ParamManager* other, bool copyAu
int32_t reverseDirectionWithLength) {

ParamCollectionSummary mpeParamsOrNullHere = *getExpressionParamSetSummary();
if (mpeParamsOrNullHere.paramCollection) {
cloneExpressionParams = false; // If we already have expression params, then just don't clone from "other".
// Paul: Prevent MPE data from not getting exchanged with a newly allocated pointer if we allocate the same params for another clip
if (this != other) {
if (mpeParamsOrNullHere.paramCollection) {
cloneExpressionParams = false; // If we already have expression params, then just don't clone from "other".
}
}

// First, allocate the memories
Expand Down Expand Up @@ -220,11 +223,17 @@ int32_t ParamManager::cloneParamCollectionsFrom(ParamManager* other, bool copyAu
otherSummary++;
}

*newSummary = mpeParamsOrNullHere;
if (mpeParamsOrNullHere.paramCollection) { // Check first, otherwise we'll overflow the array, I think...
newSummary++;
// Paul: If we move allocation position of the same clip mpe data was allocated above and doesn't require special treatment
if (this == other) {
*newSummary = {0}; // Mark end of list
}
else {
*newSummary = mpeParamsOrNullHere;
if (mpeParamsOrNullHere.paramCollection) { // Check first, otherwise we'll overflow the array, I think...
newSummary++;
*newSummary = {0}; // Mark end of list
}
}

// And finally, copy the pointers and flags from newSummaries to our permanent summaries array.
newSummary = newSummaries;
Expand Down

0 comments on commit 080e492

Please sign in to comment.