From 58117762a66473a21d7278853413669219e9f3d4 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Wed, 25 Oct 2023 12:54:05 +1100 Subject: [PATCH] First working version of position buffers as envelopes triggered from a Pattern so that they are guaranteed to be in sync with the tempoclock --- interface.scd | 46 +++++++++++++++++++++++----------------------- main.scd | 21 ++++++++++++++------- synths.scd | 51 ++++++++++++++++++++++++++++----------------------- 3 files changed, 65 insertions(+), 53 deletions(-) diff --git a/interface.scd b/interface.scd index 79205e3..eb6bd3b 100644 --- a/interface.scd +++ b/interface.scd @@ -40,20 +40,20 @@ OSCdef.freeAll; -~setspeed = { | track, v | - var speed, qv = if(~speedquant > 0, { ~quantspeed.value(v) }, { v }); - speed = qv / ~buflen; - if(~speedlock > 0, { - (0..3).do({|n| - ~possynths[n].set(\speed, speed); - if( n != track, { - var url = ("/grains/speed" ++ n).asSymbol; - ~to.s_(url, v); - }); - }); - }, - { ~possynths[track].set(\speed, speed) }); -}; +// ~setspeed = { | track, v | +// var speed, qv = if(~speedquant > 0, { ~quantspeed.value(v) }, { v }); +// speed = qv / ~buflen; +// if(~speedlock > 0, { +// (0..3).do({|n| +// ~possynths[n].set(\speed, speed); +// if( n != track, { +// var url = ("/grains/speed" ++ n).asSymbol; +// ~to.s_(url, v); +// }); +// }); +// }, +// { ~possynths[track].set(\speed, speed) }); +// }; // setrecord: toggles record on (1) or off (0) for a track, and also sets the // track's input mix to 0 so that it doesn't start fadeing out. If the track @@ -85,15 +85,15 @@ OSCdef.freeAll; ~to.slider('/grains/buflen', ~buflen, TouchOSCScale(0.1, 10.0), {}); -~to.button('/grains/mode0', 0, { |v| ~granulators[0].mode_(v); ~setmode.value(0, v) }); -~to.button('/grains/mode1', 0, { |v| ~granulators[1].mode_(v); ~setmode.value(1, v) }); -~to.button('/grains/mode2', 0, { |v| ~granulators[2].mode_(v); ~setmode.value(2, v) }); -~to.button('/grains/mode3', 0, { |v| ~granulators[3].mode_(v); ~setmode.value(3, v) }); - -~to.slider('/grains/speed0', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(0, v) }); -~to.slider('/grains/speed1', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(1, v) }); -~to.slider('/grains/speed2', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(2, v) }); -~to.slider('/grains/speed3', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(3, v) }); +// ~to.button('/grains/mode0', 0, { |v| ~granulators[0].mode_(v); ~setmode.value(0, v) }); +// ~to.button('/grains/mode1', 0, { |v| ~granulators[1].mode_(v); ~setmode.value(1, v) }); +// ~to.button('/grains/mode2', 0, { |v| ~granulators[2].mode_(v); ~setmode.value(2, v) }); +// ~to.button('/grains/mode3', 0, { |v| ~granulators[3].mode_(v); ~setmode.value(3, v) }); +// +// ~to.slider('/grains/speed0', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(0, v) }); +// ~to.slider('/grains/speed1', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(1, v) }); +// ~to.slider('/grains/speed2', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(2, v) }); +// ~to.slider('/grains/speed3', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(3, v) }); ~to.slider('/grains/passthrough', 0.75, TouchOSCScale(0, 1), { |v| ~grainmixer.set(\passthrough, v) }); diff --git a/main.scd b/main.scd index 7035ed9..ce9453e 100644 --- a/main.scd +++ b/main.scd @@ -15,9 +15,9 @@ Routine.run({ ~usbinput1 = 2; ~usbinput2 = 3; - ~bpm = 80; + ~bpm = 85; ~bps = ~bpm / 60; - ~beatsperbar = 8; + ~beatsperbar = 4; ~buflen = ~beatsperbar / ~bps; [ "bpm", ~bpm ].postln; @@ -25,7 +25,6 @@ Routine.run({ ~tc = TempoClock.new(~bps); - ~touchosc_ip = "192.168.0.209"; ("./synths.scd").loadRelative; @@ -33,8 +32,15 @@ Routine.run({ s.sync; ("./control.scd").loadRelative; s.sync; + +}); +) + ("./granulator.scd").loadRelative; - s.sync; + + +( +Routine.run({ ("./effects.scd").loadRelative; s.sync; ("./sequencer.scd").loadRelative; @@ -43,6 +49,7 @@ Routine.run({ }); ) -~granulators[0].grainamp_(0.75); -g -~dumpbuffers.value("looptober14") \ No newline at end of file +~posb[0].scope +~granulators[0].grainamp_(0); +~granulators[0].loopsynth +~dumpbuffers.value("looptober23") \ No newline at end of file diff --git a/synths.scd b/synths.scd index 66862db..707bff5 100644 --- a/synths.scd +++ b/synths.scd @@ -1,30 +1,25 @@ ( -SynthDef(\pos_sine, { - arg out, speed=1; - Out.kr(out, 0.5 + SinOsc.kr(speed * 0.5, -0.5pi, 0.5)); -}).add; - SynthDef(\pos_saw, { - arg out, speed=1; - Out.kr(out, 0.5 + LFSaw.kr(speed, 1, 0.5, 0)); -}).add; + arg out, dur=1; + Out.kr(out, EnvGen.kr(Env([0, 1], dur), doneAction: Done.freeSelf)) +}).add(); + +SynthDef(\pos_sin, { + arg out, dur=1; + Out.kr(out, EnvGen.kr(Env.sine(dur, 1), doneAction: Done.freeSelf)) +}).add(); SynthDef(\pos_reverse, { - arg out, speed=1; - Out.kr(out, 0.5 - LFSaw.kr(speed, 1, 0.5, 0)); -}).add; + arg out, dur=1; + Out.kr(out, EnvGen.kr(Env([1, 0], dur), doneAction: Done.freeSelf)) +}).add(); -SynthDef(\pos_step, { - arg out, speed=1, steps=8; - var stepwise = LFSaw.kr(speed, 1, 0.5 * steps, 0.5 * steps).floor; - Out.kr(out, stepwise / steps); -}).add; - -SynthDef(\pos_random, { - arg out=5, speed=1; - Out.kr(out, 0.5 + WhiteNoise.kr(0.5)); -}).add; +// SynthDef(\pos_step, { +// arg out, speed=1, steps=8; +// var stepwise = LFSaw.kr(speed, 1, 0.5 * steps, 0.5 * steps).floor; +// Out.kr(out, stepwise / steps); +// }).add; SynthDef(\lfo, { arg out, freq=1, amp=0; @@ -32,8 +27,18 @@ SynthDef(\lfo, { }).add; SynthDef(\trigger, { - arg out=1, freq=1; - Out.kr(out, Impulse.kr(freq)) + arg out=1; + Out.kr(out, EnvGen.kr(Env.perc(0.001, 0.2, 2), levelScale:2.0, levelBias:-1,doneAction:Done.freeSelf)); }).add; + +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; + )