I happen to have a bit more time on my hands these days and kept looking at this. I’ve managed to use Index.kr without crashing the interpreter every time. However, even though I’m using a Buffer to store and update my values, I still cannot have the process dynamically update them.
This time I used a bit more efficient and flexible process with Unpack1FFT and PackFFT.
(
var fftsize = 1024;
var numFXBins = fftsize/2; // transform just lower half of spectrum
// e = Env([0, 1], [1], \lin).discretize(numFXBins).as(Array);
// e = Env([0, 1], [1], -1).discretize(numFXBins).as(Array);
e = Env([0, 1], [1], -2).discretize(numFXBins).as(Array);
// e = Env([0, 0.5, 1], [0.5, 0.5], [-2, 2]).discretize(numFXBins).as(Array);
// e = Env([0, 0.5, 1], [0.4, 0.6], [-3, 3]).discretize(numFXBins).as(Array);
// e = Env([0, 0.5, 1], [0.4, 0.6], [-1, 1]).discretize(numFXBins).as(Array);
// e = Env([0, 0.7, 0.3, 0.45, 0.2, 1], [0.2, 0.2, 0.2, 0.2, 0.2], 'sqr').discretize(numFXBins).as(Array);
// e = Env([rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0)], [rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0), rrand(0.0, 1.0)], [rrand(-10, 10), rrand(-10, 10), rrand(-10, 10), rrand(0.0, 1.0), rrand(0.0, 1.0)]).discretize(numFXBins).as(Array);
// e = Env([0, 0.6, 0.3], [0.6, 0.4], \wel).discretize(numFXBins).as(Array);
e = (e * numFXBins).asInteger; // turn into indices
e.plot;
~warpBuffer = Buffer.loadCollection(s, e);
z = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
x = {
|rate = 0.5|
var in, chain, idx;
var outArray = Array.fill(fftsize, {0});
in = PlayBuf.ar(1, z, rate, loop: 1);
chain = FFT(LocalBuf(fftsize), in);
numFXBins.do({
|item, i|
outArray[i * 2] = Unpack1FFT(chain, fftsize, Index.kr(~warpBuffer, i), 0);
outArray[i * 2 + 1] = Unpack1FFT(chain, fftsize, Index.kr(~warpBuffer, i), 1);
});
chain = PackFFT(chain, fftsize, outArray.flop.flatten, 0, 250);
IFFT(chain).dup
}.play;
)
If i use the index i
within the Index.kr
Ugen then the process works as intended: static, but great sound. If I try and use a Ugen (I tried with Dbufrd
, but no avail) the sound is distorted as if one very specific function is applied (harsh high pitched), and still no dynamic control over it.
Moreover, if I try to use a buffer as argument (e.g. play(s, [\bufWarp, ~warpBuffer])
and the corresponding argument within the Synth, no sound at all is present for unknown reasons.
Probably still best to go for a Ugen?
Paul, lovely code! It sounds great even with not that many frequency bands. With 256 its quite expensive but sounds amazing.
Thanks!
Stefano