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 #ifdef EXPERIMENTAL_FIND_NOTES
const bool &fftFindNotes = settings.fftFindNotes; const bool &fftFindNotes = settings.fftFindNotes;
const bool &findNotesMinA = settings.findNotesMinA; const double &findNotesMinA = settings.findNotesMinA;
const bool &numberOfMaxima = settings.numberOfMaxima; const int &numberOfMaxima = settings.numberOfMaxima;
const bool &findNotesQuantize = settings.findNotesQuantize; const bool &findNotesQuantize = settings.findNotesQuantize;
#endif #endif
#ifdef EXPERIMENTAL_FFT_Y_GRID #ifdef EXPERIMENTAL_FFT_Y_GRID
@ -2267,6 +2267,8 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
#endif #endif
#ifdef EXPERIMENTAL_FIND_NOTES #ifdef EXPERIMENTAL_FIND_NOTES
float log2 = logf( 2.0f ),
lmin = logf( minFreq ), lmax = logf( maxFreq ), scale = lmax - lmin,
lmins = lmin, lmins = lmin,
lmaxs = lmax lmaxs = lmax
; ;
@ -2290,20 +2292,9 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int xx = 0; xx < hiddenMid.width; ++xx) { 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 #ifdef EXPERIMENTAL_FIND_NOTES
int maximas = 0; int maximas = 0;
const int x0 = half * x; const int x0 = half * xx;
if (fftFindNotes) { if (fftFindNotes) {
for (int i = maxTableSize - 1; i >= 0; i--) for (int i = maxTableSize - 1; i >= 0; i--)
indexes[i] = -1; indexes[i] = -1;
@ -2361,11 +2352,21 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
maxima1[i] = f2pix(f1); maxima1[i] = f2pix(f1);
} }
} }
int it = 0; int it = 0;
int oldBin0 = -1;
bool inMaximum = false; bool inMaximum = false;
#endif //EXPERIMENTAL_FIND_NOTES #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; float value;
#ifdef EXPERIMENTAL_FIND_NOTES #ifdef EXPERIMENTAL_FIND_NOTES

View File

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

View File

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

View File

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