mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 07:13:49 +01:00
Bug1169: end the separate treatment of lin vs. log display bounds for spectrum...
... also make WaveTrack responsible for storing and validating the bounds ... also let the bounds vary per-track even though other settings are default ... also change some code names to mention "period" not "undertone"
This commit is contained in:
@@ -68,8 +68,6 @@ SpectrogramSettings::SpectrogramSettings()
|
||||
SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
|
||||
: minFreq(other.minFreq)
|
||||
, maxFreq(other.maxFreq)
|
||||
, logMinFreq(other.logMinFreq)
|
||||
, logMaxFreq(other.logMaxFreq)
|
||||
, range(other.range)
|
||||
, gain(other.gain)
|
||||
, frequencyGain(other.frequencyGain)
|
||||
@@ -107,8 +105,6 @@ SpectrogramSettings &SpectrogramSettings::operator= (const SpectrogramSettings &
|
||||
if (this != &other) {
|
||||
minFreq = other.minFreq;
|
||||
maxFreq = other.maxFreq;
|
||||
logMinFreq = other.logMinFreq;
|
||||
logMaxFreq = other.logMaxFreq;
|
||||
range = other.range;
|
||||
gain = other.gain;
|
||||
frequencyGain = other.frequencyGain;
|
||||
@@ -298,20 +294,6 @@ void SpectrogramSettings::LoadPrefs()
|
||||
// Enforce legal values
|
||||
Validate(true);
|
||||
|
||||
// These preferences are not written anywhere in the program as of now,
|
||||
// but I keep this legacy here. Who knows, someone might edit prefs files
|
||||
// directly. PRL
|
||||
logMinFreq = gPrefs->Read(wxT("/SpectrumLog/MinFreq"), -1);
|
||||
if (logMinFreq < 0)
|
||||
logMinFreq = minFreq;
|
||||
if (logMinFreq < 1)
|
||||
logMinFreq = 1;
|
||||
logMaxFreq = gPrefs->Read(wxT("/SpectrumLog/MaxFreq"), -1);
|
||||
if (logMaxFreq < 0)
|
||||
logMaxFreq = maxFreq;
|
||||
logMaxFreq =
|
||||
std::max(logMinFreq + 1, logMaxFreq);
|
||||
|
||||
InvalidateCaches();
|
||||
}
|
||||
|
||||
@@ -501,59 +483,6 @@ void SpectrogramSettings::ConvertToActualWindowSizes()
|
||||
#endif
|
||||
}
|
||||
|
||||
int SpectrogramSettings::GetMinFreq(double rate) const
|
||||
{
|
||||
const int top = lrint(rate / 2.);
|
||||
return std::max(0, std::min(top, minFreq));
|
||||
}
|
||||
|
||||
int SpectrogramSettings::GetMaxFreq(double rate) const
|
||||
{
|
||||
const int top = lrint(rate / 2.);
|
||||
if (maxFreq < 0)
|
||||
return top;
|
||||
else
|
||||
return std::max(0, std::min(top, maxFreq));
|
||||
}
|
||||
|
||||
int SpectrogramSettings::GetLogMinFreq(double rate) const
|
||||
{
|
||||
const int top = lrint(rate / 2.);
|
||||
if (logMinFreq < 0)
|
||||
return top / 1000.0;
|
||||
else
|
||||
return std::max(1, std::min(top, logMinFreq));
|
||||
}
|
||||
|
||||
int SpectrogramSettings::GetLogMaxFreq(double rate) const
|
||||
{
|
||||
const int top = lrint(rate / 2.);
|
||||
if (logMaxFreq < 0)
|
||||
return top;
|
||||
else
|
||||
return std::max(1, std::min(top, logMaxFreq));
|
||||
}
|
||||
|
||||
void SpectrogramSettings::SetMinFreq(int freq)
|
||||
{
|
||||
minFreq = freq;
|
||||
}
|
||||
|
||||
void SpectrogramSettings::SetMaxFreq(int freq)
|
||||
{
|
||||
maxFreq = freq;
|
||||
}
|
||||
|
||||
void SpectrogramSettings::SetLogMinFreq(int freq)
|
||||
{
|
||||
logMinFreq = freq;
|
||||
}
|
||||
|
||||
void SpectrogramSettings::SetLogMaxFreq(int freq)
|
||||
{
|
||||
logMaxFreq = freq;
|
||||
}
|
||||
|
||||
int SpectrogramSettings::GetFFTLength() const
|
||||
{
|
||||
return windowSize
|
||||
@@ -564,9 +493,8 @@ int SpectrogramSettings::GetFFTLength() const
|
||||
}
|
||||
|
||||
NumberScale SpectrogramSettings::GetScale
|
||||
(double rate, bool bins) const
|
||||
(float minFreq, float maxFreq, double rate, bool bins) const
|
||||
{
|
||||
int minFreq, maxFreq;
|
||||
NumberScaleType type = nstLinear;
|
||||
const int half = GetFFTLength() / 2;
|
||||
|
||||
@@ -585,31 +513,8 @@ NumberScale SpectrogramSettings::GetScale
|
||||
type = nstBark; break;
|
||||
case stErb:
|
||||
type = nstErb; break;
|
||||
case stUndertone:
|
||||
type = nstUndertone; break;
|
||||
}
|
||||
|
||||
switch (scaleType) {
|
||||
default:
|
||||
wxASSERT(false);
|
||||
case stLinear:
|
||||
minFreq = GetMinFreq(rate);
|
||||
maxFreq = GetMaxFreq(rate);
|
||||
break;
|
||||
case stLogarithmic:
|
||||
case stMel:
|
||||
case stBark:
|
||||
case stErb:
|
||||
minFreq = GetLogMinFreq(rate);
|
||||
maxFreq = GetLogMaxFreq(rate);
|
||||
break;
|
||||
case stUndertone:
|
||||
{
|
||||
const float bin2 = rate / half;
|
||||
minFreq = std::max(int(0.5 + bin2), GetLogMinFreq(rate));
|
||||
maxFreq = GetLogMaxFreq(rate);
|
||||
}
|
||||
break;
|
||||
case stPeriod:
|
||||
type = nstPeriod; break;
|
||||
}
|
||||
|
||||
return NumberScale(type, minFreq, maxFreq,
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
stMel,
|
||||
stBark,
|
||||
stErb,
|
||||
stUndertone,
|
||||
stPeriod,
|
||||
|
||||
stNumScaleTypes,
|
||||
};
|
||||
@@ -87,24 +87,12 @@ public:
|
||||
|
||||
// If "bins" is false, units are Hz
|
||||
NumberScale GetScale
|
||||
(double rate, bool bins) const;
|
||||
(float minFreq, float maxFreq, double rate, bool bins) const;
|
||||
|
||||
private:
|
||||
int minFreq;
|
||||
int maxFreq;
|
||||
int logMinFreq;
|
||||
int logMaxFreq;
|
||||
public:
|
||||
int GetMinFreq(double rate) const;
|
||||
int GetMaxFreq(double rate) const;
|
||||
int GetLogMinFreq(double rate) const;
|
||||
int GetLogMaxFreq(double rate) const;
|
||||
bool SpectralSelectionEnabled() const;
|
||||
|
||||
void SetMinFreq(int freq);
|
||||
void SetMaxFreq(int freq);
|
||||
void SetLogMinFreq(int freq);
|
||||
void SetLogMaxFreq(int freq);
|
||||
bool SpectralSelectionEnabled() const;
|
||||
|
||||
public:
|
||||
int range;
|
||||
|
||||
@@ -376,8 +376,12 @@ bool SpectrumPrefs::Apply()
|
||||
if (mWt) {
|
||||
if (mDefaulted) {
|
||||
mWt->SetSpectrogramSettings(NULL);
|
||||
if (partner)
|
||||
// ... and so that the vertical scale also defaults:
|
||||
mWt->SetSpectrumBounds(-1, -1);
|
||||
if (partner) {
|
||||
partner->SetSpectrogramSettings(NULL);
|
||||
partner->SetSpectrumBounds(-1, -1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SpectrogramSettings *pSettings =
|
||||
|
||||
Reference in New Issue
Block a user