replaced grains with trgrains for multichannel granulation

master
Rob Canning 2022-09-07 13:54:15 +02:00
parent a32fef059f
commit a9a86fbe59
1 changed files with 100 additions and 2 deletions

102
gtr.scd
View File

@ -94,6 +94,9 @@ SynthDef("recBuf",{
SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
sndbuf, envbuf, pan=0, imp=50,
pitchmodeindex=0, sensorpitch=1, sensorgdur=0.1, sensorgpan=0,
positionmodeindex=1, gdurmodeindex=0, gpanmodeindex=0,
@ -152,9 +155,97 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
env = EnvGen.kr(~gpanmode=1;
Env([0, 1, 0], [1, 1], \sin, 1), gate, levelScale: amp, doneAction: 2);
signal = GrainBuf.ar(2,
impulse, // selectable between impulse.kr and dust.kr
//signal = GrainBuf.ar(2,
//impulse, // selectable between impulse.kr and dust.kr
//gdur, sndbuf, pitch, position, 2, gpan, envbuf);
//signal = FreeVerb2.ar(signal[0], signal[1], mix:0.4, room:0.5, damp:0);
signal = TGrains.ar(4, impulse, b, pitch, position, gdur, gpan, amp, 4);
stereosignal = signal* env;
quadsignalL = PanAz.ar(4, signal[0], MouseX.kr(0,2));
quadsignalR = PanAz.ar(4, signal[1], MouseX.kr(0,2).range(2,0));
quadsignal = signal; //Mix.ar([quadsignalL, quadsignalR]);
signalchannels = Select.ar(signalChannelIndex, [stereosignal, quadsignal]);
//signal = signalchannels;
Out.ar(0, signalchannels);
}).add;
);
SynthDef(\buf_tgrain, { | out, gate = 1, amp = 0.5,
sndbuf, envbuf, pan=0, imp=50,
pitchmodeindex=0, sensorpitch=1, sensorgdur=0.1, sensorgpan=0,
positionmodeindex=1, gdurmodeindex=0, gpanmodeindex=0,
sensorposition=0, impulsemodeindex=0, sensorimpulse=0,
signalChannelIndex=1,
rlow= -1, rhigh=10 |
var signal, env, freqdev, pos,
pitchmode0, pitchmode1, pitch,
gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, gdur,
gpanmode0, gpanmode1, gpan,
positionmode0, positionmode1, positionmode2, position,
impulsemode0, impulsemode1, impulse,
stereosignal, quadsignalL, quadsignalR, quadsignal, signalchannels;
// grain duration mode -untransposed, random, or sensor controlled
gdurmode0 = 0.05;
gdurmode1 = 0.1;
gdurmode2 = LFNoise1.kr.range(0.1, 0.3);
gdurmode3 = LFNoise1.kr.range(0.1, 0.6);
gdurmode4 = LFNoise1.kr.range(0.6, 0.6);
gdurmode5 = LFNoise1.kr.range(0.1, 2.6);
gdurmode6 = LFNoise1.kr.range(1, 2);
gdur = Select.kr(gdurmodeindex,
[gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, sensorgdur]);
// grain pan mode -untransposed, random, or sensor controlled
gpanmode0 = 0;
gpanmode1 = LFNoise1.kr(100).range(-1, 1);
gpan = Select.kr(gpanmodeindex,
[gpanmode0, gpanmode1, sensorgpan]);
// grain pitch mode -untransposed, random, or sensor controlled
pitchmode0 = 1;
pitchmode1 = LFNoise1.kr.range(rlow, rhigh);
pitch = Select.kr(pitchmodeindex,
[pitchmode0, sensorpitch, pitchmode1 ]);
// granular playhead mode - fixed random or sensor controlled
positionmode0 = 0.1;
positionmode0 = (Phasor.ar(0, 1 * BufRateScale.ir(b), 0, BufSamples.ir(b)-1) + LFNoise1.ar(100).bipolar(0.1 * SampleRate.ir) ) / BufSamples.ir(b);
positionmode1 = LFNoise1.kr.range(0.05, 0.98);
positionmode2 = LFNoise1.kr.range(0.1, 0.2);
position = Select.kr(positionmodeindex,
[positionmode0, positionmode1, positionmode2, sensorposition]);
// grain impulse frequency mode - random, metric or sensor based impulse modes
impulsemode0 = Impulse.kr(imp);
impulsemode1 = Dust.kr(imp);
impulse = Select.kr(impulsemodeindex,
[impulsemode0, impulsemode1, sensorimpulse]);
env = EnvGen.kr(~gpanmode=1;
Env([0, 1, 0], [1, 1], \sin, 1), gate, levelScale: amp, doneAction: 2);
signal = GrainBuf.ar(2, impulse, // selectable between impulse.kr and dust.kr
gdur, sndbuf, pitch, position, 2, gpan, envbuf);
signal = TGrains.ar(4, impulse, b, pitch, position, gdur, gpan, amp, 4);
//signal = FreeVerb2.ar(signal[0], signal[1], mix:0.4, room:0.5, damp:0);
@ -175,6 +266,10 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
}).add;
);
)
// RUNME 3 ==========================================
@ -453,6 +548,9 @@ r.set(\overdub, 0); // off
~granulator1.set(\gate, 1); // granulator on
~granulator1.set(\gate, 0); // granulator off
a = Scale.major;
/////////////////////////////////////////////////
// -----------------------------------------------