mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-07 23:32:53 +02:00
Merge branch 'master'
This commit is contained in:
commit
2ef874f036
@ -708,6 +708,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
|
|||||||
{
|
{
|
||||||
// do a translation into the linear space
|
// do a translation into the linear space
|
||||||
wt->SetLastScaleType();
|
wt->SetLastScaleType();
|
||||||
|
wt->SetLastdBRange();
|
||||||
float sign = (min >= 0 ? 1 : -1);
|
float sign = (min >= 0 ? 1 : -1);
|
||||||
if (min != 0.) {
|
if (min != 0.) {
|
||||||
min = DB_TO_LINEAR(fabs(min) * dBRange - dBRange);
|
min = DB_TO_LINEAR(fabs(min) * dBRange - dBRange);
|
||||||
@ -742,12 +743,14 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
|
|||||||
|
|
||||||
float min, max;
|
float min, max;
|
||||||
wt->GetDisplayBounds(&min, &max);
|
wt->GetDisplayBounds(&min, &max);
|
||||||
|
float lastdBRange;
|
||||||
|
|
||||||
if (wt->GetLastScaleType() != scaleType &&
|
if (wt->GetLastScaleType() != scaleType &&
|
||||||
wt->GetLastScaleType() != -1)
|
wt->GetLastScaleType() != -1)
|
||||||
{
|
{
|
||||||
// do a translation into the dB space
|
// do a translation into the dB space
|
||||||
wt->SetLastScaleType();
|
wt->SetLastScaleType();
|
||||||
|
wt->SetLastdBRange();
|
||||||
float sign = (min >= 0 ? 1 : -1);
|
float sign = (min >= 0 ? 1 : -1);
|
||||||
if (min != 0.) {
|
if (min != 0.) {
|
||||||
min = (LINEAR_TO_DB(fabs(min)) + dBRange) / dBRange;
|
min = (LINEAR_TO_DB(fabs(min)) + dBRange) / dBRange;
|
||||||
@ -765,6 +768,30 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
|
|||||||
}
|
}
|
||||||
wt->SetDisplayBounds(min, max);
|
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) {
|
if (max > 0) {
|
||||||
int top = 0;
|
int top = 0;
|
||||||
|
@ -4713,15 +4713,20 @@ void TrackPanel::HandleWaveTrackVZoom
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Zoom out
|
// 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) {
|
if (min <= -1.0 && max >= 1.0) {
|
||||||
// Go to the maximal zoom-out
|
// Go to the maximal zoom-out
|
||||||
min = -2.0;
|
min = -top;
|
||||||
max = 2.0;
|
max = top;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// limit to +/- 1 range unless already outside that range...
|
// limit to +/- 1 range unless already outside that range...
|
||||||
float minRange = (min < -1) ? -2.0 : -1.0;
|
float minRange = (min < -1) ? -top : -1.0;
|
||||||
float maxRange = (max > 1) ? 2.0 : 1.0;
|
float maxRange = (max > 1) ? top : 1.0;
|
||||||
// and enforce vertical zoom limits.
|
// and enforce vertical zoom limits.
|
||||||
const float p1 = (zoomStart - ypos) / (float)height;
|
const float p1 = (zoomStart - ypos) / (float)height;
|
||||||
if (fixedMousePoint) {
|
if (fixedMousePoint) {
|
||||||
|
@ -109,6 +109,7 @@ WaveTrack::WaveTrack(DirManager *projDirManager, sampleFormat format, double rat
|
|||||||
mDisplayLocations = NULL;
|
mDisplayLocations = NULL;
|
||||||
mDisplayNumLocationsAllocated = 0;
|
mDisplayNumLocationsAllocated = 0;
|
||||||
mLastScaleType = -1;
|
mLastScaleType = -1;
|
||||||
|
mLastdBRange = -1;
|
||||||
mAutoSaveIdent = 0;
|
mAutoSaveIdent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ WaveTrack::WaveTrack(WaveTrack &orig):
|
|||||||
? new WaveformSettings(*orig.mpWaveformSettings) : 0)
|
? new WaveformSettings(*orig.mpWaveformSettings) : 0)
|
||||||
{
|
{
|
||||||
mLastScaleType = -1;
|
mLastScaleType = -1;
|
||||||
|
mLastdBRange = -1;
|
||||||
|
|
||||||
mLegacyProjectFileOffset = 0;
|
mLegacyProjectFileOffset = 0;
|
||||||
|
|
||||||
@ -288,6 +290,11 @@ void WaveTrack::SetLastScaleType()
|
|||||||
mLastScaleType = GetWaveformSettings().scaleType;
|
mLastScaleType = GetWaveformSettings().scaleType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaveTrack::SetLastdBRange()
|
||||||
|
{
|
||||||
|
mLastdBRange = GetWaveformSettings().dBRange;
|
||||||
|
}
|
||||||
|
|
||||||
void WaveTrack::GetDisplayBounds(float *min, float *max)
|
void WaveTrack::GetDisplayBounds(float *min, float *max)
|
||||||
{
|
{
|
||||||
*min = mDisplayMin;
|
*min = mDisplayMin;
|
||||||
|
@ -435,6 +435,9 @@ class AUDACITY_DLL_API WaveTrack : public Track {
|
|||||||
int GetLastScaleType() { return mLastScaleType; }
|
int GetLastScaleType() { return mLastScaleType; }
|
||||||
void SetLastScaleType();
|
void SetLastScaleType();
|
||||||
|
|
||||||
|
int GetLastdBRange() { return mLastdBRange; }
|
||||||
|
void SetLastdBRange();
|
||||||
|
|
||||||
WaveTrackDisplay GetDisplay() const { return mDisplay; }
|
WaveTrackDisplay GetDisplay() const { return mDisplay; }
|
||||||
void SetDisplay(WaveTrackDisplay display) { mDisplay = display; }
|
void SetDisplay(WaveTrackDisplay display) { mDisplay = display; }
|
||||||
|
|
||||||
@ -463,6 +466,7 @@ class AUDACITY_DLL_API WaveTrack : public Track {
|
|||||||
float mDisplayMax;
|
float mDisplayMax;
|
||||||
WaveTrackDisplay mDisplay;
|
WaveTrackDisplay mDisplay;
|
||||||
int mLastScaleType; // last scale type choice
|
int mLastScaleType; // last scale type choice
|
||||||
|
int mLastdBRange;
|
||||||
int mDisplayNumLocations;
|
int mDisplayNumLocations;
|
||||||
int mDisplayNumLocationsAllocated;
|
int mDisplayNumLocationsAllocated;
|
||||||
Location* mDisplayLocations;
|
Location* mDisplayLocations;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user