Skip to content

Commit

Permalink
Improve performance when creating Reaper automation points
Browse files Browse the repository at this point in the history
See: https://www.reaper.fm/sdk/reascript/reascripthelp.html#InsertEnvelopePoint
InsertEnvelopePoint()'s sort control flag works opposite to the way you'd expect.  Flipping this code around prevents Reaper from re-sorting the automation curve for each point added, which significantly reduces execution time.
  • Loading branch information
carmethene authored and firthm01 committed Sep 14, 2023
1 parent 5589fd6 commit 9a5c788
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reaper-adm-extension/src/reaper_adm/automationenvelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ void DefinedStartEnvelope::createPoints(double pointsOffset)
{
double earliestPointOnTimeline{ -1.0 };
double pointOnTimeline{ 0.0 };
bool sortPoints{false};
bool noSortPoints{true};

for(auto& point : points) {
pointOnTimeline = point.effectiveTime() + pointsOffset;
if (earliestPointOnTimeline < 0.0 || pointOnTimeline < earliestPointOnTimeline) {
earliestPointOnTimeline = pointOnTimeline;
}
api.InsertEnvelopePoint(trackEnvelope, pointOnTimeline, point.value(), 0, 0, false, &sortPoints);
api.InsertEnvelopePoint(trackEnvelope, pointOnTimeline, point.value(), 0, 0, false, &noSortPoints);
}
api.Envelope_SortPoints(trackEnvelope);

Expand Down

0 comments on commit 9a5c788

Please sign in to comment.