1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-04 17:49:45 +02:00

Throw away EXPERIMENTAL_FFT_SKIP_POINTS...

... with James' consent.
This commit is contained in:
Paul Licameli 2015-06-13 09:16:32 -04:00
parent 78d0347be2
commit b25994a82d
7 changed files with 1 additions and 153 deletions

View File

@ -86,10 +86,6 @@
// to activate it instead of the Spectrum log(f) mode. // to activate it instead of the Spectrum log(f) mode.
//#define EXPERIMENTAL_FIND_NOTES //#define EXPERIMENTAL_FIND_NOTES
// AM, 22.Nov 2007
// Skip Points support in the spectrum view mode.
//#define EXPERIMENTAL_FFT_SKIP_POINTS
// AM, 22.Nov 2007: // AM, 22.Nov 2007:
// A Frequency Grid for the Spectrum Log(f) & Find Notes modes // A Frequency Grid for the Spectrum Log(f) & Find Notes modes
//#define EXPERIMENTAL_FFT_Y_GRID //#define EXPERIMENTAL_FFT_Y_GRID

View File

@ -665,10 +665,6 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r)
void TrackArtist::UpdateVRuler(Track *t, wxRect & r) void TrackArtist::UpdateVRuler(Track *t, wxRect & r)
{ {
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
const int fftSkipPoints = SpectrogramSettings::defaults().fftSkipPoints;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
// Label tracks do not have a vruler // Label tracks do not have a vruler
if (t->GetKind() == Track::Label) { if (t->GetKind() == Track::Label) {
return; return;
@ -807,16 +803,10 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r)
int freq = lrint(rate/2.); int freq = lrint(rate/2.);
int maxFreq = GetSpectrumMaxFreq(freq); int maxFreq = GetSpectrumMaxFreq(freq);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
maxFreq/=(fftSkipPoints+1);
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
if(maxFreq > freq) if(maxFreq > freq)
maxFreq = freq; maxFreq = freq;
int minFreq = GetSpectrumMinFreq(0); int minFreq = GetSpectrumMinFreq(0);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
minFreq/=(fftSkipPoints+1);
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
if(minFreq < 0) if(minFreq < 0)
minFreq = 0; minFreq = 0;
@ -853,16 +843,10 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r)
int freq = lrint(rate/2.); int freq = lrint(rate/2.);
int maxFreq = GetSpectrumLogMaxFreq(freq); int maxFreq = GetSpectrumLogMaxFreq(freq);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
maxFreq/=(fftSkipPoints+1);
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
if(maxFreq > freq) if(maxFreq > freq)
maxFreq = freq; maxFreq = freq;
int minFreq = GetSpectrumLogMinFreq(freq/1000.0); int minFreq = GetSpectrumLogMinFreq(freq/1000.0);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
minFreq/=(fftSkipPoints+1);
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
if(minFreq < 1) if(minFreq < 1)
minFreq = 1; minFreq = 1;
@ -1964,11 +1948,6 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache,
bool updated = clip->GetSpectrogram(cache, freq, where, mid.width, bool updated = clip->GetSpectrogram(cache, freq, where, mid.width,
t0, pps, autocorrelation); t0, pps, autocorrelation);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int fftSkipPoints = SpectrogramSettings::defaults().fftSkipPoints;
int fftSkipPoints1 = fftSkipPoints + 1;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
int ifreq = lrint(rate/2); int ifreq = lrint(rate/2);
int maxFreq; int maxFreq;
@ -2057,14 +2036,8 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache,
#endif #endif
#ifdef EXPERIMENTAL_FIND_NOTES #ifdef EXPERIMENTAL_FIND_NOTES
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
const float
lmins = logf(float(minFreq) / (fftSkipPoints + 1)),
lmaxs = logf(float(maxFreq) / (fftSkipPoints + 1))
#else //!EXPERIMENTAL_FFT_SKIP_POINTS
lmins = lmin, lmins = lmin,
lmaxs = lmax lmaxs = lmax
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
; ;
#endif //EXPERIMENTAL_FIND_NOTES #endif //EXPERIMENTAL_FIND_NOTES
@ -2072,11 +2045,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache,
int maxima[128]; int maxima[128];
float maxima0[128], maxima1[128]; float maxima0[128], maxima1[128];
const float const float
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
f2bin = half / (rate / 2.0f / (fftSkipPoints + 1)),
#else //!EXPERIMENTAL_FFT_SKIP_POINTS
f2bin = half / (rate / 2.0f), f2bin = half / (rate / 2.0f),
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
bin2f = 1.0f / f2bin, bin2f = 1.0f / f2bin,
minDistance = powf(2.0f, 2.0f / 12.0f), minDistance = powf(2.0f, 2.0f / 12.0f),
i0 = expf(lmin) / binUnit, i0 = expf(lmin) / binUnit,
@ -3086,13 +3055,6 @@ int TrackArtist::GetSpectrumWindowSize(bool includeZeroPadding)
return windowSize; return windowSize;
} }
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int TrackArtist::GetSpectrumFftSkipPoints()
{
return SpectrogramSettings::defaults().fftSkipPoints;
}
#endif
// Set various preference values // Set various preference values
void TrackArtist::SetSpectrumMinFreq(int freq) void TrackArtist::SetSpectrumMinFreq(int freq)
{ {

View File

@ -76,10 +76,6 @@ class AUDACITY_DLL_API TrackArtist {
int GetSpectrumLogMaxFreq(int deffreq); int GetSpectrumLogMaxFreq(int deffreq);
int GetSpectrumWindowSize(bool includeZeroPadding); int GetSpectrumWindowSize(bool includeZeroPadding);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int GetSpectrumFftSkipPoints();
#endif
void SetSpectrumMinFreq(int freq); void SetSpectrumMinFreq(int freq);
void SetSpectrumMaxFreq(int freq); void SetSpectrumMaxFreq(int freq);
void SetSpectrumLogMinFreq(int freq); void SetSpectrumLogMinFreq(int freq);

View File

@ -4714,9 +4714,6 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
float min, max, c, l, binSize = 0.0; float min, max, c, l, binSize = 0.0;
bool spectrum, spectrumLog; bool spectrum, spectrumLog;
int windowSize; int windowSize;
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int fftSkipPoints=0;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
double rate = ((WaveTrack *)track)->GetRate(); double rate = ((WaveTrack *)track)->GetRate();
spectrum = (((WaveTrack *) track)->GetDisplay() == WaveTrack::SpectrumDisplay) || spectrum = (((WaveTrack *) track)->GetDisplay() == WaveTrack::SpectrumDisplay) ||
(((WaveTrack *) track)->GetDisplay() == WaveTrack::SpectralSelectionDisplay) ; (((WaveTrack *) track)->GetDisplay() == WaveTrack::SpectralSelectionDisplay) ;
@ -4733,9 +4730,6 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
// Always spectrogram, never pitch view, pass true // Always spectrogram, never pitch view, pass true
windowSize = mTrackArtist->GetSpectrumWindowSize(true); windowSize = mTrackArtist->GetSpectrumWindowSize(true);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
fftSkipPoints = SpectrogramSettings::defaults().fftSkipPoints;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
binSize = rate / windowSize; binSize = rate / windowSize;
minBins = wxMin(10, windowSize/2); //minimum 10 freq bins, unless there are less minBins = wxMin(10, windowSize/2); //minimum 10 freq bins, unless there are less
} }
@ -4750,9 +4744,6 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
// Always spectrogram, never pitch view, pass true // Always spectrogram, never pitch view, pass true
windowSize = mTrackArtist->GetSpectrumWindowSize(true); windowSize = mTrackArtist->GetSpectrumWindowSize(true);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
fftSkipPoints = SpectrogramSettings::defaults().fftSkipPoints;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
binSize = rate / windowSize; binSize = rate / windowSize;
minBins = wxMin(10, windowSize/2); //minimum 10 freq bins, unless there are less minBins = wxMin(10, windowSize/2); //minimum 10 freq bins, unless there are less
} }

