hey, would it be possible to crossfade between different buffered envelopes inside the SynthDef using Playbuf or Phasor / BufRd and multiply it with SinOsc for pulsar synthesis? instead of sequencing them with patterns.
Overlapping grains inside the SynthDef would be another thing then using Pulsedivider or other options…
thanks.
(
// custom granular envelopes
~getCustomEnvs = {
var tri = Env([0, 1, 0], [1, 1], \lin);
var perc = Env.perc(0.01, 1, 1, -4);
var customEnvs = [tri, perc];
customEnvs.collect{|env| Buffer.sendCollection(s, env.discretize(2048), 1) };
};
~customEnvs = ~getCustomEnvs.();
)
(
~customEnvs[0].plot;
~customEnvs[1].plot;
)
(
SynthDef(\grain, { |envBuf|
var trig = \trig.tr(1);
var sig, phasor, env;
var numPartials = 64;
var n = (1..numPartials);
// harmonic tension
var tension = (1 + (n * n * \inharmonic.kr(0.005))).sqrt;
// frequency spectrum
var freqs = \freq.kr(68) * n * tension;
// 3db/octave spectral tilt
var tilt = (log2(n) * \tilt.kr(-3)).dbamp;
var combDensity = { LFDNoise3.ar(0.3).linlin(-1, 1, 1, 2) } ! 2;
var comb = ((1 - (freqs.log2 * combDensity).sin.abs) ** \peak.kr(2));
sig = SinOsc.ar(freqs, { Rand(0, 2pi) } ! numPartials);
sig = sig * tilt * comb;
sig = sig = sig[0,2..].sum + ([-1,1] * sig[1,3..].sum);
sig = sig * -10.dbamp;
env = PlayBuf.ar(1, envBuf, ( \granDur.kr(0.1) / BufDur.ir(envBuf) ).reciprocal, trig, doneAction: 0);
//phase = EnvGen.ar(Env([0, 1], [\granDur.kr(0.1)]), trig, doneAction:2);
//env = BufRd.ar(1, envBuf, phase * BufFrames.kr(envBuf), 1, 4);
sig = sig * env * \amp.kr(0.25);
OffsetOut.ar(\out.kr(0), sig);
}).add;
)
(
Pdef(\grain,
Pmono(\grain,
\bufIndex, Pdup(4, Pseq([0, 1], inf)),
\envBuf, Pfunc{ |ev| ~customEnvs[ev[\bufIndex]] },
\freq, 68,
\tFreq, Pseg([12, 5], [5], \exp, inf),
\legato, Pseg([0.35, 0.75], [10], \exp, inf),
\dur, 1 / Pkey(\tFreq),
\granDur, Pkey(\dur) * Pkey(\legato),
\amp, 0.25,
\out, 0,
)
).play;
)