uvi-script
Musical event scripting with Lua
Loading...
Searching...
No Matches
Async

Classes

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

Functions

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

Detailed Description

Asynchronous operations for non-blocking file I/O and long-running tasks.

Async operations run on background threads to avoid blocking the real-time audio thread. They return AsyncTask objects that can be polled for completion or accept callbacks for notification when the operation finishes.

Available Operations:

Task Management:

Usage Patterns:

See also
Asynchronous Operations, Engine

Function Documentation

◆ browseForFile()

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 browseForFile(mode, title, initialFileOrDirectory, filePatterns, callback)
launch a file chooser to select a file to open or save
Definition api.lua:32

◆ createMidiFile()

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

◆ loadData()

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 loadData(path, callback)
load data from file.
Definition api.lua:134

◆ loadImpulse()

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)
A Patch that represents a monotimbral instrument.
Definition Engine.cpp:238
table inserts
all InsertEffect for this node
Definition Engine.cpp:243
function loadImpulse(reverb, path, callback)
load and impulse response inside the reverb.
Definition api.lua:316

◆ loadMidi()

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

◆ loadSample()

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)
table layers
Layer list for this Program (1-indexed, use Program.layers to get the count)
Definition Engine.cpp:247
function loadSample(oscillator, path, callback)
load a sample inside the oscillator
Definition api.lua:56

◆ loadState()

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

◆ loadTextData()

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 loadTextData(path, callback)
load string from file.
Definition api.lua:193

◆ purge()

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)
function purge(target, callback)
purge an/several element(s)/oscillator(s) from its/their content in order to release memory.
Definition api.lua:350

b) polling

local task = purge(Program.layers[1])
while not task.finished do
wait(1000)
end
print("layer is now purged")
function wait(ms)
suspend the current thread callback execution for the given number of samples.
Definition wrapper.lua:39

◆ saveData()

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

◆ saveMidi()

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

◆ saveState()

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

◆ saveTextData()

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

◆ setPlaybackOptions()

function setPlaybackOptions ( oscillator ,
start ,
end_ ,
loopType ,
loopStart ,
loopEnd ,
playForward ,
callback  )

set playback options inside the oscillator

Parameters
oscillatorthe oscillator element to modify
startsample start position in samples
endsample end position in samples
loopTypeloop mode: 0 = None, 1 = Forward, 2 = Alternate, 3 = OneShot
loopStartloop start position in samples
loopEndloop end position in samples
playForwardtrue to play forward, false to play in reverse
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 setPlaybackOptions(oscillator, start, end_, loopType, loopStart, loopEnd, playForward, callback)
set playback options inside the oscillator
Definition api.lua:81

◆ unpurge()

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)
function unpurge(target, callback)
unpurge an/several element(s)/oscillator(s) content in order to load their memory.
Definition api.lua:384

b) polling

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