Can be used to ‘grab’ an effect device parameter that the user moves/changes in renoise:
Concept used in grab function in:
Sample code with printouts. Adds notifiers to all the parameters of the selected device in renoise. When a parameter is moved info is printed to the teminal and all notifiers that were added are removed.
Needs ‘correct device’ checks added etc.
Click to view contents
--API values
local song = renoise.song()
local device = song.selected_device
--table to hold functions. We user this to keep track of
--the notifier functions created for later notifier removal. (i.e. holds the pointers to the individual functions)
local notifier_tab = {}
--notifier function(s).
--This is the function added to each individual parameter of the selected device
--As the functions are added in a loop, num will equal the incrementer "i" which equals the devices parameter index.
--------------------------
local function printy(num)
--------------------------
--test print
print("Captured Parameter: "..num.."\n")
--do stuff relevant to your captured parameter here. i.e. set a global to point to it:
--my_global_captured_param = device:parameter(num)
--loop to delete all notifiers
------------------------------
for i = 1,#device.parameters do
--param
local param = device:parameter(i).value_observable
--remove notifiers
if param:has_notifier(notifier_tab[i]) then
param:remove_notifier(notifier_tab[i])
print("removed notifier "..i)
end
end
--reset table
notifier_tab = {}
end
--loop to add notifiers to all parameters of the selected
--device in renoise
------------------------
for i = 1,#device.parameters do
--build table as we go, passing i to printy()
notifier_tab[i] = function() printy(i) end
--param
local param = device:parameter(i).value_observable
--add notifiers
if not param:has_notifier(notifier_tab[i]) then
param:add_notifier(notifier_tab[i])
end
end