[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-users] multiple Convolution2 UGens without CPU overload
hello,
i'm trying to understand how to have as many Convolution2 synths
running as possible. i found out, i get much more synths or much
bigger fftSize, when the synths carrying Convolution2 are created not
at once but in a delayed manner. What's the formula to determine the
best delay between creating them? in the example below i use
(fftSize / numSynth) / s.sampleRate) seconds between two creations ...
// note: CPU load was measured on macbook pro v1 with 2 ghz
~numChannels = 8;
~fftSize = 16384;
~fftBufs = Buffer.allocConsecutive( ~numChannels * 2, s,
~fftSize ).reshape( ~numChannels, 2 );
~path = "~/Desktop/Kalligraphie/IRs".absolutePath ++ "/"; // folder
of impulse responses, the files should be "[ 0 ... 7 ]
GainHPFCutMix.aif" (binaural stereo!)
~fftBufs.do({ arg chanBufs, speakCh; chanBufs.do({ arg buf, irChan;
buf.readChannel( ~path ++ speakCh.asString ++ "GainHPFCutMix.aif", 0,
~fftSize, channels: [ irChan ])})});
(
SynthDef( \convMix, { arg in, out, bufL, bufR, amp = 1.0;
var loadbang;
loadbang = Impulse.ar( 0 );
OffsetOut.ar( out, Convolution2.ar( In.ar( in, 2 ) * amp, [ bufL,
bufR ], loadbang ));
}).send( s );
)
~mixBusses = Array.fill( ~numChannels, { Bus.audio( s, 2 )});
// this pushes peak CPU to some 400 % (would have to use ~fftSize ==
2048 for no audio dropouts!)
~convSynths = Array.fill( ~numChannels, { arg ch; Synth( \convMix,
[ \in, ~mixBusses[ ch ].index, \out, 0, \bufL, ~fftBufs[ch]
[0].bufnum, \bufR, ~fftBufs[ch][1].bufnum, \amp, 0.5 ], s,
\addToTail )});
// ... second approach:
~convSynths.do({ arg synth; synth.free; });
// delaying the synth creations results in peak CPU at <80%
(therefore no audio drop outs)!
(
~convSynths = Array.newClear( ~numChannels );
fork {
~numChannels.do({ arg ch;
~convSynths[ ch ] = Synth( \convMix, [ \in, ~mixBusses[ ch ].index,
\out, 0, \bufL, ~fftBufs[ch][0].bufnum, \bufR, ~fftBufs[ch]
[1].bufnum, \amp, 0.5 ], s, \addToTail );
((~fftSize / ~numChannels) / s.sampleRate).wait;
});
}
)
would it be possible to have a multichannel Convolution2 version,
like i read in an 8 channel impulse response into one single buffer?
i know there exists an optimized two-channel FFT version, so i guess
this could be expanded to numChannels := 1 << n; i guess that would
also result in a great(?) CPU load improvement?
thx, -sciss-
p.s.: if i split up the stereo multi channel expansion onto two
different delayed synths, i get peak CPU even down to 40%