keyboard shortcuts for Fade In/Out

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->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()
   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:

Thanks, Ed. I guess it may be an idea to move this to General Audio Programming if there are no comments/new votes for effects shortcuts after a month has passed?


Well a big +1 from me

Ed wrote this in response to a remark I made on another thread recently - I would love to have such a facility integrated into Audacity.

For those of us who use Audacity to transcribed LPs & tapes the three most common effects used are Fade-in, Fade-out and Amplify - and the Fades are the most used.

Unfortunately fo me Ed’s patch requires one to build/compile your own Audacity - and that is beyond my skill level.



I also find it frustrating that shortcuts are available for so many functions I don’t use, but that the two that I DO use frequently are not in the editable list.

I’ve added your vote for “Bind effects to buttons or keyboard shortcuts” on Wiki Feature Requests.

Don’t forget that on Windows there already is an uncustomisable keyboard sequence you can use, thanks to being able to seek by the first letter of the effect name. So:

  • Fade In : ALT - C - F - ENTER
  • Fade Out: ALT - C - F - F - ENTER

More tips on Effect Navigation: