
4.9 Scripting 63
tasks such as trimming and cropping a file at specific times, for example. You can write
scripts that perform other basic editing commands, apply offline processing, place markers,
and display information about the active file. You can script commands to edit the active
Audio File or the active Audio Montage. If you have some experience of programming with
modern scripting languages you should have no problem writing utility scripts for WaveLab.
The WaveLab Scripting language is based on ECMAScript, with the addition of WaveLab
specific commands. If you have had any experience with Javascript, Jscript or Actionscript
the code syntax will be familiar to you as they are all based on ECMAScript too. If not, there
is a large amount of teaching and reference material available online. A Javascript reference
such as www.w3schools.com for example, or a book like JavaScript: The Definitive
Guide are good places to start.
To begin exploring the WaveLab specific functions available see WaveLab Scripting Lan-
guage. For a broader look at the complete subset of commands available see ECMAScript
Reference.
Getting started
To write and execute a script:
1. Open the Script window in either the Audio File or Audio Montage Workspaces.
2. Type your script directly in the Script window or copy and paste it from an external text
editor.
3. Run the script by clicking Execute Script or selecting it from the Functions menu.
The script will run if there are no syntax errors. Any errors will appear in a dialog box to help
you debug them.
Tip: There are several free utility text editors that are context sensitive. This means that they
can color and highlight parts of your code to make it more readable. If you use one of these
for writing and editing your scripts, choose Javascript as the editing language and/or save
the file with a .js (Javascript) extension.
Using the Log window
It is a good idea to begin by writing some simple scripts that output some text to the Log
window. The Log window is part of the Control Window and can be accessed via Utilities
> Log. To output a simple text message:
1. Open the Log window.
2. Open an Audio File in the Audio File Workspace.
3. Copy and paste the following script into the Script window and try executing it.
//output the number of samples in the active wave as text in the log window.
logWindow.printInfo("This file has " + activeWave.size() + " samples");
Note: Any lines of a script that begin with two forward slashes // are comments, and are
ignored when the script is executed. For commenting multiple lines you can use the following
syntax:
/* This a long comment,
that wraps onto more than one line. */
WaveLab 7
Comentários a estes Manuais