A recent feature request for Audacity was for the provision of key bindings to zoom in / out vertically on a track. This feature is already available in a limited fashion from the “Set Track Visuals” macro command.
The first step is to create a macro and add the command “Set Track Visuals”. Enable the options “VZoom Top” and “VZoom Bottom”. The numeric values for these two settings are the top / bottom of the track on a scale of +/-1 (normal track height). Thus to zoom in by a factor of 2, centred around the track’s centre line, VZoom Top should be set to 0.5, and VZoom Bottom to -0.5.
The maximum top to bottom range is +2.0 to -2.0. This limit is set internally by Audacity.
After saving the macro, a custom keyboard shortcut may be added in the usual way.
A more flexible solution
While the above is simple and effective, if you want several different zoom levels, the number of keys required for keyboard access increases rapidly. A better solution would be to have one key binding for zooming in, which may be pressed repeatedly to zoom in more, and another key to zoom out (repeatedly if necessary).
To this end I wrote a couple of Nyquist Macros; one to handle zooming in and another to handle zooming out. After installing and enabling the plug-ins, they will appear as “VZoom-In” and “VZoom-Out” in the “Tools” menu. Keyboard shortcuts may be added in the usual way.
What should the behaviour be if more than one track is selected?
Zooming vertically on multiple tracks at the same time is problematic since the track’s initial zoom state may differ. The scripting command for zooming vertically applies to all selected tracks and applies the same absolute zoom level to each track. These factors can lead to unexpected / unhelpful results when applied to multiple tracks, so I decided to retain Audacity’s standard behaviour of zooming vertically on one track at a time only.
When the plug-in runs, the focused track has to be selected and all other selected tracks must be deselected, so the plug-in also restores the original track selection(s) after performing the zoom action.
The first time these plug-ins run, they may be a little slow, after which it should be very much quicker. This is caused by Nyqust updating its command cache. The cache needs to be updated when Audacity has been updated, so this minor inconvenience will not occur very often.
If multiple tracks are selected, Audacity always returns focus to the first (topmost) selected track, regardless of which track had focus originally. This will usually not be a problem as typically you would select the track that you want to zoom and apply the effect. In this case, focus is returned to the selected track as expected.
These plug-ins were written for Audacity 2.4.2 or later. (They “may” work with slightly older versions, but this is untested and not recommended). The current version of Audacity at time of writing is Audacity 3.4.2.