mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +02:00
TimeTrack drawing not dependent on EnvelopeEditor...
... after a static function is moved from EnvelopeEditor to Envelope
This commit is contained in:
parent
a99b746520
commit
63350d8573
@ -1455,3 +1455,46 @@ void Envelope::testMe()
|
|||||||
checkResult( 18, NextPointAfter( 0 ), 5 );
|
checkResult( 18, NextPointAfter( 0 ), 5 );
|
||||||
checkResult( 19, NextPointAfter( 5 ), 10 );
|
checkResult( 19, NextPointAfter( 5 ), 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "ZoomInfo.h"
|
||||||
|
void Envelope::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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -83,6 +83,15 @@ public:
|
|||||||
|
|
||||||
virtual ~Envelope();
|
virtual ~Envelope();
|
||||||
|
|
||||||
|
/** \brief Get many envelope points for pixel columns at once,
|
||||||
|
* but don't assume uniform time per pixel.
|
||||||
|
*/
|
||||||
|
static void GetValues
|
||||||
|
( const Envelope &env,
|
||||||
|
double aligned_time, double sampleDur,
|
||||||
|
double *buffer, int bufferLen, int leftOffset,
|
||||||
|
const ZoomInfo &zoomInfo);
|
||||||
|
|
||||||
// Return true if violations of point ordering invariants were detected
|
// Return true if violations of point ordering invariants were detected
|
||||||
// and repaired
|
// and repaired
|
||||||
bool ConsistencyCheck();
|
bool ConsistencyCheck();
|
||||||
|
@ -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)
|
EnvelopeEditor::EnvelopeEditor(Envelope &envelope, bool mirrored)
|
||||||
: mEnvelope(envelope)
|
: mEnvelope(envelope)
|
||||||
, mMirrored(mirrored)
|
, mMirrored(mirrored)
|
||||||
|
@ -29,15 +29,6 @@ public:
|
|||||||
bool dB, double dBRange,
|
bool dB, double dBRange,
|
||||||
float zoomMin, float zoomMax, bool mirrored);
|
float zoomMin, float zoomMax, bool mirrored);
|
||||||
|
|
||||||
/** \brief Get many envelope points for pixel columns at once,
|
|
||||||
* but don't assume uniform time per pixel.
|
|
||||||
*/
|
|
||||||
static void GetValues
|
|
||||||
( const Envelope &env,
|
|
||||||
double aligned_time, double sampleDur,
|
|
||||||
double *buffer, int bufferLen, int leftOffset,
|
|
||||||
const ZoomInfo &zoomInfo);
|
|
||||||
|
|
||||||
EnvelopeEditor(Envelope &envelope, bool mirrored);
|
EnvelopeEditor(Envelope &envelope, bool mirrored);
|
||||||
~EnvelopeEditor();
|
~EnvelopeEditor();
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "AColor.h"
|
#include "AColor.h"
|
||||||
#include "widgets/Ruler.h"
|
#include "widgets/Ruler.h"
|
||||||
#include "Envelope.h"
|
#include "Envelope.h"
|
||||||
#include "EnvelopeEditor.h"
|
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
#include "ProjectSettings.h"
|
#include "ProjectSettings.h"
|
||||||
@ -316,7 +315,7 @@ void TimeTrack::Draw
|
|||||||
mRuler->Draw(dc, GetEnvelope());
|
mRuler->Draw(dc, GetEnvelope());
|
||||||
|
|
||||||
Doubles envValues{ size_t(mid.width) };
|
Doubles envValues{ size_t(mid.width) };
|
||||||
EnvelopeEditor::GetValues( *GetEnvelope(),
|
Envelope::GetValues( *GetEnvelope(),
|
||||||
0, 0, envValues.get(), mid.width, 0, zoomInfo );
|
0, 0, envValues.get(), mid.width, 0, zoomInfo );
|
||||||
|
|
||||||
wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
|
wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
|
||||||
|
@ -1816,7 +1816,7 @@ void TrackArt::DrawClipWaveform(TrackPanelDrawingContext &context,
|
|||||||
|
|
||||||
std::vector<double> vEnv(mid.width);
|
std::vector<double> vEnv(mid.width);
|
||||||
double *const env = &vEnv[0];
|
double *const env = &vEnv[0];
|
||||||
EnvelopeEditor::GetValues( *clip->GetEnvelope(),
|
Envelope::GetValues( *clip->GetEnvelope(),
|
||||||
tOffset,
|
tOffset,
|
||||||
|
|
||||||
// PRL: change back to make envelope evaluate only at sample times
|
// PRL: change back to make envelope evaluate only at sample times
|
||||||
@ -1956,7 +1956,7 @@ void TrackArt::DrawClipWaveform(TrackPanelDrawingContext &context,
|
|||||||
if (!showIndividualSamples) {
|
if (!showIndividualSamples) {
|
||||||
std::vector<double> vEnv2(rectPortion.width);
|
std::vector<double> vEnv2(rectPortion.width);
|
||||||
double *const env2 = &vEnv2[0];
|
double *const env2 = &vEnv2[0];
|
||||||
EnvelopeEditor::GetValues( *clip->GetEnvelope(),
|
Envelope::GetValues( *clip->GetEnvelope(),
|
||||||
tOffset,
|
tOffset,
|
||||||
|
|
||||||
// PRL: change back to make envelope evaluate only at sample times
|
// PRL: change back to make envelope evaluate only at sample times
|
||||||
|
Loading…
x
Reference in New Issue
Block a user