Study 3 should probably be updated, as it doesnāt work as described, in that case.
With
function init()
-- Params
params:add_control("tempo","tempo",controlspec.new(40,200,'lin',0,110,'bpm'))
params:set_action( "tempo", function(t) clk:bpm_change(t) end)
params:add_control("xpos","xpos",controlspec.new(1,5,'lin',0,3))
params:set_action( "xpos", function(x) patterngen.set_xpos(x) end)
params:add_control("ypos","ypos",controlspec.new(1,5,'lin',0,3))
params:set_action( "ypos", function(y) patterngen.set_ypos(y) end)
params:add_control("density_kick","density_kick",controlspec.new(0,1,'lin',0,0.5))
params:set_action( "density_kick", function(x) patterngen.set_threshold_kick(x) end)
params:add_control("density_snare","density_snare",controlspec.new(0,1,'lin',0,0.5))
params:set_action( "density_snare", function(x) patterngen.set_threshold_snare(x) end)
params:add_control("density_hat","density_hat",controlspec.new(0,1,'lin',0,0.5))
params:set_action( "density_hat", function(x) patterngen.set_threshold_hat(x) end)
params:read(nil)
params:bang()
metro_save = metro.init(function(stage) params:write(nil) end, 10)
metro_save:start()
---etc.
end
I now get
pset >> write: /home/we/dust/data/luagrid/luagrid-01.pset
The preset seems to contain the value I expect, after running the script and tweaking params.
However, while tempo seems to be currently recalled, when re-running the script, the value for āxposā and āyposā always get their default values, rather than those previously written to the pset (and these values are re-written into the pset the first time it auto-saves, assuming I havenāt changed them manually at this point).
UPDATE
My bad- a āreset()ā function was being called later on in init(), that was resetting the xpos and ypos params.
Removed that, and all appears to be working as expected, now!