Last active
April 1, 2024 18:33
-
-
Save catfact/7278f61d2dc69f95fd0571bc0d67ca0c to your computer and use it in GitHub Desktop.
norns amplitude poll test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- amp poll test | |
engine.name="AmpPollTest" | |
handle_amp_poll = function(channel, value) | |
local db | |
if value <= 0.0 then db = "-inf" | |
else db = 20 * math.log10(value) | |
end | |
print("amp poll: "..channel.." = "..db) | |
end | |
init = function() | |
print("amp_poll_test init") | |
params:add({ | |
type='control', | |
id='amp', | |
name='amp', | |
controlspec=controlspec.new(0, 1, 'lin', 0, 0.001, ''), | |
action=function(value) engine.amp(value) end | |
}) | |
params:add({ | |
type='number', | |
id='which', | |
name='which', | |
minval=1, | |
maxval=2, | |
default=0, | |
action=function(value) | |
-- zero-base for supercollider | |
engine.which(value-1) | |
end | |
}) | |
local p = poll.set("amp_out_l", function(x) handle_amp_poll(1, x) end) | |
p:start() | |
p = poll.set("amp_out_r", function(x) handle_amp_poll(2, x) end) | |
p:start() | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Engine_AmpPollTest : CroneEngine { | |
var <synth; | |
*new { arg context, doneCallback; | |
^super.new(context, doneCallback); | |
} | |
alloc { | |
synth = SynthDef.new(\amp_poll_test, { | |
arg out=0, amp=0.125, which = 0; | |
var sources = [ | |
WhiteNoise.ar, | |
SinOsc.ar(220) | |
]; | |
var signal = (Select.ar(which, sources) * amp).dup; | |
Out.ar(out, signal.dup(2)); | |
}).play(target: context.xg); | |
this.addCommand("amp", "f", { | |
arg msg; | |
var amp = msg[1]; | |
synth.set(\amp, amp.clip(0, 1)); | |
}); | |
this.addCommand("which", "i", { | |
arg msg; | |
var which = msg[1]; | |
synth.set(\which, which.clip(0, 1)); | |
}); | |
} | |
free { | |
synth.free; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment