Classes | Functions
Async

Asynchronous operations. More...

Classes

class  AsyncBrowseForFileTask
 An Asyncronous task that browses for a file on disk. More...
 
class  AsyncMidiFileLoadTask
 An Asyncronous task that load a MIDI file. More...
 
class  AsyncTask
 An Asyncronous task. More...
 

Functions

function browseForFile (mode, title, initialFileOrDirectory, filePatterns, callback)
 launch a file chooser to select a file to open or save More...
 
function createMidiFile (maxNumTracks, maxNumEvents, callback)
 create a midi file asynchronously More...
 
function loadData (path, callback)
 load data from file. More...
 
function loadImpulse (reverb, path, callback)
 load and impulse response inside the reverb. More...
 
function loadMidi (path, callback)
 load a midi file asynchronously More...
 
function loadSample (oscillator, path, callback)
 load a sample inside the oscillator More...
 
function loadState (path, callback)
 load state to file. More...
 
function loadTextData (path, callback)
 load string from file. More...
 
function purge (target, callback)
 purge an/several element(s)/oscillator(s) from its/their content in order to release memory. More...
 
function saveData (data, path, callback)
 save data to file. More...
 
function saveMidi (midifile, path, callback)
 save a midi file asynchronously More...
 
function saveState (path, callback)
 save state from file. More...
 
function saveTextData (data, path, callback)
 save string to file. More...
 
function setPlaybackOptions (oscillator, start, end_, loopType, loopStart, loopEnd, playForward, callback)
 set playback options inside the oscillator More...
 
function unpurge (target, callback)
 unpurge an/several element(s)/oscillator(s) content in order to load their memory. More...
 

Detailed Description

Asynchronous operations.

Function Documentation

function browseForFile ( mode  ,
title  ,
initialFileOrDirectory  ,
filePatterns  ,
callback   
)

launch a file chooser to select a file to open or save

Parameters
modefile browsing mode ("open" or "save")
titlea text string to display in the dialog box to tell the user what's going on
initialFileOrDirectorythe file or directory that should be selected when the dialog box opens. If left empty the default location is OS-dependent
filePatternsa set of file patterns to specify which files can be selected - each pattern should be separated by a comma or semi-colon, e.g. "*" or "*.jpg;*.gif". An empty string means that all files are allowed
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncBrowseForFileTask

Example:

browseForFile("open", "choose file to open", "", "", function(task) print(task.result) end)
function loadSample ( oscillator  ,
path  ,
callback   
)

load a sample inside the oscillator

Parameters
oscillator
pathpath to sample file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask

Example:

loadSample(Program.layers[1].keygroups[1].oscillators[1], "samples/sample.wav", function(task) print("done") print(task.success) end)
function setPlaybackOptions ( oscillator  ,
start  ,
end_  ,
loopType  ,
loopStart  ,
loopEnd  ,
playForward  ,
callback   
)

set playback options inside the oscillator

Parameters
oscillator
start
end
loopType0 None, 1 Forward, 2 Alternate, 3 OneShot
loopStart
loopEnd
playForward
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask

Example:

setPlaybackOptions(Program.layers[1].keygroups[1].oscillators[1], 0, 100, 0, 0, 0, function(task) print("done") print(task.success) end)
function loadState ( path  ,
callback   
)

load state to file.

Parameters
pathpath to file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask
function saveState ( path  ,
callback   
)

save state from file.

Parameters
pathpath to file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask
function loadData ( path  ,
callback   
)

load data from file.

Parameters
pathpath to file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask

Example:

browseForFile("open", "choose file to open", "", "", function(task)
loadData(task.result, function(data)
print(data)
end)
end)
function saveTextData ( data  ,
path  ,
callback   
)

save string to file.

Parameters
datastring to save
pathpath to file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask
function loadTextData ( path  ,
callback   
)

load string from file.

Parameters
pathpath to file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask

Example:

browseForFile("open", "choose file to open", "", "", function(task)
loadTextData(task.result, function(data)
print(data)
end)
end)
function saveData ( data  ,
path  ,
callback   
)

save data to file.

the data is encoded using JSON, supported types are boolean, numbers, arrays and dicts lua tables can be both arrays and dicts at the same time, this case cannot be converted and is thus unsupported, the result is undefined is undefined. Lua tables that are saved should be either arrays or dicts. Nested tables are supported but circular references are not. Any other lua datatype that cannot be mapped to JSON will be ignored:

  • coroutines
  • lightuserdata
  • userdata
Parameters
datadata to save
pathpath to file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask
function loadMidi ( path  ,
callback   
)

load a midi file asynchronously

Parameters
pathpath to midi file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncMidiFileLoadTask
function createMidiFile ( maxNumTracks  ,
maxNumEvents  ,
callback   
)

create a midi file asynchronously

Parameters
maxNumTracks
maxNumEvents
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncMidiFileLoadTask
function saveMidi ( midifile  ,
path  ,
callback   
)

save a midi file asynchronously

Parameters
midifilemidi sequence object
pathpath where the midi file should be saved
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncMidiFileLoadTask
function loadImpulse ( reverb  ,
path  ,
callback   
)

load and impulse response inside the reverb.

Parameters
reverb
pathpath to impulse response file
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask

Example:

loadImpulse(Program.inserts[1], "IR/irsample.wav", function(task) print("done") print(task.success) end)
function purge ( target  ,
callback   
)

purge an/several element(s)/oscillator(s) from its/their content in order to release memory.

A purge command is sent and executed asynchronously to avoid blocking the script execution. One can specify either a single Element or an array of Elements to purge. Elements that contain other Elements are purged recursively. One can also specify and optional callback to be called upon completion of the asynchronous operation.

Parameters
targetit can be either a single oscillator, and Element or a Table of Elements
callbackcallback function that will be called upon completion of the asynchronous task
Returns
an AsyncTask

Examples: a) asynchronous callback

purge(Program.layers[1], function() print("layer is now purged") end)

b) polling

local task = purge(Program.layers[1])
while not task.finished do
wait(1000)
end
print("layer is now purged")
function unpurge ( target  ,
callback   
)

unpurge an/several element(s)/oscillator(s) content in order to load their memory.

An unpurge command is sent and executed asynchronously to avoid blocking the script execution. One can specify either a single Element or an array of Elements to load. Elements that contain other Elements are unpurged recursively. One can also specify and optional callback to be called upon completion of the asynchronous operation.

Parameters
targetit can be either a single oscillator, and Element or a Table of Elements
callbackcallback function that will be called upon completion of the asynchronous task
Returns
a handle

Examples: a) asynchronous callback

unpurge(Program.layer[1], function() print("layer is now loaded") end)

b) polling

local task = unpurge(Program.layer[1])
while not task.finished do
wait(1000)
end
print("layer is now loaded")