From 90e4ad3032c2f338456a6f134af6c20c077631d0 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 1 Oct 2023 13:21:40 +1100 Subject: [PATCH] Moved metronome out to sequencer.scd --- sequencer.scd | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sequencer.scd diff --git a/sequencer.scd b/sequencer.scd new file mode 100644 index 0000000..4516a4e --- /dev/null +++ b/sequencer.scd @@ -0,0 +1,46 @@ +// metronome code here is a bit gross but easier + +~beatsperbar = 4; +~bps = ~beatsperbar / ~buflen; +~tc = TempoClock.new(~bps); + +SynthDef(\metronome, { + arg out=0, amp=1, pan=0, filter=1000, atk=0.01, rel=0.1; + var sig, env; + env = EnvGen.kr(Env.perc(atk, rel, amp), doneAction: Done.freeSelf); + sig = HPF.ar(WhiteNoise.ar(), filter); + Out.ar(out, Pan2.ar(sig * env, pan)); +} +).add; + +~metrob = Bus.audio(s, 2); + +~metromix = SynthDef(\metromix, { + arg in=1, out=0, amp=1; + Out.ar(out, amp * In.ar(in, 2)); +}).play(s, [\in, ~metrob, \out, 0, \amp, 0]); + + + + +~metronome = Pbind( + \instrument, \metronome, + \dur, 1, + \amp, 0.5, + \pan, 0, + \out, ~metrob +).play(~tc); + + +~to.button('/grains/metronome', 0, { |v| + // reset tempo when turning metronome on + if( v == 1, { + ~bps = ~beatsperbar / ~buflen; + ~tc.tempo_(~bps); + }); + // FIXME + ~metromix.set(\amp, v) + +}); + +