1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-23 15:41:09 +02:00

Make EXPERIMENTAL_FIND_NOTES work again

This commit is contained in:
Paul Licameli 2017-02-12 10:13:23 -05:00
parent dbb2f04def
commit 463e7d971d
4 changed files with 78 additions and 77 deletions

View File

@ -2155,8 +2155,8 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
#ifdef EXPERIMENTAL_FIND_NOTES
const bool &fftFindNotes = settings.fftFindNotes;
const bool &findNotesMinA = settings.findNotesMinA;
const bool &numberOfMaxima = settings.numberOfMaxima;
const double &findNotesMinA = settings.findNotesMinA;
const int &numberOfMaxima = settings.numberOfMaxima;
const bool &findNotesQuantize = settings.findNotesQuantize;
#endif
#ifdef EXPERIMENTAL_FFT_Y_GRID
@ -2267,6 +2267,8 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
#endif
#ifdef EXPERIMENTAL_FIND_NOTES
float log2 = logf( 2.0f ),
lmin = logf( minFreq ), lmax = logf( maxFreq ), scale = lmax - lmin,
lmins = lmin,
lmaxs = lmax
;
@ -2290,20 +2292,9 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
#pragma omp parallel for
#endif
for (int xx = 0; xx < hiddenMid.width; ++xx) {
for (int yy = 0; yy < hiddenMid.height; ++yy) {
const float bin = bins[yy];
const float nextBin = bins[yy+1];
if (settings.scaleType != SpectrogramSettings::stLogarithmic) {
const float value = findValue
(freq + half * xx, bin, nextBin, half, autocorrelation, gain, range);
clip->mSpecPxCache->values[xx * hiddenMid.height + yy] = value;
}
else {
// Do we need this legacy experiment still?
#ifdef EXPERIMENTAL_FIND_NOTES
int maximas = 0;
const int x0 = half * x;
const int x0 = half * xx;
if (fftFindNotes) {
for (int i = maxTableSize - 1; i >= 0; i--)
indexes[i] = -1;
@ -2361,11 +2352,21 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
maxima1[i] = f2pix(f1);
}
}
int it = 0;
int oldBin0 = -1;
bool inMaximum = false;
#endif //EXPERIMENTAL_FIND_NOTES
for (int yy = 0; yy < hiddenMid.height; ++yy) {
const float bin = bins[yy];
const float nextBin = bins[yy+1];
if (settings.scaleType != SpectrogramSettings::stLogarithmic) {
const float value = findValue
(freq + half * xx, bin, nextBin, half, autocorrelation, gain, range);
clip->mSpecPxCache->values[xx * hiddenMid.height + yy] = value;
}
else {
float value;
#ifdef EXPERIMENTAL_FIND_NOTES

View File

@ -138,8 +138,8 @@ public:
#ifdef EXPERIMENTAL_FIND_NOTES
bool fftFindNotes;
bool findNotesMinA;
bool numberOfMaxima;
double findNotesMinA;
int numberOfMaxima;
bool findNotesQuantize;
#endif //EXPERIMENTAL_FIND_NOTES

View File

@ -107,7 +107,7 @@ void SpectrumPrefs::Populate(size_t windowSize)
//------------------------- Main section --------------------
// Now construct the GUI itself.
ShuttleGui S(this, eIsCreating);
ShuttleGui S(this, eIsCreatingFromPrefs);
PopulateOrExchange(S);
// ----------------------- End of main section --------------
}
@ -265,18 +265,18 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
{
mFindNotesMinA =
S.TieNumericTextBox(_("Minimum Amplitude (dB):"),
mTempSettings.fftFindNotes,
mTempSettings.findNotesMinA,
8);
mFindNotesN =
S.TieNumericTextBox(_("Max. Number of Notes (1..128):"),
mTempSettings.findNotesMinA,
mTempSettings.numberOfMaxima,
8);
}
S.EndTwoColumn();
S.TieCheckBox(_("&Find Notes"),
mTempSettings.numberOfMaxima);
mTempSettings.fftFindNotes);
S.TieCheckBox(_("&Quantize Notes"),
mTempSettings.findNotesQuantize);
@ -353,7 +353,7 @@ bool SpectrumPrefs::Validate()
}
#endif //EXPERIMENTAL_FIND_NOTES
ShuttleGui S(this, eIsGettingFromDialog);
ShuttleGui S(this, eIsSavingToPrefs);
PopulateOrExchange(S);
// Delegate range checking to SpectrogramSettings class
@ -376,7 +376,7 @@ bool SpectrumPrefs::Apply()
static_cast<WaveTrack*>(mWt->GetLink())
: nullptr;
ShuttleGui S(this, eIsGettingFromDialog);
ShuttleGui S(this, eIsSavingToPrefs);
PopulateOrExchange(S);

View File

@ -64,7 +64,7 @@ void WaveformPrefs::Populate()
//------------------------- Main section --------------------
// Now construct the GUI itself.
ShuttleGui S(this, eIsCreating);
ShuttleGui S(this, eIsCreatingFromPrefs);
PopulateOrExchange(S);
// ----------------------- End of main section --------------
}