1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 00:50:52 +02:00

Spectral Selection Toggle (using q key) by Paul Licameli.

This commit is contained in:
james.k.crook@gmail.com 2014-11-29 16:53:28 +00:00
parent 4ed7396b24
commit 2131568876
4 changed files with 34 additions and 5 deletions

View File

@ -574,7 +574,7 @@ void AudacityProject::CreateMenusAndCommands()
c->AddItem(wxT("SelectNone"), _("&None"), FN(OnSelectNone), wxT("Ctrl+Shift+A"));
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
c->AddItem(wxT("DefaultFrequencySelection"), _("Select all fre&quencies"), FN(OnDefaultFrequencySelection), wxT("Q"));
c->AddItem(wxT("ToggleSpectralSelection"), _("To&ggle spectral selection"), FN(OnToggleSpectralSelection), wxT("Q"));
#endif
c->AddItem(wxT("SetLeftSelection"), _("&Left at Playback Position"), FN(OnSetLeftSelection), wxT("["));
@ -4715,10 +4715,9 @@ void AudacityProject::OnSelectNone()
}
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
void AudacityProject::OnDefaultFrequencySelection()
void AudacityProject::OnToggleSpectralSelection()
{
mViewInfo.selectedRegion.setFrequencies
(SelectedRegion::UndefinedFrequency, SelectedRegion::UndefinedFrequency);
mTrackPanel->ToggleSpectralSelection();
mTrackPanel->Refresh(false);
ModifyState(false);
}

View File

@ -242,7 +242,7 @@ void OnDisjoinLabels();
void OnSelectAll();
void OnSelectNone();
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
void OnDefaultFrequencySelection();
void OnToggleSpectralSelection();
#endif
void OnSelectCursorEnd();
void OnSelectStartCursor();

View File

@ -578,6 +578,8 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
mFreqSelMode = FREQ_SEL_INVALID;
mFrequencySnapper.reset(new SpectrumAnalyst());
mLastF0 = mLastF1 = SelectedRegion::UndefinedFrequency;
#endif
}
@ -2698,6 +2700,25 @@ void TrackPanel::ExtendFreqSelection(int mouseYCoordinate, int trackTopEdge,
}
}
void TrackPanel::ToggleSpectralSelection()
{
SelectedRegion &region = mViewInfo->selectedRegion;
const double f0 = region.f0();
const double f1 = region.f1();
const bool haveSpectralSelection =
!(f0 == SelectedRegion::UndefinedFrequency &&
f1 == SelectedRegion::UndefinedFrequency);
if (haveSpectralSelection)
{
mLastF0 = f0;
mLastF1 = f1;
region.setFrequencies
(SelectedRegion::UndefinedFrequency, SelectedRegion::UndefinedFrequency);
}
else
region.setFrequencies(mLastF0, mLastF1);
}
void TrackPanel::ResetFreqSelectionPin(double hintFrequency, bool logF)
{
switch (mFreqSelMode) {

View File

@ -582,6 +582,15 @@ protected:
double mFreqSelPin;
const WaveTrack *mFreqSelTrack;
std::auto_ptr<SpectrumAnalyst> mFrequencySnapper;
// For toggling of spectral seletion
double mLastF0;
double mLastF1;
public:
void ToggleSpectralSelection();
protected:
#endif
Track *mCapturedTrack;