yes, like this:
ControlSpec = require 'controlspec'
-- param 'A' just prints its mapped value
params:add { type='control', id='A', name='A',
controlspec = ControlSpec.new(0, 100, 'lin', 0, 1, ''),
action = function(value) print('A: '..value) end}
----------------------
----- warning: bad code smell here
-- memoize raw 'A' param structure to avoid excessive lookups
local pA = params:lookup_param('A')
-- hack the maxval of the existing controlspec.
function change_a_max(newmax)
print('setting new max value: ' .. newmax)
pA.controlspec.maxval = newmax
end
-- param 'B' action changes control spec of param A
params:add { type='control', id='B', name='B', controlspec = ControlSpec.new(0, 100),
action = function(value) change_a_max(value) end}
---------------------
params:set('A', 75) -- prints '75'
params:set('B', 15)
params:set('A', 75) -- prints '15' (clamped)
but like @tehn, i don’t recommend it. i imagine you will run into edge cases when loading param sets from disk and stuff; it’s complex, &c.
i would consider whether you really need the “bars” abstraction (what about just having a sequence with a count of beats?), and also consider just constraining the values of beat_start and beat_end where they are used (e.g. within in the action functions.)
(as an aside, i’d recommend using 1-based indexing in lua programs, since it is the native paradigm and mixing them in the same codebase leads to confusion. )