1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

Timetrack fixes and refactoring.

Possibly fixes:

Bug 206 - Time Tracks: Ruler warp goes in wrong direction
Bug 205 - Time Tracks that slow down the audio result in truncated exports
This commit is contained in:
mchinen
2010-10-07 23:01:49 +00:00
parent 2fd5555378
commit a9a0d51454
14 changed files with 77 additions and 41 deletions

View File

@@ -69,6 +69,7 @@ array of Ruler::Label.
#include "../Theme.h"
#include "../AllThemeResources.h"
#include "../Experimental.h"
#include "../TimeTrack.h"
#define max(a,b) ( (a<b)?b:a )
@@ -905,10 +906,10 @@ void Ruler::TickCustom(int labelIdx, bool major, bool minor)
void Ruler::Update()
{
Update(NULL, 0, 0);
Update(NULL);
}
void Ruler::Update( Envelope *speedEnv, long minSpeed, long maxSpeed )
void Ruler::Update(TimeTrack* timetrack)// Envelope *speedEnv, long minSpeed, long maxSpeed )
{
// This gets called when something has been changed
// (i.e. we've been invalidated). Recompute all
@@ -1050,19 +1051,14 @@ void Ruler::Update( Envelope *speedEnv, long minSpeed, long maxSpeed )
i = -1;
while(i <= mLength) {
double warpfactor;
if( d>0 && speedEnv != NULL ) {
warpfactor = speedEnv->Average( lastD, d );
// Now we re-scale so that 0.5 is normal speed and
// 0 and 1.0 are min% and max% of normal speed
warpfactor = (maxSpeed * (1 - warpfactor) +
warpfactor * minSpeed) / 100.0;
}
if( d>0 && timetrack != NULL )
warpfactor = timetrack->ComputeWarpFactor( lastD, d );
else
warpfactor = 1.0;
i++;
lastD = d;
d += UPP*warpfactor;
d += UPP/warpfactor;
if ((int)floor(sg * d / mMajor) > majorInt) {
majorInt = (int)floor(sg * d / mMajor);
@@ -1077,19 +1073,14 @@ void Ruler::Update( Envelope *speedEnv, long minSpeed, long maxSpeed )
i = -1;
while(i <= mLength) {
double warpfactor;
if( d>0 && speedEnv != NULL ) {
warpfactor = speedEnv->Average( lastD, d );
// Now we re-scale so that 0.5 is normal speed and
// 0 and 1.0 are min% and max% of normal speed
warpfactor = (maxSpeed * (1 - warpfactor) +
warpfactor * minSpeed) / 100.0;
}
if( d>0 && timetrack != NULL )
warpfactor = timetrack->ComputeWarpFactor( lastD, d );
else
warpfactor = 1.0;
i++;
lastD = d;
d += UPP*warpfactor;
d += UPP/warpfactor;
if ((int)floor(sg * d / mMinor) > minorInt) {
minorInt = (int)floor(sg * d / mMinor);
@@ -1217,17 +1208,17 @@ void Ruler::Update( Envelope *speedEnv, long minSpeed, long maxSpeed )
void Ruler::Draw(wxDC& dc)
{
Draw( dc, NULL, 0, 0);
Draw( dc, NULL);
}
void Ruler::Draw(wxDC& dc, Envelope *speedEnv, long minSpeed, long maxSpeed)
void Ruler::Draw(wxDC& dc, TimeTrack* timetrack)
{
mDC = &dc;
if( mLength <=0 )
return;
if (!mValid)
Update( speedEnv, minSpeed, maxSpeed );
Update(timetrack);
#ifdef EXPERIMENTAL_THEMING
mDC->SetPen(mPen);
@@ -1462,7 +1453,7 @@ void Ruler::GetMaxSize(wxCoord *width, wxCoord *height)
wxBitmap tmpBM(1, 1);
tmpDC.SelectObject(tmpBM);
mDC = &tmpDC;
Update( NULL, 0, 0 );
Update( NULL);
}
if (width)

View File

@@ -21,6 +21,7 @@
struct ViewInfo;
class AudacityProject;
class TimeTrack;
class AUDACITY_DLL_API Ruler {
public:
@@ -115,7 +116,7 @@ class AUDACITY_DLL_API Ruler {
// Note that it will not erase for you...
void Draw(wxDC& dc);
void Draw(wxDC& dc, Envelope *speedEnv, long minSpeed, long maxSpeed);
void Draw(wxDC& dc, TimeTrack* timetrack);
// If length <> 0, draws lines perpendiculars to ruler corresponding
// to selected ticks (major, minor, or both), in an adjacent window.
// You may need to use the offsets if you are using part of the dc for rulers, borders etc.
@@ -128,7 +129,7 @@ class AUDACITY_DLL_API Ruler {
private:
void Invalidate();
void Update();
void Update(Envelope *speedEnv, long minSpeed, long maxSpeed);
void Update(TimeTrack* timetrack);
void FindTickSizes();
void FindLinearTickSizes(double UPP);
wxString LabelString(double d, bool major);