OK, took less than 15 minutes to do…
I chose Ctrl+6 and Ctrl+7 as I have so many shortcuts now that they were the first available –you could pick your own choices. I also moved the “My Amplify” to the “Effects” menu–I had stuck it under “Generate” earlier without thinking (the real version I use it in has no GUI so I needed something quick for a screen shot).
The Code
Lines I have added have the trailing comment: //efm5
Functions I have added are wrapped in comment pairs:
//efm5 start
//efm5 end
First create the new menu items in menus.cpp (a few lines of context are shown so you will know where to put the new stuff):
// Effect Menu
/////////////////////////////////////////////////////////////////////////////
c->BeginMenu(_("Effe&ct"));
c->SetDefaultFlags(AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag,
AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag);
c->AddItem(wxT("MyAmplifier"), _("My Amplifier"), FN(OnAmplify), wxT("Ctrl+8"));//efm5
c->AddItem(wxT("MyFadeIn"), _("My Fade In"), FN(OnFadeIn), wxT("Ctrl+6"));//efm5
c->AddItem(wxT("MyFadeOut"), _("My Fade Out"), FN(OnFadeOut), wxT("Ctrl+7"));//efm5
Now add the functions at the very bottom of menus.cpp:
//efm5 start
void AudacityProject::OnAmplify()
{
OnSelectAll();
OnEffect(38, 0);//index = 0 type = 38
}
//efm5 end
//efm5 start
void AudacityProject::OnFadeIn()
{
OnEffect(38, 10);//index = 10 type = 38
}
//efm5 end
//efm5 start
void AudacityProject::OnFadeOut()
{
OnEffect(38, 11);//index = 11 type = 38
}
//efm5 end
Now add the new declarations to the header file menus.h (again I include a few lines of context to show where I put the new stuff):
// Effect Menu
//efm start
void OnAmplify();
void OnFadeIn();
void OnFadeOut();
//efm end
bool OnEffect(int type, Effect * f, wxString params = wxEmptyString, bool saveState = true);
That is all there is to it. The key shortcuts show up in Preferences where you may change them:
To determine an effect’s Type & Index you set a breakpoint somewhere in the code executed by the effect a look at the call stack when the breakpoint hits:
breakPoint.png