Play region around cursor

I am trying to figure out how to do this: play, say, 350 msec before and after the cursor position (and then stop). Is there a command or could I make a macro to do it? Thanks!
[Windows 10/Audacity 3.1.3]

By default, pressing “C” (Play Cut Preview) will play 2 seconds before the selection and one second after.
You can change how much is played before and after in Playback Preferences:

True, but I want to play around the cursor not around a selection that could be elsewhere. And Play Cut Preview doesn’t work when the selection is “zero length” (it doesn’t interpret the cursor as a zero length selection). No, my reason for wanting to do this is, for example, I could be zoomed in making a small edit and want to hear what it sounds like in context without having to zoom out, select a section, and play that.


If there’s no time selection, then either Ctrl+Shift+F5 or Ctrl+Shift+F7 will do what you want.
Note that these shortcuts are available in the full set of default shortcuts - see top of that page.
These commands share the before and after periods with cut preview, and these can be set in the playback category of preferences.

Fascinating David - a great tip :sunglasses:

Those shortcuts of Are for the commands:

  1. Play Before and after Selection Start
  2. Play Before and after Selection End

Given that the standard shortcuts are
a) only in the non-default Full set of shortcuts
b) a multi-key operation (on my HP Probook it’s 4 keys as the function keys double-up usage abd require “fn” to operate
you may want to set a simpler custom shortcut (as it sounds like you will be using this often).

If it were me I’d appropriate and re-use the “B” shortcut - which currently is:
Play to Selection: Plays to or from the current mouse pointer position to or from the start or end of the selection, depending on the pointer position.

See this section in the Manual re custom shortcuts:


Hooray, that works, thanks David! And thanks for the whole list of commands. But there’s one very useful action I don’t see there: would it be possible to set a keyboard shortcut for switching between waveform and spectrogram view?

I tweaked the alpha manual for the upcoming 3.2.0 release to note that these commands work on a point selection (as well as a range):


Create a macro containing the command:


Give the macro a suitable name, such as “Spectrogram View”,
Then create a shortcut to the macro.


OOH - that’s jolly clever Steve :ugeek: :sunglasses:

I’m guessing the user would need a second macro and second shortcut to rever to waveform view - as I’m guessing this is not a toggle?

And is the a command for setting Multi-view?


“Set Track Visuals” (Extra Menu: Scriptables I - Audacity Manual) has three options for “Display”: Waveform, Spectrogram or Multi-view.

The manual (and alpha manual) are out of date and only mention Waveform or Spectrogram, (even in the Reference section:, but when you open the “Set track Visuals” interface you will see that all three options are available.

If you want a keyboard shortcut, then yes.
Personally I find it easier to right click with the mouse on the panel on the left end of the track and select the required option from the context menu.

OK - so I updated the alpha Manual to add the Multi-view option:

BUT when I try the command (from the menus not via scripting) I get no change in the display type - it stays resolutely waveform. Is this a bug that needs logging?


Maybe you forgot to enable the “Display” option (tick the checkbox)

Yepper - that’s it …

Another dumb user bites the dust - but it’s not exactly obvious :unamused:


Create a macro containing the command …

Great! What would be the command to make it so that every time the view switches to spectrogram, the zoom level is set to 500ths of a second? I’m a bit surprised that horizontal zoom levels aren’t part of the SetTrackVisuals menu, only vertical.

Agreed, but it is documented, and it is consistent across many of the “Extra” commands:

Many of these commands have optional values.

  • Where the dialog shows a checkbox with no label, leaving the box unticked leaves the corresponding value unchanged.

Probably easiest to set your “Zoom Toggle” appropriately (in Tracks Preferences - Audacity Manual), and add the “ZoomToggle:” command to the macro.
The reference list of available macro commands is here: Scripting Reference - Audacity Manual

OK, but, I am already using the zoom toggle for something else useful.

A brute-force way to do it would be to zoom in enough times that you’re sure to hit the maximum wherever you started from, then zoom out the correct number of times, but c’mon, that’s ridiculous.

Not so “obvious” or “discoverable” when you approach it from the paradigm of setting preferences methinks …

That’s certainly why I fell into that little bear-trap :confused: