Skip to content

Commit

Permalink
Maintain LFO phase constraint in mseg node delete (surge-synthesizer#…
Browse files Browse the repository at this point in the history
…6370)

We have to explicitly maintain the endpoint constraint and
rebuild when deleting in MSEG LFO mode. Without it the last
node ended up obviously wrong.

Closes surge-synthesizer#6349
  • Loading branch information
baconpaul authored Jul 16, 2022
1 parent bba6515 commit ddb4788
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/common/dsp/modulators/MSEGModulationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,21 @@ void deleteSegment(MSEGStorage *ms, int idx)

ms->n_activeSegments--;

if (ms->editMode == MSEGStorage::LFO)
{
// We need to fill up the last one to span.
auto ei = ms->n_activeSegments - 1;
ms->segmentEnd[ei] = 1.0;
auto cd = 0.f;
for (int i = 0; i < ei; ++i)
cd += ms->segments[i].duration;

ms->segments[ei].duration = 1.0 - cd;
ms->segments[ei].cpduration += 1.0 - cd;

rebuildCache(ms);
}

if (ms->loop_start > idx)
{
ms->loop_start--;
Expand Down

0 comments on commit ddb4788

Please sign in to comment.