---
layout: post
title: Punch and Roll editing in Audacity on Mac OSX
author: Steven
date: 2014-01-19 12:47:42
categories: 
- Musings
tags: 
- audacity
- audio
- daw
- os x
- software
- voiceover
featured_image: https://www.stevenjaycohen.com/wp-content/uploads/2016/07/wsi-imageoptim-audacity-template-1.png
---
Even after using almost every advanced DAW (Digital Audio Workstation) out there, I still have a soft spot in my heart for Audacity.

It's a wonderful piece of open source software that can handle an incredible number of common audio editing tasks. One reason that people sometimes leave Audacity for commercial software (like ProTools - video below) is Audacity's lack of Punch and Roll Editing.

http://vimeo.com/38259466

As a way of giving back to the Audacity Community, I put together an AppleScript that simulates Punch and Roll.
tell application "Audacity"
  activate
  tell application "System Events"
    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
  end tell
end tell
When activated, this script automatically cuts the audio from the cursor to the end of the VO track, places a Label at the edit point, pastes the audio to the EDIT track (in case you need it later), pre-rolls 5 seconds of your recorded audio, then starts recording again.

If you improve upon this script, let me know so I can include your changes here.

This is as close to non-destructive Punch and Roll editing that you can get in Audacity. Since the script relies mostly on shortcuts built into Audacity, it should be easy to port to other operating systems (like Linux or Windows).

This script above assumes that you have 2 Audio tracks and a Label track set up in your Audacity Project (see below). Feel free to download my VO Project Template for Audacity.



To use this script on OSX, either paste it into AppleScript Editor and save it as a program, or use Automator to Create a ServiceĀ (pictured below).



The advantage of using a Service is that you can assign it a Keyboard Shortcut in System Preferences (see below).



Once you've tried it, let me know what you think :)

[coffee]