1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 09:20:16 +01:00

TimeTrack drawing not dependent on EnvelopeEditor...

... after a static function is moved from EnvelopeEditor to Envelope
This commit is contained in:
Paul Licameli
2019-06-05 14:03:59 -04:00
parent a99b746520
commit 63350d8573
6 changed files with 55 additions and 55 deletions

View File

@@ -103,48 +103,6 @@ void EnvelopeEditor::DrawPoints
}
}
void EnvelopeEditor::GetValues
( const Envelope &env,
double alignedTime, double sampleDur,
double *buffer, int bufferLen, int leftOffset,
const ZoomInfo &zoomInfo )
{
// Getting many envelope values, corresponding to pixel columns, which may
// not be uniformly spaced in time when there is a fisheye.
double prevDiscreteTime=0.0, prevSampleVal=0.0, nextSampleVal=0.0;
for ( int xx = 0; xx < bufferLen; ++xx ) {
auto time = zoomInfo.PositionToTime( xx, -leftOffset );
if ( sampleDur <= 0 )
// Sample interval not defined (as for time track)
buffer[xx] = env.GetValue( time );
else {
// The level of zoom-in may resolve individual samples.
// If so, then instead of evaluating the envelope directly,
// we draw a piecewise curve with knees at each sample time.
// This actually makes clearer what happens as you drag envelope
// points and make discontinuities.
auto leftDiscreteTime = alignedTime +
sampleDur * floor( ( time - alignedTime ) / sampleDur );
if ( xx == 0 || leftDiscreteTime != prevDiscreteTime ) {
prevDiscreteTime = leftDiscreteTime;
prevSampleVal =
env.GetValue( prevDiscreteTime, sampleDur );
nextSampleVal =
env.GetValue( prevDiscreteTime + sampleDur, sampleDur );
}
auto ratio = ( time - leftDiscreteTime ) / sampleDur;
if ( env.GetExponential() )
buffer[ xx ] = exp(
( 1.0 - ratio ) * log( prevSampleVal )
+ ratio * log( nextSampleVal ) );
else
buffer[ xx ] =
( 1.0 - ratio ) * prevSampleVal + ratio * nextSampleVal;
}
}
}
EnvelopeEditor::EnvelopeEditor(Envelope &envelope, bool mirrored)
: mEnvelope(envelope)
, mMirrored(mirrored)