Page tree
Skip to end of metadata
Go to start of metadata

runAsync(func, arg1, arg2, ...)

Description

Executes a function in the controller thread. By calling runAsync in the processor thread, you can invoke a function that is executed in the controller thread. The execution of runAsync takes at least one audio block, or longer, depending on the function which was called. The callback which called runAsync is put on hold until the function has completed. Please be aware of this when using runAsync.

Available in: Processor.

Arguments

funcThe name of the function to be called.function
arg1, arg2, ...The arguments of the function.optional

Example

-- color held keys
keyOnColor = 5
keys = getKeyProperties()

function setColorOfKey(event, keyColor)
  if keyColor then
    keys[event.note] = { color = keyColor }
  else
    keys[event.note].color = nil
  end
  print(event.note)
end
  
function onNote(event)
  postEvent(event)  
  runAsync(setColorOfKey, event, keyOnColor)
  print("onNote")
end
   
function onRelease(event)
  postEvent(event)
  runAsync(setColorOfKey, event)
  print("onRelease")
end

1 Comment