mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-19 09:30:06 +02:00
Bug 521 - Lower half of Waveform (dB) vertical scale does not show dB level.
Added a DbMirrorValue for two sided dB scale on Waveform VRuler when in dB view mode.
This commit is contained in:
parent
37541de6be
commit
8ce8e7bcce
@ -702,6 +702,7 @@ void TrackArtist::UpdateVRuler(const Track *t, wxRect & rect)
|
|||||||
min = tt->GetRangeLower() * 100.0;
|
min = tt->GetRangeLower() * 100.0;
|
||||||
max = tt->GetRangeUpper() * 100.0;
|
max = tt->GetRangeUpper() * 100.0;
|
||||||
|
|
||||||
|
vruler->SetDbMirrorValue( 0.0 );
|
||||||
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height-1);
|
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height-1);
|
||||||
vruler->SetOrientation(wxVERTICAL);
|
vruler->SetOrientation(wxVERTICAL);
|
||||||
vruler->SetRange(max, min);
|
vruler->SetRange(max, min);
|
||||||
@ -753,6 +754,7 @@ void TrackArtist::UpdateVRuler(const Track *t, wxRect & rect)
|
|||||||
wt->SetDisplayBounds(min, max);
|
wt->SetDisplayBounds(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vruler->SetDbMirrorValue( 0.0 );
|
||||||
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
|
vruler->SetBounds(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
|
||||||
vruler->SetOrientation(wxVERTICAL);
|
vruler->SetOrientation(wxVERTICAL);
|
||||||
vruler->SetRange(max, min);
|
vruler->SetRange(max, min);
|
||||||
@ -792,13 +794,17 @@ void TrackArtist::UpdateVRuler(const Track *t, wxRect & rect)
|
|||||||
max = 0.0;
|
max = 0.0;
|
||||||
max *= sign;
|
max *= sign;
|
||||||
}
|
}
|
||||||
wt->SetDisplayBounds(min, max);
|
wt->SetDisplayBounds(min, max );
|
||||||
}
|
}
|
||||||
else if (dBRange != (lastdBRange = wt->GetLastdBRange())) {
|
else if (dBRange != (lastdBRange = wt->GetLastdBRange())) {
|
||||||
wt->SetLastdBRange();
|
wt->SetLastdBRange();
|
||||||
// Remap the max of the scale
|
// Remap the max of the scale
|
||||||
const float sign = (max >= 0 ? 1 : -1);
|
const float sign = (max >= 0 ? 1 : -1);
|
||||||
float newMax = max;
|
float newMax = max;
|
||||||
|
|
||||||
|
// This commented out code is problematic.
|
||||||
|
// min and max may be correct, and this code cause them to change.
|
||||||
|
#ifdef ONLY_LABEL_POSITIVE
|
||||||
if (max != 0.) {
|
if (max != 0.) {
|
||||||
|
|
||||||
// Ugh, duplicating from TrackPanel.cpp
|
// Ugh, duplicating from TrackPanel.cpp
|
||||||
@ -815,16 +821,24 @@ void TrackArtist::UpdateVRuler(const Track *t, wxRect & rect)
|
|||||||
if (min != 0.)
|
if (min != 0.)
|
||||||
min = std::max(-extreme, newMax * min / max);
|
min = std::max(-extreme, newMax * min / max);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
wt->SetDisplayBounds(min, newMax);
|
wt->SetDisplayBounds(min, newMax );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Old code was if ONLY_LABEL_POSITIVE were defined.
|
||||||
|
// it uses the +1 to 0 range only.
|
||||||
|
// the enabled code uses +1 to -1, and relies on set ticks labelling knowing about
|
||||||
|
// the dB scale.
|
||||||
|
#ifdef ONLY_LABEL_POSITIVE
|
||||||
if (max > 0) {
|
if (max > 0) {
|
||||||
|
#endif
|
||||||
int top = 0;
|
int top = 0;
|
||||||
float topval = 0;
|
float topval = 0;
|
||||||
int bot = rect.height;
|
int bot = rect.height;
|
||||||
float botval = -dBRange;
|
float botval = -dBRange;
|
||||||
|
|
||||||
|
#ifdef ONLY_LABEL_POSITIVE
|
||||||
if (min < 0) {
|
if (min < 0) {
|
||||||
bot = top + (int)((max / (max - min))*(bot - top));
|
bot = top + (int)((max / (max - min))*(bot - top));
|
||||||
min = 0;
|
min = 0;
|
||||||
@ -841,13 +855,19 @@ void TrackArtist::UpdateVRuler(const Track *t, wxRect & rect)
|
|||||||
if (min > 0) {
|
if (min > 0) {
|
||||||
botval = -((1 - min) * dBRange);
|
botval = -((1 - min) * dBRange);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
topval = -((1 - max) * dBRange);
|
||||||
|
botval = -((1 - min) * dBRange);
|
||||||
|
vruler->SetDbMirrorValue( dBRange );
|
||||||
|
#endif
|
||||||
vruler->SetBounds(rect.x, rect.y + top, rect.x + rect.width, rect.y + bot - 1);
|
vruler->SetBounds(rect.x, rect.y + top, rect.x + rect.width, rect.y + bot - 1);
|
||||||
vruler->SetOrientation(wxVERTICAL);
|
vruler->SetOrientation(wxVERTICAL);
|
||||||
vruler->SetRange(topval, botval);
|
vruler->SetRange(topval, botval);
|
||||||
|
#ifdef ONLY_LABEL_POSITIVE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vruler->SetBounds(0.0, 0.0, 0.0, 0.0); // A.C.H I couldn't find a way to just disable it?
|
vruler->SetBounds(0.0, 0.0, 0.0, 0.0); // A.C.H I couldn't find a way to just disable it?
|
||||||
|
#endif
|
||||||
vruler->SetFormat(Ruler::RealLogFormat);
|
vruler->SetFormat(Ruler::RealLogFormat);
|
||||||
vruler->SetLabelEdges(true);
|
vruler->SetLabelEdges(true);
|
||||||
vruler->SetLog(false);
|
vruler->SetLog(false);
|
||||||
@ -858,6 +878,7 @@ void TrackArtist::UpdateVRuler(const Track *t, wxRect & rect)
|
|||||||
const SpectrogramSettings &settings = wt->GetSpectrogramSettings();
|
const SpectrogramSettings &settings = wt->GetSpectrogramSettings();
|
||||||
float minFreq, maxFreq;
|
float minFreq, maxFreq;
|
||||||
wt->GetSpectrumBounds(&minFreq, &maxFreq);
|
wt->GetSpectrumBounds(&minFreq, &maxFreq);
|
||||||
|
vruler->SetDbMirrorValue( 0.0 );
|
||||||
|
|
||||||
switch (settings.scaleType) {
|
switch (settings.scaleType) {
|
||||||
default:
|
default:
|
||||||
|
@ -139,6 +139,7 @@ Ruler::Ruler()
|
|||||||
mbTicksAtExtremes = false;
|
mbTicksAtExtremes = false;
|
||||||
mTickColour = wxColour( theTheme.Colour( clrTrackPanelText ));
|
mTickColour = wxColour( theTheme.Colour( clrTrackPanelText ));
|
||||||
mPen.SetColour(mTickColour);
|
mPen.SetColour(mTickColour);
|
||||||
|
mDbMirrorValue = 0.0;
|
||||||
|
|
||||||
// Note: the font size is now adjusted automatically whenever
|
// Note: the font size is now adjusted automatically whenever
|
||||||
// Invalidate is called on a horizontal Ruler, unless the user
|
// Invalidate is called on a horizontal Ruler, unless the user
|
||||||
@ -768,7 +769,7 @@ void Ruler::Tick(int pos, double d, bool major, bool minor)
|
|||||||
wxCoord strW, strH, strD, strL;
|
wxCoord strW, strH, strD, strL;
|
||||||
int strPos, strLen, strLeft, strTop;
|
int strPos, strLen, strLeft, strTop;
|
||||||
|
|
||||||
// FIXME: We don't draw a tick if of end of our label arrays
|
// FIXME: We don't draw a tick if off end of our label arrays
|
||||||
// But we shouldn't have an array of labels.
|
// But we shouldn't have an array of labels.
|
||||||
if( mNumMinorMinor >= mLength )
|
if( mNumMinorMinor >= mLength )
|
||||||
return;
|
return;
|
||||||
@ -792,6 +793,9 @@ void Ruler::Tick(int pos, double d, bool major, bool minor)
|
|||||||
label->text = wxT("");
|
label->text = wxT("");
|
||||||
|
|
||||||
mDC->SetFont(major? *mMajorFont: minor? *mMinorFont : *mMinorMinorFont);
|
mDC->SetFont(major? *mMajorFont: minor? *mMinorFont : *mMinorMinorFont);
|
||||||
|
// Bug 521. dB view for waveforms needs a 2-sided scale.
|
||||||
|
if(( mDbMirrorValue > 1.0 ) && ( -d > mDbMirrorValue ))
|
||||||
|
d = -2*mDbMirrorValue - d;
|
||||||
l = LabelString(d, major);
|
l = LabelString(d, major);
|
||||||
mDC->GetTextExtent(l, &strW, &strH, &strD, &strL);
|
mDC->GetTextExtent(l, &strW, &strH, &strD, &strL);
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ class AUDACITY_DLL_API Ruler {
|
|||||||
// Specify the name of the units (like "dB") if you
|
// Specify the name of the units (like "dB") if you
|
||||||
// want numbers like "1.6" formatted as "1.6 dB".
|
// want numbers like "1.6" formatted as "1.6 dB".
|
||||||
void SetUnits(const wxString &units);
|
void SetUnits(const wxString &units);
|
||||||
|
void SetDbMirrorValue( const double d ){ mDbMirrorValue = d ; };
|
||||||
|
|
||||||
// Logarithmic
|
// Logarithmic
|
||||||
void SetLog(bool log);
|
void SetLog(bool log);
|
||||||
@ -223,6 +224,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
int mOrientation;
|
int mOrientation;
|
||||||
int mSpacing;
|
int mSpacing;
|
||||||
|
double mDbMirrorValue;
|
||||||
bool mHasSetSpacing;
|
bool mHasSetSpacing;
|
||||||
bool mLabelEdges;
|
bool mLabelEdges;
|
||||||
RulerFormat mFormat;
|
RulerFormat mFormat;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user