View File

@ -276,9 +276,6 @@ public:
, windowSize(-1) , windowSize(-1)
, zeroPaddingFactor(-1) , zeroPaddingFactor(-1)
, frequencyGain(-1) , frequencyGain(-1)
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
, fftSkipPoints(-1)
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
, freq(NULL) , freq(NULL)
, where(NULL) , where(NULL)
@ -291,9 +288,6 @@ public:
SpecCache(int cacheLen, bool autocorrelation, SpecCache(int cacheLen, bool autocorrelation,
double pps_, double start_, int windowType_, int windowSize_, double pps_, double start_, int windowType_, int windowSize_,
int zeroPaddingFactor_, int frequencyGain_ int zeroPaddingFactor_, int frequencyGain_
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
, int fftSkipPoints_
#endif
) )
: len(cacheLen) : len(cacheLen)
, ac(autocorrelation) , ac(autocorrelation)
@ -303,9 +297,6 @@ public:
, windowSize(windowSize_) , windowSize(windowSize_)
, zeroPaddingFactor(zeroPaddingFactor_) , zeroPaddingFactor(zeroPaddingFactor_)
, frequencyGain(frequencyGain_) , frequencyGain(frequencyGain_)
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
, fftSkipPoints(fftSkipPoints_)
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
// len columns, and so many rows, column-major. // len columns, and so many rows, column-major.
// Don't take column literally -- this isn't pixel data yet, it's the // Don't take column literally -- this isn't pixel data yet, it's the
@ -350,9 +341,6 @@ public:
const int windowSize; const int windowSize;
const int zeroPaddingFactor; const int zeroPaddingFactor;
const int frequencyGain; const int frequencyGain;
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
const int fftSkipPoints;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
std::vector<float> freq; std::vector<float> freq;
std::vector<sampleCount> where; std::vector<sampleCount> where;
@ -833,9 +821,6 @@ bool SpecCache::Matches
windowSize == settings.windowSize && windowSize == settings.windowSize &&
zeroPaddingFactor == settings.zeroPaddingFactor && zeroPaddingFactor == settings.zeroPaddingFactor &&
frequencyGain == settings.frequencyGain && frequencyGain == settings.frequencyGain &&
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
fftSkipPoints == settings.fftSkipPoints &&
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
ac == autocorrelation; ac == autocorrelation;
} }
@ -847,11 +832,6 @@ void SpecCache::CalculateOneSpectrum
bool autocorrelation, const std::vector<float> &gainFactors, bool autocorrelation, const std::vector<float> &gainFactors,
float *scratch) float *scratch)
{ {
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int fftSkipPoints = settings.fftSkipPoints;
int fftSkipPoints1 = fftSkipPoints + 1;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
const int windowSize = settings.windowSize; const int windowSize = settings.windowSize;
sampleCount start = where[xx]; sampleCount start = where[xx];
const int zeroPaddingFactor = (autocorrelation ? 1 : settings.zeroPaddingFactor); const int zeroPaddingFactor = (autocorrelation ? 1 : settings.zeroPaddingFactor);
@ -881,15 +861,6 @@ void SpecCache::CalculateOneSpectrum
start = 0; start = 0;
copy = true; copy = true;
} }
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
copy = true;
if (start + len*fftSkipPoints1 > numSamples) {
int newlen = (numSamples - start) / fftSkipPoints1;
for (int i = newlen*fftSkipPoints1; i < (sampleCount)len*fftSkipPoints1; i++)
adj[i] = 0;
len = newlen;
}
#else //!EXPERIMENTAL_FFT_SKIP_POINTS
if (start + len > numSamples) { if (start + len > numSamples) {
// Near the end of the clip, pad right with zeroes as needed. // Near the end of the clip, pad right with zeroes as needed.
int newlen = numSamples - start; int newlen = numSamples - start;
@ -898,28 +869,13 @@ void SpecCache::CalculateOneSpectrum
len = newlen; len = newlen;
copy = true; copy = true;
} }
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
if (len > 0) { if (len > 0) {
// Copy samples out of the track. // Copy samples out of the track.
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
useBuffer = (float*)(waveTrackCache.Get(floatSample,
floor(0.5 + start + offset * rate), len*fftSkipPoints1));
memcpy(adj, useBuffer, len * fftSkipPoints1 * sizeof(float));
if (fftSkipPoints) {
// TODO: (maybe) alternatively change Get to include skipping of points
int j = 0;
for (int i = 0; i < len; i++) {
adj[i] = adj[j];
j += fftSkipPoints1;
}
}
#else //!EXPERIMENTAL_FFT_SKIP_POINTS
useBuffer = (float*)(waveTrackCache.Get(floatSample, useBuffer = (float*)(waveTrackCache.Get(floatSample,
floor(0.5 + start + offset * rate), len)); floor(0.5 + start + offset * rate), len));
if (copy) if (copy)
memcpy(adj, useBuffer, len * sizeof(float)); memcpy(adj, useBuffer, len * sizeof(float));
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
} }
if (copy) if (copy)
@ -961,11 +917,6 @@ void SpecCache::Populate
settings.CacheWindows(); settings.CacheWindows();
#endif #endif
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int fftSkipPoints = settings.fftSkipPoints;
int fftSkipPoints1 = fftSkipPoints + 1;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
const int &frequencyGain = settings.frequencyGain; const int &frequencyGain = settings.frequencyGain;
const int &windowSize = settings.windowSize; const int &windowSize = settings.windowSize;
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS #ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
@ -979,11 +930,7 @@ void SpecCache::Populate
const int fftLen = windowSize * zeroPaddingFactor; const int fftLen = windowSize * zeroPaddingFactor;
std::vector<float> buffer( std::vector<float> buffer(
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
fftLen*fftSkipPoints1
#else //!EXPERIMENTAL_FFT_SKIP_POINTS
fftLen fftLen
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
); );
std::vector<float> gainFactors; std::vector<float> gainFactors;
@ -1009,10 +956,6 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
{ {
const SpectrogramSettings &settings = SpectrogramSettings::defaults(); const SpectrogramSettings &settings = SpectrogramSettings::defaults();
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int fftSkipPoints = settings.fftSkipPoints;
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
const int &frequencyGain = settings.frequencyGain; const int &frequencyGain = settings.frequencyGain;
const int &windowSize = settings.windowSize; const int &windowSize = settings.windowSize;
const int &windowType = settings.windowType; const int &windowType = settings.windowType;
@ -1070,9 +1013,6 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
mSpecCache = new SpecCache( mSpecCache = new SpecCache(
numPixels, autocorrelation, pixelsPerSecond, t0, numPixels, autocorrelation, pixelsPerSecond, t0,
windowType, windowSize, zeroPaddingFactor, frequencyGain windowType, windowSize, zeroPaddingFactor, frequencyGain
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
, fftSkipPoints
#endif
); );
fillWhere(mSpecCache->where, numPixels, 0.5, correction, fillWhere(mSpecCache->where, numPixels, 0.5, correction,

View File

@ -164,35 +164,6 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
} }
S.EndStatic(); S.EndStatic();
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
// Search and replace with _ if you want translation.
#define TRANSLATABLE( x ) wxT(x)
wxArrayString wskipn;
wxArrayInt wskipv;
for (size_t i = 0; i < 7; i++) {
wskipn.Add(wxString::Format(wxT("%d"), (1 << i) - 1));
wskipv.Add((1 << i) - 1);
}
/* /////i18n-hint: (noun) Experimental. Don't know what it does. Don't translate.*/
S.StartStatic(TRANSLATABLE("FFT Skip Points"));
{
S.StartMultiColumn(2);
{
/* /////i18n-hint: (noun) here the user chooses points to skip.*/
S.TieChoice(TRANSLATABLE("Skip Points:"),
wxT("/Spectrum/FFTSkipPoints"),
0,
wskipn,
wskipv);
S.SetSizeHints(wskipn);
}
S.EndMultiColumn();
}
S.EndStatic();
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
S.StartStatic(_("Display")); S.StartStatic(_("Display"));
{ {
S.StartTwoColumn(); S.StartTwoColumn();
@ -430,10 +401,6 @@ void SpectrogramSettings::UpdatePrefs()
isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0); isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
fftSkipPoints = gPrefs->Read(wxT("/Spectrum/FFTSkipPoints"), 0L);
#endif
#ifdef EXPERIMENTAL_FFT_Y_GRID #ifdef EXPERIMENTAL_FFT_Y_GRID
fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0); fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
#endif //EXPERIMENTAL_FFT_Y_GRID #endif //EXPERIMENTAL_FFT_Y_GRID

View File

@ -103,10 +103,6 @@ public:
bool isGrayscale; bool isGrayscale;
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
int fftSkipPoints;
#endif
#ifdef EXPERIMENTAL_FFT_Y_GRID #ifdef EXPERIMENTAL_FFT_Y_GRID
bool fftYGrid; bool fftYGrid;
#endif //EXPERIMENTAL_FFT_Y_GRID #endif //EXPERIMENTAL_FFT_Y_GRID