1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00

Merge branch 'master'

This commit is contained in:
Paul Licameli 2015-08-27 16:54:48 -04:00
commit 2ef874f036
4 changed files with 47 additions and 4 deletions

View File

@ -708,6 +708,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
{
// do a translation into the linear space
wt->SetLastScaleType();
wt->SetLastdBRange();
float sign = (min >= 0 ? 1 : -1);
if (min != 0.) {
min = DB_TO_LINEAR(fabs(min) * dBRange - dBRange);
@ -742,12 +743,14 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
float min, max;
wt->GetDisplayBounds(&min, &max);
float lastdBRange;
if (wt->GetLastScaleType() != scaleType &&
wt->GetLastScaleType() != -1)
{
// do a translation into the dB space
wt->SetLastScaleType();
wt->SetLastdBRange();
float sign = (min >= 0 ? 1 : -1);
if (min != 0.) {
min = (LINEAR_TO_DB(fabs(min)) + dBRange) / dBRange;
@ -765,6 +768,30 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
}
wt->SetDisplayBounds(min, max);
}
else if (dBRange != (lastdBRange = wt->GetLastdBRange())) {
wt->SetLastdBRange();
// Remap the max of the scale
const float sign = (max >= 0 ? 1 : -1);
float newMax = max;
if (max != 0.) {
// Ugh, duplicating from TrackPanel.cpp
#define ZOOMLIMIT 0.001f
const float extreme = LINEAR_TO_DB(2);
// recover dB value of max
const float dB = std::min(extreme, (float(fabs(max)) * lastdBRange - lastdBRange));
// find new scale position, but old max may get trimmed if the db limit rises
// Don't trim it to zero though, but leave max and limit distinct
newMax = sign * std::max(ZOOMLIMIT, (dBRange + dB) / dBRange);
// Adjust the min of the scale if we can,
// so the db Limit remains where it was on screen, but don't violate extremes
if (min != 0.)
min = std::max(-extreme, newMax * min / max);
}
wt->SetDisplayBounds(min, newMax);
}
if (max > 0) {
int top = 0;

View File

@ -4713,15 +4713,20 @@ void TrackPanel::HandleWaveTrackVZoom
}
else {
// Zoom out
const WaveformSettings &settings = track->GetWaveformSettings();
const bool linear = settings.isLinear();
const float top = linear
? 2.0
: (LINEAR_TO_DB(2.0) + settings.dBRange) / settings.dBRange;
if (min <= -1.0 && max >= 1.0) {
// Go to the maximal zoom-out
min = -2.0;
max = 2.0;
min = -top;
max = top;
}
else {
// limit to +/- 1 range unless already outside that range...
float minRange = (min < -1) ? -2.0 : -1.0;
float maxRange = (max > 1) ? 2.0 : 1.0;
float minRange = (min < -1) ? -top : -1.0;
float maxRange = (max > 1) ? top : 1.0;
// and enforce vertical zoom limits.
const float p1 = (zoomStart - ypos) / (float)height;
if (fixedMousePoint) {

View File

@ -109,6 +109,7 @@ WaveTrack::WaveTrack(DirManager *projDirManager, sampleFormat format, double rat
mDisplayLocations = NULL;
mDisplayNumLocationsAllocated = 0;
mLastScaleType = -1;
mLastdBRange = -1;
mAutoSaveIdent = 0;
}
@ -121,6 +122,7 @@ WaveTrack::WaveTrack(WaveTrack &orig):
? new WaveformSettings(*orig.mpWaveformSettings) : 0)
{
mLastScaleType = -1;
mLastdBRange = -1;
mLegacyProjectFileOffset = 0;
@ -288,6 +290,11 @@ void WaveTrack::SetLastScaleType()
mLastScaleType = GetWaveformSettings().scaleType;
}
void WaveTrack::SetLastdBRange()
{
mLastdBRange = GetWaveformSettings().dBRange;
}
void WaveTrack::GetDisplayBounds(float *min, float *max)
{
*min = mDisplayMin;

View File

@ -435,6 +435,9 @@ class AUDACITY_DLL_API WaveTrack : public Track {
int GetLastScaleType() { return mLastScaleType; }
void SetLastScaleType();
int GetLastdBRange() { return mLastdBRange; }
void SetLastdBRange();
WaveTrackDisplay GetDisplay() const { return mDisplay; }
void SetDisplay(WaveTrackDisplay display) { mDisplay = display; }
@ -463,6 +466,7 @@ class AUDACITY_DLL_API WaveTrack : public Track {
float mDisplayMax;
WaveTrackDisplay mDisplay;
int mLastScaleType; // last scale type choice
int mLastdBRange;
int mDisplayNumLocations;
int mDisplayNumLocationsAllocated;
Location* mDisplayLocations;