mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Pitch is no longer a special view type... && bug fixes 1040, 1041
... It is a choice of algorithm in spectrogram settings, and any frequency scale may be chosen with it. Spectral selection works in it.
This commit is contained in:
parent
981acf0bd2
commit
adb4a534e8
@ -466,7 +466,6 @@ void TrackArtist::DrawTrack(const Track * t,
|
||||
drawEnvelope, bigPoints, drawSliders, true, muted);
|
||||
break;
|
||||
case WaveTrack::Spectrum:
|
||||
case WaveTrack::PitchDisplay:
|
||||
DrawSpectrum(wt, dc, rect, selectedRegion, zoomInfo);
|
||||
break;
|
||||
}
|
||||
@ -543,11 +542,6 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & rect)
|
||||
bev.width += 1;
|
||||
AColor::BevelTrackInfo(*dc, true, bev);
|
||||
|
||||
// Pitch doesn't have a ruler
|
||||
if (((WaveTrack *)t)->GetDisplay() == WaveTrack::PitchDisplay) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Right align the ruler
|
||||
wxRect rr = rect;
|
||||
rr.width--;
|
||||
@ -858,15 +852,12 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetLog(true);
|
||||
NumberScale scale
|
||||
(wt->GetSpectrogramSettings().GetScale(wt->GetRate(), false, false).Reversal());
|
||||
(wt->GetSpectrogramSettings().GetScale(wt->GetRate(), false).Reversal());
|
||||
vruler->SetNumberScale(&scale);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (display == WaveTrack::PitchDisplay) {
|
||||
// Pitch
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_MIDI
|
||||
@ -1966,6 +1957,8 @@ static inline float findValue
|
||||
bool autocorrelation, int gain, int range)
|
||||
{
|
||||
float value;
|
||||
|
||||
|
||||
#if 0
|
||||
// Averaging method
|
||||
if (int(bin1) == int(bin0)) {
|
||||
@ -1991,11 +1984,24 @@ static inline float findValue
|
||||
half;
|
||||
// Maximum method, and no apportionment of any single bins over multiple pixel rows
|
||||
// See Bug971
|
||||
int bin = std::min(half - 1, int(floor(0.5 + bin0)));
|
||||
const int limitBin = std::min(half, int(floor(0.5 + bin1)));
|
||||
value = spectrum[bin];
|
||||
while (++bin < limitBin)
|
||||
value = std::max(value, spectrum[bin]);
|
||||
int index, limitIndex;
|
||||
if (autocorrelation) {
|
||||
// bin = 2 * half / (half - 1 - array_index);
|
||||
// Solve for index
|
||||
index = std::max(0.0f, std::min(float(half - 1),
|
||||
(half - 1) - (2 * half) / (std::max(1.0f, bin0))
|
||||
));
|
||||
limitIndex = std::max(0.0f, std::min(float(half - 1),
|
||||
(half - 1) - (2 * half) / (std::max(1.0f, bin1))
|
||||
));
|
||||
}
|
||||
else {
|
||||
index = std::min(half - 1, int(floor(0.5 + bin0)));
|
||||
limitIndex = std::min(half, int(floor(0.5 + bin1)));
|
||||
}
|
||||
value = spectrum[index];
|
||||
while (++index < limitIndex)
|
||||
value = std::max(value, spectrum[index]);
|
||||
#endif
|
||||
if (!autocorrelation) {
|
||||
// Last step converts dB to a 0.0-1.0 range
|
||||
@ -2042,8 +2048,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
const WaveTrack *const track = waveTrackCache.GetTrack();
|
||||
const SpectrogramSettings &settings = track->GetSpectrogramSettings();
|
||||
|
||||
const int display = track->GetDisplay();
|
||||
const bool autocorrelation = (WaveTrack::PitchDisplay == display);
|
||||
const bool autocorrelation = (settings.algorithm == SpectrogramSettings::algPitchEAC);
|
||||
|
||||
enum { DASH_LENGTH = 10 /* pixels */ };
|
||||
|
||||
@ -2072,10 +2077,8 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
double freqLo = SelectedRegion::UndefinedFrequency;
|
||||
double freqHi = SelectedRegion::UndefinedFrequency;
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
if (!autocorrelation) {
|
||||
freqLo = selectedRegion.f0();
|
||||
freqHi = selectedRegion.f1();
|
||||
}
|
||||
freqLo = selectedRegion.f0();
|
||||
freqHi = selectedRegion.f1();
|
||||
#endif
|
||||
|
||||
const bool &isGrayscale = settings.isGrayscale;
|
||||
@ -2102,7 +2105,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
return;
|
||||
unsigned char *data = image->GetData();
|
||||
|
||||
const int half = settings.GetFFTLength(autocorrelation) / 2;
|
||||
const int half = settings.GetFFTLength() / 2;
|
||||
const double binUnit = rate / (2 * half);
|
||||
const float *freq = 0;
|
||||
const sampleCount *where = 0;
|
||||
@ -2122,7 +2125,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
scaleType == SpectrogramSettings::stLinear
|
||||
? settings.GetMaxFreq(rate) : settings.GetLogMaxFreq(rate);
|
||||
|
||||
const NumberScale numberScale(settings.GetScale(rate, true, autocorrelation));
|
||||
const NumberScale numberScale(settings.GetScale(rate, true));
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
const float
|
||||
|
@ -328,7 +328,6 @@ enum {
|
||||
OnWaveformID,
|
||||
OnWaveformDBID,
|
||||
OnSpectrumID,
|
||||
OnPitchID,
|
||||
OnViewSettingsID,
|
||||
|
||||
OnSplitStereoID,
|
||||
@ -368,7 +367,7 @@ BEGIN_EVENT_TABLE(TrackPanel, wxWindow)
|
||||
EVT_MENU_RANGE(OnUpOctaveID, OnDownOctaveID, TrackPanel::OnChangeOctave)
|
||||
EVT_MENU_RANGE(OnChannelLeftID, OnChannelMonoID,
|
||||
TrackPanel::OnChannelChange)
|
||||
EVT_MENU_RANGE(OnWaveformID, OnPitchID, TrackPanel::OnSetDisplay)
|
||||
EVT_MENU_RANGE(OnWaveformID, OnSpectrumID, TrackPanel::OnSetDisplay)
|
||||
EVT_MENU(OnViewSettingsID, TrackPanel::OnViewSettings)
|
||||
EVT_MENU_RANGE(OnRate8ID, OnRate384ID, TrackPanel::OnRateChange)
|
||||
EVT_MENU_RANGE(On16BitID, OnFloatID, TrackPanel::OnFormatChange)
|
||||
@ -726,7 +725,6 @@ void TrackPanel::BuildMenus(void)
|
||||
mWaveTrackMenu->Append(OnWaveformID, _("Wa&veform"));
|
||||
mWaveTrackMenu->Append(OnWaveformDBID, _("&Waveform (dB)"));
|
||||
mWaveTrackMenu->Append(OnSpectrumID, _("&Spectrum"));
|
||||
mWaveTrackMenu->Append(OnPitchID, _("Pitc&h (EAC)"));
|
||||
mWaveTrackMenu->Append(OnViewSettingsID, _("View& Settings...")); // PRL: all the other letters already taken for accelerators!
|
||||
mWaveTrackMenu->AppendSeparator();
|
||||
|
||||
@ -1726,9 +1724,7 @@ bool TrackPanel::SetCursorByActivity( )
|
||||
void TrackPanel::SetCursorAndTipWhenInLabel( Track * t,
|
||||
wxMouseEvent &event, const wxChar ** ppTip )
|
||||
{
|
||||
if (event.m_x >= GetVRulerOffset() &&
|
||||
(t->GetKind() == Track::Wave) &&
|
||||
( ((WaveTrack *) t)->GetDisplay() != WaveTrack::PitchDisplay) )
|
||||
if (event.m_x >= GetVRulerOffset() && (t->GetKind() == Track::Wave) )
|
||||
{
|
||||
*ppTip = _("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.");
|
||||
SetCursor(event.ShiftDown()? *mZoomOutCursor : *mZoomInCursor);
|
||||
@ -2984,7 +2980,7 @@ inline double findMaxRatio(double center, double rate)
|
||||
void TrackPanel::SnapCenterOnce(const WaveTrack *pTrack, bool up)
|
||||
{
|
||||
const SpectrogramSettings &settings = pTrack->GetSpectrogramSettings();
|
||||
const int windowSize = settings.GetFFTLength(false);
|
||||
const int windowSize = settings.GetFFTLength();
|
||||
const double rate = pTrack->GetRate();
|
||||
const double nyq = rate / 2.0;
|
||||
const double binFrequency = rate / windowSize;
|
||||
@ -3047,7 +3043,7 @@ void TrackPanel::StartSnappingFreqSelection (const WaveTrack *pTrack)
|
||||
// except, shrink the window as needed so we get some answers
|
||||
|
||||
const SpectrogramSettings &settings = pTrack->GetSpectrogramSettings();
|
||||
int windowSize = settings.GetFFTLength(false);
|
||||
int windowSize = settings.GetFFTLength();
|
||||
|
||||
while(windowSize > effectiveLength)
|
||||
windowSize >>= 1;
|
||||
@ -3528,7 +3524,7 @@ double TrackPanel::PositionToFrequency(const WaveTrack *wt,
|
||||
return -1;
|
||||
|
||||
const SpectrogramSettings &settings = wt->GetSpectrogramSettings();
|
||||
const NumberScale numberScale(settings.GetScale(rate, false, false));
|
||||
const NumberScale numberScale(settings.GetScale(rate, false));
|
||||
const double p = double(mouseYCoordinate - trackTopEdge) / trackHeight;
|
||||
return numberScale.PositionToValue(1.0 - p);
|
||||
}
|
||||
@ -3542,7 +3538,7 @@ wxInt64 TrackPanel::FrequencyToPosition(const WaveTrack *wt,
|
||||
const double rate = wt->GetRate();
|
||||
|
||||
const SpectrogramSettings &settings = wt->GetSpectrogramSettings();
|
||||
const NumberScale numberScale(settings.GetScale(rate, false, false));
|
||||
const NumberScale numberScale(settings.GetScale(rate, false));
|
||||
const float p = numberScale.ValueToPosition(frequency);
|
||||
return trackTopEdge + wxInt64((1.0 - p) * trackHeight);
|
||||
}
|
||||
@ -4551,9 +4547,7 @@ void TrackPanel::HandleVZoomClick( wxMouseEvent & event )
|
||||
if (!mCapturedTrack)
|
||||
return;
|
||||
|
||||
// don't do anything if track is not wave or Spectrum/log Spectrum
|
||||
if (((mCapturedTrack->GetKind() == Track::Wave) &&
|
||||
(((WaveTrack*)mCapturedTrack)->GetDisplay() != WaveTrack::PitchDisplay))
|
||||
if (mCapturedTrack->GetKind() == Track::Wave
|
||||
#ifdef USE_MIDI
|
||||
|| mCapturedTrack->GetKind() == Track::Note
|
||||
#endif
|
||||
@ -4639,7 +4633,7 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
|
||||
const double rate = track->GetRate();
|
||||
const float halfrate = rate / 2;
|
||||
const SpectrogramSettings &settings = track->GetSpectrogramSettings();
|
||||
NumberScale scale(track->GetSpectrogramSettings().GetScale(rate, false, false));
|
||||
NumberScale scale(track->GetSpectrogramSettings().GetScale(rate, false));
|
||||
const bool spectral = (track->GetDisplay() == WaveTrack::Spectrum);
|
||||
const bool spectrumLinear = spectral &&
|
||||
(track->GetSpectrogramSettings().scaleType == SpectrogramSettings::stLinear);
|
||||
@ -4653,7 +4647,7 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event )
|
||||
min = settings.GetLogMinFreq(rate);
|
||||
max = settings.GetLogMaxFreq(rate);
|
||||
}
|
||||
const int fftLength = settings.GetFFTLength(false);
|
||||
const int fftLength = settings.GetFFTLength();
|
||||
const float binSize = rate / fftLength;
|
||||
const int minBins =
|
||||
std::min(10, fftLength / 2); //minimum 10 freq bins, unless there are less
|
||||
@ -8460,7 +8454,6 @@ void TrackPanel::OnTrackMenu(Track *t)
|
||||
theMenu->Enable(OnWaveformDBID,
|
||||
display != WaveTrack::WaveformDBDisplay);
|
||||
theMenu->Enable(OnSpectrumID, display != WaveTrack::Spectrum);
|
||||
theMenu->Enable(OnPitchID, display != WaveTrack::PitchDisplay);
|
||||
theMenu->Enable(OnViewSettingsID, true);
|
||||
|
||||
WaveTrack * track = (WaveTrack *)t;
|
||||
@ -8963,7 +8956,7 @@ void TrackPanel::OnViewSettings(wxCommandEvent &)
|
||||
void TrackPanel::OnSetDisplay(wxCommandEvent & event)
|
||||
{
|
||||
int idInt = event.GetId();
|
||||
wxASSERT(idInt >= OnWaveformID && idInt <= OnPitchID);
|
||||
wxASSERT(idInt >= OnWaveformID && idInt <= OnSpectrumID);
|
||||
wxASSERT(mPopupMenuTarget
|
||||
&& mPopupMenuTarget->GetKind() == Track::Wave);
|
||||
|
||||
@ -8976,8 +8969,6 @@ void TrackPanel::OnSetDisplay(wxCommandEvent & event)
|
||||
id = WaveTrack::WaveformDBDisplay; break;
|
||||
case OnSpectrumID:
|
||||
id = WaveTrack::Spectrum; break;
|
||||
case OnPitchID:
|
||||
id = WaveTrack::PitchDisplay; break;
|
||||
}
|
||||
WaveTrack *wt = (WaveTrack *) mPopupMenuTarget;
|
||||
if (wt->GetDisplay() != id) {
|
||||
|
@ -846,7 +846,8 @@ void SpecCache::CalculateOneSpectrum
|
||||
rate, results,
|
||||
autocorrelation, settings.windowType);
|
||||
#endif // EXPERIMENTAL_USE_REALFFTF
|
||||
if (!gainFactors.empty()) {
|
||||
if (!autocorrelation &&
|
||||
!gainFactors.empty()) {
|
||||
// Apply a frequency-dependant gain factor
|
||||
for (int ii = 0; ii < half; ++ii)
|
||||
results[ii] += gainFactors[ii];
|
||||
|
@ -236,13 +236,14 @@ WaveTrack::ConvertLegacyDisplayValue(int oldValue)
|
||||
newValue = WaveTrack::WaveformDBDisplay; break;
|
||||
case Spectrogram:
|
||||
case SpectrogramLogF:
|
||||
case Pitch:
|
||||
newValue = WaveTrack::Spectrum; break;
|
||||
/*
|
||||
case SpectrogramLogF:
|
||||
newValue = WaveTrack::SpectrumLogDisplay; break;
|
||||
*/
|
||||
case Pitch:
|
||||
newValue = WaveTrack::PitchDisplay; break;
|
||||
*/
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
@ -256,13 +257,13 @@ WaveTrack::ValidateWaveTrackDisplay(WaveTrackDisplay display)
|
||||
case WaveformDisplay:
|
||||
case WaveformDBDisplay:
|
||||
case Spectrum:
|
||||
case PitchDisplay:
|
||||
return display;
|
||||
|
||||
// obsolete codes
|
||||
case obsolete1: // was SpectrumLogDisplay
|
||||
case obsolete2: // was SpectralSelectionDisplay
|
||||
case obsolete3: // was SpectralSelectionLogDisplay
|
||||
case obsolete4: // was PitchDisplay
|
||||
return Spectrum;
|
||||
|
||||
// codes out of bounds (from future prefs files?)
|
||||
|
@ -423,12 +423,11 @@ class AUDACITY_DLL_API WaveTrack: public Track {
|
||||
obsolete1, // was SpectrumLogDisplay
|
||||
obsolete2, // was SpectralSelectionDisplay
|
||||
obsolete3, // was SpectralSelectionLogDisplay
|
||||
|
||||
PitchDisplay,
|
||||
obsolete4, // was PitchDisplay
|
||||
|
||||
// Add values here, and update MaxDisplay.
|
||||
|
||||
MaxDisplay = PitchDisplay,
|
||||
MaxDisplay = Spectrum,
|
||||
|
||||
NoDisplay, // Preview track has no display
|
||||
};
|
||||
|
@ -792,7 +792,6 @@ bool NyquistEffect::ProcessOne()
|
||||
case WaveTrack::WaveformDisplay: view = wxT("\"Waveform\""); break;
|
||||
case WaveTrack::WaveformDBDisplay: view = wxT("\"Waveform (dB)\""); break;
|
||||
case WaveTrack::Spectrum: view = wxT("\"Spectrum\""); break;
|
||||
case WaveTrack::PitchDisplay: view = wxT("\"Pitch (EAC)\""); break;
|
||||
default: view = wxT("NIL"); break;
|
||||
}
|
||||
break;
|
||||
|
@ -78,6 +78,7 @@ SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
, spectralSelection(other.spectralSelection)
|
||||
#endif
|
||||
, algorithm(other.algorithm)
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
, fftYGrid(other.fftYGrid)
|
||||
#endif
|
||||
@ -114,6 +115,7 @@ SpectrogramSettings &SpectrogramSettings::operator= (const SpectrogramSettings &
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
spectralSelection = other.spectralSelection;
|
||||
#endif
|
||||
algorithm = other.algorithm;
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
fftYGrid = other.fftYGrid;
|
||||
#endif
|
||||
@ -144,12 +146,19 @@ namespace
|
||||
static wxArrayString theArray;
|
||||
return theArray;
|
||||
}
|
||||
|
||||
wxArrayString &algorithmNamesArray()
|
||||
{
|
||||
static wxArrayString theArray;
|
||||
return theArray;
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void SpectrogramSettings::InvalidateNames()
|
||||
{
|
||||
scaleNamesArray().Clear();
|
||||
algorithmNamesArray().Clear();
|
||||
}
|
||||
|
||||
//static
|
||||
@ -170,6 +179,20 @@ const wxArrayString &SpectrogramSettings::GetScaleNames()
|
||||
return theArray;
|
||||
}
|
||||
|
||||
//static
|
||||
const wxArrayString &SpectrogramSettings::GetAlgorithmNames()
|
||||
{
|
||||
wxArrayString &theArray = algorithmNamesArray();
|
||||
|
||||
if (theArray.IsEmpty()) {
|
||||
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
|
||||
theArray.Add(_("STFT"));
|
||||
theArray.Add(_("Pitch (enhanced autocorrelation)"));
|
||||
}
|
||||
|
||||
return theArray;
|
||||
}
|
||||
|
||||
bool SpectrogramSettings::Validate(bool quiet)
|
||||
{
|
||||
if (!quiet &&
|
||||
@ -227,6 +250,9 @@ bool SpectrogramSettings::Validate(bool quiet)
|
||||
ScaleType(std::max(0,
|
||||
std::min(int(SpectrogramSettings::stNumScaleTypes) - 1,
|
||||
int(scaleType))));
|
||||
algorithm = Algorithm(
|
||||
std::max(0, std::min(int(algNumAlgorithms) - 1, int(algorithm)))
|
||||
);
|
||||
ConvertToEnumeratedWindowSizes();
|
||||
ConvertToActualWindowSizes();
|
||||
|
||||
@ -259,6 +285,8 @@ void SpectrogramSettings::LoadPrefs()
|
||||
spectralSelection = (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
|
||||
#endif
|
||||
|
||||
algorithm = Algorithm(gPrefs->Read(wxT("/Spectrum/Algorithm"), 0L));
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
@ -319,6 +347,8 @@ void SpectrogramSettings::SavePrefs()
|
||||
gPrefs->Write(wxT("/Spectrum/EnableSpectralSelection"), spectralSelection);
|
||||
#endif
|
||||
|
||||
gPrefs->Write(wxT("/Spectrum/Algorithm"), algorithm);
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
gPrefs->Write(wxT("/Spectrum/FFTYGrid"), fftYGrid);
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
@ -519,21 +549,21 @@ void SpectrogramSettings::SetLogMaxFreq(int freq)
|
||||
logMaxFreq = freq;
|
||||
}
|
||||
|
||||
int SpectrogramSettings::GetFFTLength(bool autocorrelation) const
|
||||
int SpectrogramSettings::GetFFTLength() const
|
||||
{
|
||||
return windowSize
|
||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||
* (!autocorrelation ? zeroPaddingFactor : 1);
|
||||
* ((algorithm == algSTFT) ? zeroPaddingFactor : 1);
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
NumberScale SpectrogramSettings::GetScale
|
||||
(double rate, bool bins, bool autocorrelation) const
|
||||
(double rate, bool bins) const
|
||||
{
|
||||
int minFreq, maxFreq;
|
||||
NumberScaleType type = nstLinear;
|
||||
const int half = GetFFTLength(autocorrelation) / 2;
|
||||
const int half = GetFFTLength() / 2;
|
||||
|
||||
// Don't assume the correspondence of the enums will remain direct in the future.
|
||||
// Do this switch.
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
|
||||
static void InvalidateNames(); // in case of language change
|
||||
static const wxArrayString &GetScaleNames();
|
||||
static const wxArrayString &GetAlgorithmNames();
|
||||
|
||||
static SpectrogramSettings &defaults();
|
||||
SpectrogramSettings();
|
||||
@ -87,7 +88,7 @@ public:
|
||||
|
||||
// If "bins" is false, units are Hz
|
||||
NumberScale SpectrogramSettings::GetScale
|
||||
(double rate, bool bins, bool autocorrelation) const;
|
||||
(double rate, bool bins) const;
|
||||
|
||||
private:
|
||||
int minFreq;
|
||||
@ -117,7 +118,7 @@ public:
|
||||
int zeroPaddingFactor;
|
||||
#endif
|
||||
|
||||
int GetFFTLength(bool autocorrelation) const; // window size (times zero padding, if STFT)
|
||||
int GetFFTLength() const; // window size (times zero padding, if STFT)
|
||||
|
||||
bool isGrayscale;
|
||||
|
||||
@ -127,6 +128,14 @@ public:
|
||||
bool spectralSelection; // But should this vary per track? -- PRL
|
||||
#endif
|
||||
|
||||
enum Algorithm {
|
||||
algSTFT = 0,
|
||||
algPitchEAC,
|
||||
|
||||
algNumAlgorithms,
|
||||
};
|
||||
Algorithm algorithm;
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
bool fftYGrid;
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
|
@ -60,6 +60,7 @@ enum {
|
||||
ID_WINDOW_TYPE,
|
||||
ID_PADDING_SIZE,
|
||||
ID_SCALE,
|
||||
ID_ALGORITHM,
|
||||
ID_MINIMUM,
|
||||
ID_MAXIMUM,
|
||||
ID_GAIN,
|
||||
@ -97,6 +98,8 @@ void SpectrumPrefs::Populate(int windowSize)
|
||||
|
||||
mScaleChoices = SpectrogramSettings::GetScaleNames();
|
||||
|
||||
mAlgorithmChoices = SpectrogramSettings::GetAlgorithmNames();
|
||||
|
||||
//------------------------- Main section --------------------
|
||||
// Now construct the GUI itself.
|
||||
ShuttleGui S(this, eIsCreating);
|
||||
@ -171,6 +174,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.SetSizeHints(mTypeChoices);
|
||||
|
||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||
mZeroPaddingChoiceCtrl =
|
||||
S.Id(ID_PADDING_SIZE).TieChoice(_("&Zero padding factor") + wxString(wxT(":")),
|
||||
mTempSettings.zeroPaddingFactor,
|
||||
&mZeroPaddingChoices);
|
||||
@ -189,6 +193,11 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
*(int*)&mTempSettings.scaleType,
|
||||
&mScaleChoices);
|
||||
|
||||
mAlgorithmChoice =
|
||||
S.Id(ID_ALGORITHM).TieChoice(_("Algorithm") + wxString(wxT(":")),
|
||||
*(int*)&mTempSettings.algorithm,
|
||||
&mAlgorithmChoices);
|
||||
|
||||
mMinFreq =
|
||||
S.Id(ID_MINIMUM).TieNumericTextBox(_("Mi&nimum Frequency (Hz):"),
|
||||
mTempSettings.minFreq,
|
||||
@ -275,6 +284,8 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
}
|
||||
S.EndMultiColumn();
|
||||
|
||||
EnableDisableSTFTOnlyControls();
|
||||
|
||||
mPopulating = false;
|
||||
}
|
||||
|
||||
@ -428,6 +439,24 @@ void SpectrumPrefs::OnDefaults(wxCommandEvent &)
|
||||
}
|
||||
}
|
||||
|
||||
void SpectrumPrefs::OnAlgorithm(wxCommandEvent &evt)
|
||||
{
|
||||
EnableDisableSTFTOnlyControls();
|
||||
OnControl(evt);
|
||||
}
|
||||
|
||||
void SpectrumPrefs::EnableDisableSTFTOnlyControls()
|
||||
{
|
||||
// Enable or disable other controls that are applicable only to STFT.
|
||||
const bool STFT = (mAlgorithmChoice->GetSelection() == 0);
|
||||
mGain->Enable(STFT);
|
||||
mRange->Enable(STFT);
|
||||
mFrequencyGain->Enable(STFT);
|
||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||
mZeroPaddingChoiceCtrl->Enable(STFT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpectrumPrefs::OnApply(wxCommandEvent &)
|
||||
{
|
||||
if (Validate()) {
|
||||
@ -439,6 +468,7 @@ void SpectrumPrefs::OnApply(wxCommandEvent &)
|
||||
BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
||||
EVT_CHOICE(ID_WINDOW_SIZE, SpectrumPrefs::OnWindowSize)
|
||||
EVT_CHECKBOX(ID_DEFAULTS, SpectrumPrefs::OnDefaults)
|
||||
EVT_CHOICE(ID_ALGORITHM, SpectrumPrefs::OnAlgorithm)
|
||||
|
||||
// Several controls with common routine that unchecks the default box
|
||||
EVT_CHOICE(ID_WINDOW_TYPE, SpectrumPrefs::OnControl)
|
||||
|
@ -54,9 +54,12 @@ class SpectrumPrefs:public PrefsPanel
|
||||
void OnControl(wxCommandEvent &event);
|
||||
void OnWindowSize(wxCommandEvent &event);
|
||||
void OnDefaults(wxCommandEvent&);
|
||||
void OnAlgorithm(wxCommandEvent &);
|
||||
void OnApply(wxCommandEvent &);
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
void EnableDisableSTFTOnlyControls();
|
||||
|
||||
WaveTrack *const mWt;
|
||||
bool mDefaulted;
|
||||
|
||||
@ -70,12 +73,16 @@ class SpectrumPrefs:public PrefsPanel
|
||||
|
||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||
int mZeroPaddingChoice;
|
||||
wxChoice *mZeroPaddingChoiceCtrl;
|
||||
wxArrayString mZeroPaddingChoices;
|
||||
#endif
|
||||
|
||||
wxArrayString mTypeChoices;
|
||||
wxArrayString mScaleChoices;
|
||||
|
||||
wxChoice *mAlgorithmChoice;
|
||||
wxArrayString mAlgorithmChoices;
|
||||
|
||||
|
||||
#ifdef EXPERIMENTAL_FIND_NOTES
|
||||
wxTextCtrl *mFindNotesMinA;
|
||||
@ -98,5 +105,4 @@ public:
|
||||
private:
|
||||
WaveTrack *const mWt;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -68,9 +68,6 @@ void TracksPrefs::Populate()
|
||||
mViewChoices.Add(_("Spectrum"));
|
||||
mViewCodes.Add(WaveTrack::Spectrum);
|
||||
|
||||
mViewChoices.Add(_("Pitch (EAC)"));
|
||||
mViewCodes.Add(int(WaveTrack::PitchDisplay));
|
||||
|
||||
//------------------------- Main section --------------------
|
||||
// Now construct the GUI itself.
|
||||
// Use 'eIsCreatingFromPrefs' so that the GUI is
|
||||
|
Loading…
x
Reference in New Issue
Block a user