Hi Brian,
You can use runSync to get around this.
It should let you create and post events from macro page.
-- A Global pointing to our "CC Mapper" MidiModule to be used throughout the script
theMap = this.parent:getMidiModule("CC Mapper")
-- Some visual feedback for the macro to display the value of what ever controller is set to do vibrato in a text field.
defineParameter("Vibrato", nil, 0, 0, 127, 1)
-- Track a parameter that can be updated via macro page control (knob) which is ultimately tied to a mod matrix.
defineParameter("setVibrato", nil, 0, 0, 127, 1, function() postVib() end)
function postNewControllerEvent()
postEvent(newEvent)
end
-- Post the "setVibrato" parameter value as a valid CC event to the engine if it changes.
function postVib()
mapper = theMap:getParameter("CC131.Source")
newEvent = Event(EventType.controller) -- make this global variable
newEvent.controller = mapper
newEvent.value = setVibrato
print(newEvent) --Added just for testing purposes to make sure the newEvent is actually being generated properly.
--postEvent(newEvent)
runSync(postNewControllerEvent, 1)
end
-- What the script does with any controller events it processes.
function onController(event)
postEvent(event)
mapper = theMap:getParameter("CC131.Source")
if event.controller == mapper then
Vibrato = event.value
end
end
Or another way, using controlChange() instead of creating and posting new events. Should do the same thing and it’s a bit shorter.
-- A Global pointing to our "CC Mapper" MidiModule to be used throughout the script
theMap = this.parent:getMidiModule("CC Mapper")
-- Some visual feedback for the macro to display the value of what ever controller is set to do vibrato in a text field.
defineParameter("Vibrato", nil, 0, 0, 127, 1)
-- Track a parameter that can be updated via macro page control (knob) which is ultimately tied to a mod matrix.
defineParameter("setVibrato", nil, 0, 0, 127, 1, function() postVib() end)
function postNewControllerEvent()
controlChange(mapper, setVibrato)
end
-- Post the "setVibrato" parameter value as a valid CC event to the engine if it changes.
function postVib()
mapper = theMap:getParameter("CC131.Source")
runSync(postNewControllerEvent, 1)
end
-- What the script does with any controller events it processes.
function onController(event)
postEvent(event)
mapper = theMap:getParameter("CC131.Source")
if event.controller == mapper then
Vibrato = event.value
end
end
I’m not sure I completely understand what you’re trying to do but the error message was gone when using runSync.