Steinberg WaveLab 7 Operation Manual
Have a look at the manual Steinberg WaveLab 7 Operation Manual online for free. It’s possible to download the document as PDF or print. UserManuals.tech offer 523 Steinberg manuals and user’s guides for free. Share the user manual or guide on Facebook, Twitter or Google+.
4.9 Scripting 67 addMarker(type, name, comment) - Add a marker at the cursor position. Possible values for type are: ˆ generic ˆ temporary ˆ cdTrackStart ˆ cdTrackEnd ˆ cdTrackFrontier ˆ cdTrackIndex ˆ loopStart ˆ loopEnd ˆ muteStart ˆ muteEnd ˆ playbackStarter ˆ regionStart ˆ regionEnd ˆ errorStart ˆ errorEnd ˆ correctionStart ˆ correctionEnd Example: activeWave.addMarker(generic, "SomeName", "SomeComment"); findNextMarkerPosition(posStartSearch, type) - Searches for the next marker oftype, from a given position. Returns the marker position, if any is found, or -1. normalize(presetName) - Loads the normalizer preset and applies its setting to an audio range. normalizeLoudness(presetName) - Loads the loudness normalizer preset and applies its setting to an audio range. normalizePan(presetName) - Loads the pan normalizer preset and applies its setting to an audio range. silence(presetName) - Loads the silence preset and applies its setting to an audio range. timeStretch(presetName) - Loads the time stretch preset and applies its setting to an audio range. pitchCorrection(presetName) - Loads the pitch correction preset and applies its setting to an audio range. pitchQuantize(presetName) - Loads the pitch quantize preset and applies its setting to an audio range. WaveLab 7
68 WaveLab Concepts changeLevel(dbValue) - Changes the level of the selected audio range. fadeIn(shape) and fadeOut(shape) - Applies a fade on the selected audio range. shape can be one of the following: ˆ linear ˆ sinus ˆ squareRoot ˆ sinusoid ˆ log ˆ exp ˆ expp Example: activeWave.fadeIn(squareRoot); levelEnvelope(presetName) - Loads the envelope shape and applies its setting to an audio range. morph(presetName) - Loads an effect morphing preset and applies it according to its settings. invertPhase() - Inverts the phase of the samples in the audio range. reverse() - Reverses the order of the samples in the audio range. cut() - Cuts the selected audio range. copy() - Copies the selected audio range. paste() - Pastes audio from the clipboard to the current cursor position. trim() - Trims the selected audio range. remove() - Deletes the selected audio range. removeSmooth() - Deletes the selected audio range and cross fades the resulting regions together. mute() - Mutes the selected audio range. swapChannels() - Swaps stereo channels. undo() - Undoes the last command. removeDcOffset() - Removes the DC offset in the audio range. readSamples(channelIndex, from, numSamples) - Reads a number of samples from a given cursor position, on a given channel: ˆ Use 0 for the leftchannel ˆ Use 1 for the rightchannel Returns the result in an array. Example: WaveLab 7
4.9 Scripting 69 buf = activeWave.readSamples(0, 20, 100); // read 100 samples on left channel, fr om sample index 20 for (i = 0; i < 100; i++) { logWindow.printInfo(buf[i]); } Audio Montage Scripting Commands Functions Preliminary info: the Scripting API is an open project and will evolve according to user re- quests. size() - Returns the number of samples in the Audio Montage. sampleRate() - Returns the sample rate of the Audio Montage. numChannels() - Returns the number of output channels of the Audio Montage. numTracks() - Returns the number of tracks of the Audio Montage. cursorPosition() - Returns the current cursor position (in samples). setCursorPosition(pos) - Sets the current cursor position at a certain sample location. selectionStart() - Returns the index of the first selected sample, or -1 if there is no selection. selectionSize() - Returns the number of selected samples. select(presetName) - Loads the audio range preset and applies its setting to the active Audio Montage. select(start, size) - Selects a number of samples, starting from a given position. setFocusedTrack(index) - Sets the focused track. addMarker(type, name, comment) - Add a marker at the cursor position. Possible values for type are: ˆ generic ˆ temporary ˆ cdTrackStart ˆ cdTrackEnd ˆ cdTrackFrontier ˆ cdTrackIndex ˆ loopStart ˆ loopEnd ˆ muteStart ˆ muteEnd ˆ playbackStarter ˆ regionStart WaveLab 7
70 WaveLab Concepts ˆ regionEnd ˆ errorStart ˆ errorEnd ˆ correctionStart ˆ correctionEnd Example: activeWave.addMarker(generic, "SomeName", "SomeComment"); findNextMarkerPosition(posStartSearch, type) - Searches for the next marker oftype, from a given position. Returns the marker position, if any is found, or -1. insertMonoTrack(where) - Adds a Mono Audio Track at index 'where' insertStereoTrack(where) - Adds a Stereo Audio Track at index 'where' insertClip(iTrack, timePosition, fileName, autoShift) - Creates a Clip from 'fileName', inserts it in track 'iTrack', on the time line at posision 'timePosition', add possibly shift other Clips to make room according to parameter 'autoShift' autoShiftcan be one of the following: ˆ autoShiftNo ˆ autoShiftTrack ˆ autoShiftGlobal This function returns the ID of first created Clip, or 0. clipWithName(name) - Returns the ID of first Clip with name 'name', or 0. clipWithFile(name) - Returns the ID of first Clip that refers to 'fileName', or 0. firstClip() - Returns the first Montage Clip ID, or 0, if the Montage is empty. nextClip(clipId) - Returns the ID of the Clip stored after 'clipId', or 0. Clips are not sorted in any special order. Using both firstClip and nextClip allow to access all Montage Clips. clipName(clipId) - Returns the name of the Clip identified by 'clipId' clipPosition(clipId) - Returns the time line position of the Clip identified by 'clipId' clipSize(clipId) - Returns the size of the Clip identified by 'clipId' setClipName(clipId, name) - Rename the Clip identified by 'clipId' setTrackName(index, name) - Rename the Track identified by 'index' moveClip(clipId, newPos) - Move on the time line the Clip identified by 'clipId' resizeClip(clipId, qlonglong newSize) - Resize the Clip identified by 'clipId'. The size will be limited by the Audio File referenced by the Clip. setClipDefaultFadeIn(clipId) - Sets the default fade-in shape and time for the Clip iden- tified by 'clipId' setClipDefaultFadeOut(clipId) - Sets the default fade-out shape and time for the Clip identified by 'clipId' undo() - Undoes the last command. WaveLab 7
4.9 Scripting 71 Related topics ECMAScript Reference 4.9.2 ECMAScript Reference WaveLab's scripting language is based on the ECMAScript scripting language, as defined in standard ECMA-262 Microsoft's JScript, Netscape's JavaScript and Adobe's Actionscript are also based on the ECMAScript standard. If you are not familiar with the ECMAScript language, there is a large amount of teaching and reference material available online. This reference page contains a list of all ECMAScript objects, functions and properties sup- ported by the WaveLab scripting system. These are available in any scripting context but are not WaveLab specific. When scripting for the Audio File Workspace for example, (using the Scripting window (Audio File Workspace) ) there are specific additional functions that allow you to perform editing commands. For a list of these WaveLab specific scripting commands and functions see WaveLab Scripting Language . Tip: Some basic scripting examples are included below so you can see the scripting syntax in context. These scripts will work if you copy, paste and execute them in a script window. Supported ECMAScript subset The Global Object Values ˆ NaN ˆ Infinity ˆ undefined ˆ Math Functions ˆ eval(x) ˆ parseInt(string, radix) ˆ parseFloat(string) ˆ isNaN(number) ˆ isFinite(number) ˆ decodeURI(encodedURI) ˆ decodeURIComponent(encodedURIComponent) ˆ encodeURI(uri) ˆ encodeURIComponent(uriComponent) WaveLab 7
72 WaveLab Concepts Objects ˆ Object ˆ Function ˆ Array ˆ String ˆ Boolean ˆ Number ˆ Date ˆ RegExp ˆ Error Examples: //Test if a value is not a number var isNumber = isNaN("this is a string"); //Print the result in the log window logWindow.printInfo(isNumber); //Traces "true" because it is a String //Convert a string to a number var numStr = "2.345"; var num = parseFloat(numStr); //Print the result in the log window logWindow.printInfo(num); //Encode a string into an internet valid ASCII String var str = "a sentence with spaces"; var encodedStr = encodeURI(str); logWindow.printInfo(encodedStr); Function Object Prototypes ˆ toString() ˆ toLocaleString() ˆ valueOf() ˆ hasOwnProperty(V) ˆ isPrototypeOf(V) ˆ propertyIsEnumerable(V) WaveLab 7
4.9 Scripting 73 Functions ˆ toString() ˆ apply(thisArg, argArray) ˆ call(thisArg [, arg1 [, arg2, ...]]) Example: //Create a new custom marker Object function customMarker(name, comment, timeSecs) { this.name=name; this.comment=comment; this.timeSecs=timeSecs; } //Create a new instance of the custom marker var myMarker=new customMarker("A custom marker", "My custom marker comments",5); //Use prototype function to add a new property to it customMarker.prototype.samples = null; myMarker.samples = activeWave.sampleRate() * myMarker.timeSecs; //Trace the results in the log window logWindow.printInfo(myMarker.name); logWindow.printInfo(myMarker.samples); Array Objects Functions ˆ toString() ˆ toLocaleString() ˆ concat([item1 [, item2 [, ...]]]) ˆ join(separator) ˆ pop() ˆ push([item1 [, item2 [, ...]]]) ˆ reverse() ˆ shift() ˆ slice(start, end) ˆ sort(comparefn) ˆ splice(start, deleteCount[, item1 [, item2 [, ...]]]) ˆ unshift([item1 [, item2 [, ...]]]) Example: WaveLab 7
74 WaveLab Concepts //Create an empty array var a = new Array(); //Add some items to it a.push("first array item"); a.push("next array item", "last array item"); //Print them out in the Log window logWindow.printInfo(a.toString()); //Call the Array's reverse function a.reverse(); //View the results in the Log window logWindow.printInfo(a.toString()); String Objects Functions ˆ toString() ˆ valueOf() ˆ charAt(pos) ˆ charCodeAt(pos) ˆ concat([string1 [, string2 [, ...]]]) ˆ indexOf(searchString ,position) ˆ lastIndexOf(searchString, position) ˆ localeCompare(that) ˆ match(regexp) ˆ replace(searchValue, replaceValue) ˆ search(regexp) ˆ slice(start, end) ˆ split(separator, limit) ˆ substring(start, end) ˆ toLowerCase() ˆ toLocaleLowerCase() ˆ toUpperCase() ˆ toLocaleUpperCase() Example: //Create a string variable var str = new String("WaveLab is a powerful editing tool"); //Make it all upper case var capsStr = str.toUpperCase(); //View the results in the Log window logWindow.printInfo(capsStr); WaveLab 7
4.9 Scripting 75 Boolean objects Functions ˆ toString() ˆ valueOf() Example: //Test if an equation is true or false var isTrue = (1 + 1 == 3); //Convert the Boolean to a String and trace in the Log window logWindow.printInfo(isTrue.toString()); Number Objects Functions ˆ toString(radix) ˆ toLocaleString() ˆ toFixed(fractionDigits) ˆ toExponential(fractionDigits) ˆ toPrecision(precision) Example: //Convert a number into exponential notation var num = new Number(13.3714); //Show the result in the Log window logWindow.printInfo(num.toExponential()); Math Objects Values ˆ E ˆ LN10 ˆ LN2 ˆ LOG2E ˆ LOG10E ˆ PI ˆ SQRT1 2 ˆ SQRT2 WaveLab 7
76 WaveLab Concepts Functions ˆ abs(x) ˆ acos(x) ˆ asin(x) ˆ atan(x) ˆ atan2(y, x) ˆ ceil(x) ˆ cos(x) ˆ exp(x) ˆ floor(x) ˆ log(x) ˆ max([value1 [, value2 [, ...]]]) ˆ min([value1 [, value2 [, ...]]]) ˆ pow(x, y) ˆ random() ˆ round(x) ˆ sin(x) ˆ sqrt(x) ˆ tan(x) Examples: //Get a random number from 0 to 1 var r = Math.random(); //Print it out in the log window logWindow.printInfo(r); //Trace out Pi in the log window logWindow.printInfo(Math.PI); Date Objects Functions ˆ toString() ˆ toDateString() ˆ toTimeString() ˆ toLocaleString() WaveLab 7