From f5a7e4ce7cc976719e6d19e303ee3ec1e37986ee Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 7 May 2017 19:18:12 -0400 Subject: [PATCH] Define private Envelope evaluator functions taking relative time... ... To be very sure we can avoid roundoff errors from adding mOffset and subtracting it again; so that evaluation exactly at a control point time gives the exact value of that point. --- src/Envelope.cpp | 13 +++++++++++++ src/Envelope.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/Envelope.cpp b/src/Envelope.cpp index 75f5dfe3d..42b938d93 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -1060,6 +1060,14 @@ double Envelope::GetValue(double t) const return temp; } +double Envelope::GetValueRelative(double t) const +{ + double temp; + + GetValuesRelative(&temp, 1, t, 1.0); + return temp; +} + // relative time /// @param Lo returns last index at or before this time, maybe -1 /// @param Hi returns first index after this time, maybe past the end @@ -1126,7 +1134,12 @@ void Envelope::GetValues(double *buffer, int bufferLen, { // Convert t0 from absolute to clip-relative time t0 -= mOffset; + GetValuesRelative( buffer, bufferLen, t0, tstep); +} +void Envelope::GetValuesRelative(double *buffer, int bufferLen, + double t0, double tstep) const +{ // JC: If bufferLen ==0 we have probably just allocated a zero sized buffer. // wxASSERT( bufferLen > 0 ); diff --git a/src/Envelope.h b/src/Envelope.h index 5bec859d1..2c9d89ce1 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -145,6 +145,9 @@ public: (double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo) const; private: + double GetValueRelative(double t) const; + void GetValuesRelative + (double *buffer, int len, double t0, double tstep) const; // relative time int NumberOfPointsAfter(double t) const; // relative time