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