From fdf92ef4bab79897e959d3b59cb250a3008a2bed Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Fri, 7 Apr 2023 16:16:05 +1000 Subject: [PATCH] Refactoring with granulator in a quark --- NOTES.md | 10 ++++++++++ grains.scd | 57 ++++++++++++------------------------------------------ 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/NOTES.md b/NOTES.md index 1250418..25716a2 100644 --- a/NOTES.md +++ b/NOTES.md @@ -6,6 +6,16 @@ - multiple grain buffers - TouchOsc interface to select which to send to - play back all buffers? +- refactor for multitrack + - which controls are per-track and which are global? sort these out in the UI + - encapsulate a grainstrack in an object? + +- auto-mix: base the mix level on how loud the incoming signal is so that tracks don't fade out + +- fancier playback: + - intertwine different rates and directions + + - rhythm controls - number of steps in step granulator - modulate grain level in time with playback diff --git a/grains.scd b/grains.scd index 8dd0d17..96ee03d 100644 --- a/grains.scd +++ b/grains.scd @@ -9,53 +9,11 @@ Server.killAll; ~frippbuffer.isNil; -( -SynthDef( - \fripp_record, - { - arg in = 2, buffer = 0, mix = 0.25, record = 0.0; - var insig = record * In.ar(in, 1); - RecordBuf.ar(insig, buffer, 0, mix, 1 - mix, loop: 1) - } -).add; -SynthDef( - \grainsynth, - { - arg out=0, buffer, blen, pitchb, triggerb, posb, modb, size=0.1, amp=0.5, pan=0, track=0.25, jitter=0, blur=0.0; - var pitch, trigger, chor, pos, pans, grains, filtfreq; - trigger = In.kr(triggerb); - pitch = In.kr(pitchb); - pos = Wrap.kr(In.kr(posb, 1) + WhiteNoise.kr(blur), 0, 1); - pans = pan + WhiteNoise.kr(jitter) + (track * (In.kr(posb, 1) - 1)); - grains = TGrains.ar(2, trigger, buffer, pitch, pos * blen, size, pans, amp); - Out.ar(out, grains); - } -).add; -) - -( - -~ntracks = 4; - -~makebuffers = { - if( ~frippbuffers.isNil.not, { - ~frippbuffers.do({ |b| b.free }); - ~frippbuffers.free; - }); - - ~frippbuffers = Array.new(~ntracks); - - ~currentfripp = 0; - - (1..~ntracks).do( { |i| - ~frippbuffers.add(Buffer.alloc(s, s.sampleRate * ~buflen, 1)); - }); -}; - +( ~to = TouchOSC("192.168.0.209", 9000); ~usbinput = 2; @@ -241,9 +199,17 @@ fork { ).play(s, [ \out, ~pitchb, \triggerb, ~triggerb, \posb, ~playbacklfob, \dir, 1, \track, 0]); +) + +s +Granulator.init(s) + +~g3 = Granulator.new(4, ~recordb, ~granulatorb, ~playbacklfob, ~triggerb, ~pitchb); + +~g.recorder.set(\record, 1.0); ~makebuffers.value(); - +( ~bufrecorders = Array.new(~ntracks); ~frippbuffers.do({ @@ -288,6 +254,8 @@ fork { ~granulator = ~granulators[0]; +) +( // mixing and effects ~fxb = Bus.audio(s, 2); @@ -361,7 +329,6 @@ fork { ) -// why can't this all be in the same block? (