1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 23:33:49 +01:00

Use class NumberScale in TrackArtist and spectral selection, abstracting...

... the details of mapping to and from pixel height
This commit is contained in:
Paul Licameli
2015-06-16 12:46:55 -04:00
parent 045828d744
commit 43b7df701b
5 changed files with 173 additions and 244 deletions

View File

@@ -15,6 +15,7 @@ Paul Licameli
#include "../Audacity.h"
#include "SpectrogramSettings.h"
#include "../NumberScale.h"
#include <algorithm>
#include <wx/msgdlg.h>
@@ -23,7 +24,6 @@ Paul Licameli
#include "../Prefs.h"
#include "../RealFFTf.h"
#include <algorithm>
#include <cmath>
SpectrogramSettings::Globals::Globals()
@@ -524,6 +524,42 @@ int SpectrogramSettings::GetFFTLength(bool autocorrelation) const
;
}
NumberScale SpectrogramSettings::GetScale
(double rate, bool bins, bool autocorrelation) const
{
int minFreq, maxFreq;
NumberScaleType type = nstLinear;
// Don't assume the correspondence of the enums will remain direct in the future.
// Do this switch.
switch (scaleType) {
default:
wxASSERT(false);
case stLinear:
type = nstLinear; break;
case stLogarithmic:
type = nstLogarithmic; break;
}
switch (scaleType) {
default:
wxASSERT(false);
case stLinear:
minFreq = GetMinFreq(rate);
maxFreq = GetMaxFreq(rate);
break;
case stLogarithmic:
minFreq = GetLogMinFreq(rate);
maxFreq = GetLogMaxFreq(rate);
break;
}
const int half = GetFFTLength(autocorrelation) / 2;
return NumberScale(type, minFreq, maxFreq,
bins ? rate / (2 * half) : 1.0f);
}
bool SpectrogramSettings::SpectralSelectionEnabled() const
{
#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH