WaveLab Pro Scripting

This documentation describes the objects and functions you can call in a WaveLab script. Let's start with a simple Example

Classes


Application

This class represents some aspects of the WaveLab Application. You access it with the global object application

Functions

setResponsiveUi (state)

You can set the state to 0 if you have many javascript instructions.

wait (milliseconds)

Wait a certain amount of milliseconds before continuing the script.

wait (milliseconds)

Wait until all WaveLab tasks are finished, especially background tasks like rendering.


AudioObject

This class is inherited by Wave and Montage

Observers

Functions

addMarker (type, name, comment)

Adds a marker at the cursor position. Possible marker: Marker Type

applyAudioRangePreset ()

Loads the audio range Preset and applies its setting to the audio object.

cursorPosition ()

Returns the position of the edit cursor in the audio object

findNextMarkerPosition (searchStartPos, type)

Searches for the next marker of the specified Marker Type, from a set position. Returns the marker position if any is found, or -1.

render (outputFileName)

This function renders the audio object with the currently active Preset. outputFileName is the path name to the output file.

Certain rendering procedure use an output path and not a specific file name (e.g. when rendering multiple regions). In that case, use '*' as file name.

For example:

var outputFileName = "c:/audio/temp/*"

Certain rendering procedure don't use any output file name, in that case use an empty value. a specific file name (e.g. when rendering multiple regions). In that case, use '*' as file name.

Global example:

var montage = workspace.openMontage("c:/audio/temp/piano.wav");
workspace.activateFile(montage);

montageEditor.loadRenderPreset("myPreset");

montage.render(pathToOutputFileName);

application.waitsUntilAllTasksFinished();
workspace.closeAllFilesInActiveGroup();

sampleRate ()

Returns the sample rate of the audio object

select (start, count)

Selects a number of samples, starting from a specific position.

selectionSize ()

Returns the number of selected samples.

selectionStart ()

Returns the index of the first selected sample, or -1 if there is no selection.

setCursorPosition (pos)

Sets the cursor position to a specific sample location.

size ()

Returns the number of samples of the audio object

undo ()

Undoes the last operation.


Example

//clear the log window
logWindow.clear();

//show some information about the active wave file in the log window
logWindow.printInfo("This wave file has " + activeWave.size() + " samples");
logWindow.printInfo("Its sample rate is " + activeWave.sampleRate());
logWindow.printInfo("It has " + activeWave.numChannels() + " channels");

//Work out how long the file is in seconds and round to a whole number
var lengthSecs = activeWave.size() / activeWave.sampleRate();
logWindow.printInfo("This wave file is " + lengthSecs + " seconds long");

//Select the first 10 seconds of the file
activeWave.select(0, 10 * activeWave.sampleRate());

//Trim the file to 10 seconds
activeWave.trim();

//select the first two seconds of the file and fade it in
activeWave.select(0, 2 * activeWave.sampleRate()); //sample rate multiplied by two = 2 seconds
activeWave.fadeIn(linear);

//select the last two seconds of the file and fade it out
activeWave.select(activeWave.size() - (2 * activeWave.sampleRate()), activeWave.size());
activeWave.fadeOut(linear);

//loop through 10 times and add a marker each second
for (i = 1; i <= 10; i++)
{
    //work out next cursor time
    var nextCursorPosition = i * activeWave.sampleRate();

    //set cursor position forwards by a second
    activeWave.setCursorPosition(nextCursorPosition);

    //add a generic marker at the next cursor position and give it a name and comment
    activeWave.addMarker(generic, "Marker " + i, "A comment for marker " + i);

    //write some information about the new marker
    var cursorTimeSecs = nextCursorPosition / activeWave.sampleRate();
    logWindow.printInfo("created a new marker at " + cursorTimeSecs + " seconds");
}

Fade Shape

Possible fade shapes:


Global Objects

activeMontage

Global object to access the active Audio Montage (Montage). That is, the Audio Montage being edited in the active tab. If the active tab is not an Audio Montage, the active Audio Montage is the one that was last activated, if any (and which is still opened).

Example of use:

activeMontage.deselectAllClips();

activeWave

Global object to access the active audio file (Wave). That is, the audio file being edited in the active tab. If the active tab is not an audio file, the active audio file is the one that was last activated, if any (and which is still opened).

Example of use:

activeWave.normalize("myPreset");

application

Global object to access the WaveLab Application.

masterSection

Global object to access the MasterSection.

montageEditor

Global object to access the MontageEditor

waveEditor

Global object to access the WaveEditor

workspace

Global object to access the Workspace


LogWindow

Global object representing the Log window, where you can output messages to. If the Log window is not open, all functions are ignored. There is one global object to access the Log Window: {logWindow}

clear ()

Clears the Log window. For example:

logWindow.clear();

printError (messageString)

Outputs an error message to the Log window.

printInfo (messageString)

Outputs an informal message to the Log window.The message argument must be typed as a string.For example, between inverted commas :

logWindow.printInfo("start");

printWarning (messageString)

Outputs a warning message to the Log window.


Marker Type

addMarker(type, name, comment) Adds a marker at the cursor position. Possible values for type are:

For example:

activeWave.addMarker(generic, "SomeName", "SomeComment");

MasterSection

This class represents the Master Section. You access it with the global object masterSection

Functions

loadPreset (presetName)

Loads a Master Section Preset

var wave = workspace.openWave(someFileName);
workspace.activateFile(wave);

masterSection.loadPreset("eq1");

waveEditor.loadRenderPreset("wholeFile");

wave.render("c:/audio/temp/piano.wav");

masterSection.reset();

application.waitsUntilAllTasksFinished();
workspace.closeAllFilesInActiveGroup();

reset ()

Reset the Master Section to its default state.


Montage

Inherits AudioObject

This class represents an Audio Montage, as edited in WaveLab.

You access an audio montage with activeMontage or with openMontage(fileName).

All positions and sizes are measured in sample units. If you want to specify a time range in another unit you need to convert it from samples:

Observers

Functions

bypassPlugins (state)

Bypass On/Off (1 or 0) all plug-ins used in the montage.

clipName (clipdId)

Returns the name of the clip identified by clipId.

clipPosition (clipdId)

Returns the time line position of the clip identified by clipId.

clipSize (clipdId)

Returns the sample size of the clip identified by clipId.

clipWithFile (fileName)

Returns the ID of the first clip that refers to fileName, or 0.

clipWithName (name)

Returns the ID of the first clip with name name, or 0.

clipId = activeMontage.clipWithName("testName");

deselectAllClips ()

Deselect all clips.

See also: selectClip(clipId)

firstClip ()

Outputs the ID of the first clip that refers to fileName, or 0

See also: nextClip(clipId)

Example:

id = activeMontage.firstClip();
while (id)
{
    logWindow.printInfo(activeMontage.clipName(id));
    id = activeMontage.nextClip(id);
}

insertClip (indexTrack, where, fileName, rippleMode)

Creates a clip from fileName, inserts it in track indexTrack, on the timeline at the position where, and shifts other clips to make room, according to one of the following ripple modes: * autoShiftNo * autoShiftTrack * autoShiftGlobal

This function returns the ID of first created clip, or 0

insertMonoTrack (indexWhere)

Adds a mono audio track at a given track index.

insertStereoTrack (indexWhere)

Adds a stereo audio track at a given track index.

moveClip (clipId, where)

Move the clip identified by clipId on the timeline.

nextClip (clipId)

Outputs the ID of the clip saved after 'clipId', or 0. Clips are not sorted in any special order. Using both firstClip and nextClip allows to access all audio montage clips.

See also: firstClip()

numChannels ()

Returns the number of output channels of the audio montage.

numTracks ()

Returns the number of tracks of the audio montage.

resizeClip (clipId, newSize)

Resize the clip identified by clipId on the timeline.

selectActiveClip (clipId)

Sets the clip identified by clipId as the active clip.

selectClip (clipId)

Select the clip identified by clipId. The selection status of other clips remains unchanged.

var montage = workspace.openMontage(someFileName);
workspace.activateFile(montage);

montage.deselectAllClips();
montage.selectClip(montage.clipWithName("piano"));
montage.selectClip(montage.clipWithName("guitar"));
montage.selectClip(montage.clipWithName("drum"));

montageEditor.loadRenderPreset("selectedClips");
montage.render("c:/audio/temp/*");

application.waitsUntilAllTasksFinished();
workspace.closeAllFilesInActiveGroup();

See also: deselectAllClips()

setClipDefaultFadeIn (clipId)

Sets the default fade-in shape and time for the clip identified by clipId.

setClipDefaultFadeOut (clipId)

Sets the default fade-in shape and time for the clip identified by clipId.

setClipName (clipdId, name)

Rename the clip identified by clipId.

Example:

activeMontage.setClipName(clipId, "Piano");

setSelectedTrack (index)

Sets the selected track.

setTrackName (indexTrack, name)

Rename a given track.


MontageEditor

class that represents the Audio Montage Editor. There is one global object to access the Audio File Editor: montageEditor

Functions

loadRenderPreset (presetName)

Load a Render Preset in the Audio Montage Editor.

montageEditor.loadRenderPreset("myPreset");

Preset

Many functions use a preset name as argument. For example:

activeWave.normalize("mySubFolder/myPreset");

The advantage is that you do not need to specify many parameters in your scripts, instead you can use the corresponding dialog to define the settings of a particular function, and then save them as a preset file. Because each type of preset is unique, you do not need to specify a full path name to the preset. Only specifying the preset name is enough, there is no need for its file extension. Because presets can also be saved in a subfolder, you can use a relative path name if necessary.

If the preset is a factory preset, you must specify this using the prefix %factory%/. For example:

activeWave.normalize("%factory%/EBU R-128 Recommendation")

Wave

Inherits AudioObject

This class represents an audio file, as edited in WaveLab.

You access an audio file with activeWave or with openWave(fileName).

All audio processing functions operate on the selected audio range. If there is no selection, the whole file range is processed if this option is activated in the Audio Files Preferences. If the cursor or selection is in one channel only, only that channel is processed. In other words, it operates exactly the same as if you were applying a process from within a dialog.

All positions and sizes are measured in sample units. If you want to specify a time range in another unit you need to convert it from samples:

var twoSeconds = 2 * activeWave.sampleRate();

Observers

Functions

changeLevel (decibelValue)

Changes the level of the selected audio range.

copy ()

Copies the selected audio range to the clipboard.

cut ()

Copies the selected audio range to the clipboard.

fadeIn (shape)

Applies a fade-in to the selected audio range. The shape can be one of Fade Shape.

fadeOut (shape)

Applies a fade-out to the selected audio range. The shape can be one of Fade Shape.

invertPhase ()

Inverts the phase of the samples in the audio range.

levelEnvelope (presetName)

Loads a level envelope Preset and applies its settings to an audio range.

morph (presetName)

Loads an effect morphing Preset and applies its settings to an audio range.

mute ()

Mutes the selected audio range.

normalize (presetName)

Loads a normalize level Preset and applies its settings to an audio range.

normalizeLoudness (presetName)

Loads a normalize loudness Preset and applies its settings to an audio range.

normalizePan (presetName)

Loads a normalize pan Preset and applies its settings to an audio range.

numChannels ()

Returns the number of channels of the audio file.

paste ()

Pastes audio from the clipboard to the current cursor position or audio range.

pitchBend (presetName)

Loads a pitch bend Preset and applies its settings to an audio range.

pitchCorrection (presetName)

Loads a pitch correction Preset and applies its settings to an audio range.

pitchQuantize (presetName)

Loads a pitch quantize Preset and applies its settings to an audio range.

readSamples (indexChannel, from, numSamples)

Reads a number of samples from a specific cursor position, on a set channel: * Use 0 for the left channel * Use 1 for the right channel

This returns the result in an array. For example:

buf = activeWave.readSamples(0, 20, 100); // read 100 sample from position 20, on the left channel
samples on left channel, from sample index 20
for (i = 0; i < 100; i++)
{
    logWindow.printInfo(buf[i]);
}

remove ()

Deletes the selected audio range.

removeDcOffset ()

Removes the DC offset in an audio range.

removeSoft ()

Deletes the selected audio range and crossfades the resulting regions.

reverse ()

Reverses the order of the samples in the audio range.

setCursorChannel (channel)

Sets the cursor position to a new channel. Use leftCh, rightCh, or allCh as argument.

silence (presetName)

Loads a silence Preset and applies its settings.

swapChannels ()

Swaps stereo channels.

timeStretch (presetName)

Loads a time stretch Preset and applies its settings to an audio range.

trim ()

Trims the selected audio range.


WaveEditor

class that represents the Audio File Editor. There is one global object to access the Audio File Editor: waveEditor

Functions

loadRenderPreset (presetName)

Load a Render Preset in the Audio File Editor.

waveEditor.loadRenderPreset("myPreset");

Workspace

class that represents the Workspace Window. There is one global object to access the Workspace: workspace

Functions

activateFile (fileId)

Activate the tab of the file identified by fileId

closeAllFilesInActiveGroup ()

Closes all files in the active file group.

closeFile (fileId)

Closes the file identified by fileId

openMontage (fileName)

Opens in the Workspace the Montage with the file name fileName Returns a fileId that can be used with activateFile(fileId) and closeFile(fileId)

var montage = workspace.openMontage(pathToFileName);
workspace.activateFile(montage);

openWave (fileName)

Opens in the Workspace the Wave with the file name fileName Returns a fileId that can be used with activateFile(fileId) and closeFile(fileId)

var montage = workspace.openWave(pathToFileName);
workspace.activateFile(montage);