oh, it just uses the built-in system polls to track amplitude and calls a specific function when a threshold is crossed (exemplified in oooooo as well + was the inspiration!)

basic setup:

function init()
  params:add_control("record_threshold","rec threshold",controlspec.new(1,1000,'exp',1,85,'amp/10k'))
end

amp_in = {}
local amp_src = {"amp_in_l","amp_in_r"}
for i = 1,2 do
  amp_in[i] = poll.set(amp_src[i])
  amp_in[i].time = 0.01
  amp_in[i].callback = function(val)
    if val > params:get("record_threshold")/10000 then
      -- your recording function goes here!
      amp_in[i]:stop() -- once threshold is crossed, we don't need to listen for it anymore
    end
  end
end

function arm_threshold_recording()
  amp_in[1]:start()
  amp_in[2]:start()
end
4 Likes