Page 1 of 2

Macros consisting of existing Audacity shortcuts

Posted: Sun Jan 19, 2014 2:29 pm
by StevenJayCohen
Moderator Note: Moved to "Adding Features"

Over time, quite a few people have tried various ways to script Audacity.

For me, the need was Punch and Roll editing. Someone posted a way to do this with a 3rd party program in Windows, but I am on a Mac.

So, I wrote my own using AppleScript http://www.stevenjaycohen.com/2014/01/1 ... n-mac-osx/

But, I got thinking about this...

My script relies almost entirely on shortcuts already built into Audacity (see below);

Code: Select all

    keystroke "k" using {shift down} -- Select to end of VO Track
    keystroke "z" -- find Zero Crossing Cut
    keystroke "x" using {command down} -- Cut the Audio
    keystroke return -- Disarms VO Track
    keystroke "b" using {command down} -- Add Label to Label Track
    keystroke "?" -- Name Label
    keystroke return -- Saves Label
    keystroke return -- Disarms LABEL Track
    keystroke (ASCII character 30) -- Up Arrow selects EDIT Track
    keystroke return -- Arms EDIT Track
    keystroke "v" using {command down} -- Pastes to EDIT Track
    keystroke return -- Disarms EDIT Track
    keystroke (ASCII character 30) -- Up Arrow selects VO Track
    keystroke return -- Arms VO Track
    keystroke ",,,,," -- back up 5 seconds
    keystroke " " -- Start playback
    delay 5 -- wait 5 seconds until end of playback
    keystroke "a" using {shift down} -- stop Playback & set cursor 
    delay 1 -- needed or the following command does not work
    keystroke "r" using {shift down} -- Record from end of track
So, if Audacity would allow macros consisting of the following:
-Stringing built-in Audacity shortcuts together
-Access to Cut/Copy/Paste from the host operating system
-Some kind of pause/wait command

Then, people like me could write/share Macros that would work in a way similar to Chains.

What do you think?

Re: Macros consisting of existing Audacity shortcuts

Posted: Sat Jul 12, 2014 3:36 pm
by Paul L
I second the idea of easy platform neutral scripting. I am aware of the experimental Perl scripting pipe which requires one to rebuild Audacity from source. I have not tried it.

A nuisance using AutoHotKeys or AppleScript is the need to insert appropriate Sleep or delay commands to make scripts work more reliably with the discarding of typeahead during long operations. Maybe a smaller wish would be a means to turn that behavior on and off.

Re: Macros consisting of existing Audacity shortcuts

Posted: Sat Jul 12, 2014 4:11 pm
by StevenJayCohen
Thanks for the bump, Paul. Does anyone else think the ability to make a Chain of Shortcuts (Macros) is a good idea?

Re: Macros consisting of existing Audacity shortcuts

Posted: Sun Jul 13, 2014 10:08 am
by Gale Andrews
StevenJayCohen wrote:Access to Cut/Copy/Paste from the host operating system
Please explain how that differs from what happens now.

Gale

Re: Macros consisting of existing Audacity shortcuts

Posted: Sun Jul 13, 2014 12:02 pm
by Paul L
Gale Andrews wrote:
StevenJayCohen wrote:Access to Cut/Copy/Paste from the host operating system
Please explain how that differs from what happens now.

Gale
I don't understand that part either. It easy enough to send ctrl (or cmd) -c or -v. You must mean more.

Re: Macros consisting of existing Audacity shortcuts

Posted: Sun Jul 13, 2014 12:07 pm
by StevenJayCohen
In order to build a script like the one I show in the original post, not only would the "Macros" need to be able to be comprised of Audacity's own shortcuts, but they would also need to be able to send ones native to the operating system (like the Cut/Copy/Paste).

Since actual keys differ (CTRL+X on Windows and CMD + X on OSX), the "Macros" would be most useful if they included the ability to leverage things like Cut/Copy/Paste WITHOUT using platform specific key commands.

That way, scripts would run universally in Audacity without needing to be tweaked between platforms.

Re: Macros consisting of existing Audacity shortcuts

Posted: Tue Sep 23, 2014 4:43 pm
by waxcylinder
BUMP

does this need transferring to Wiki>PFR

Peter

Re: Macros consisting of existing Audacity shortcuts

Posted: Tue Sep 23, 2014 6:18 pm
by Paul L
Don't know, but I do know the developers' board has debated the right approach to scripting quite a bit, and I have not followed it closely.

Re: Macros consisting of existing Audacity shortcuts

Posted: Tue Sep 23, 2014 9:22 pm
by Gale Andrews
waxcylinder wrote:BUMP

does this need transferring to Wiki>PFR
Thanks, Peter. Yes, please transfer it. Copy across the script too. StevenJayCohen, do we have your permission to post the script on Audacity Wiki, for example on http://wiki.audacityteam.org/wiki/Scripts ?


Gale

Re: Macros consisting of existing Audacity shortcuts

Posted: Wed Sep 24, 2014 8:39 am
by waxcylinder
Thanks, I'll keep the transfer on hold until StevenJayCohen replies.

Peter