9 - ScremplerPlayer
Today, as a start of integrating my Scrempler instrument into my performance setup, I cleaned up the code that I have for the instrument.
The first cleanup in this is cleaning up the sound processing bit — it is basically sampling sounds from the microphones on the scrempler, and then has a few different methods of processing these.
There are a number of controls over each processing, which during the cleanup (and looking back at the code) I identified.
As I will have to adjust the actual physical controller I will use in this setup still a little bit, I will need to think about how I will control these parameters.
`
ScremplerPlayer {</p>
var <direct, <recorder,
<player;
var <comb, <pitcher, <filter;
var <recorderMono, <grainer, <grainfilter;
var <buffer;
var <grainbuffer;
*new{ |bufferLength|
^super.new.allocBuffer( bufferLength ).init;
}
allocBuffer { |length=4|
var s = Server.default;
if ( buffer.notNil ){ buffer.free };
buffer = Buffer.alloc( s, s.sampleRate * length, 2 ) ;
if ( grainbuffer.notNil ){ grainbuffer.free };
grainbuffer = Buffer.alloc( s, s.sampleRate * length, 1 ) ;
}
init{
direct = NodeProxy.new( Server.default, \audio, 2 );
direct.source = { |in=0, amp1=0.5, amp2=0.5, amp=1, lag=0.1|
SoundIn.ar( [0,1]+in ) * [amp1, amp2 ] * amp.lag( lag );
};
recorder = NodeProxy.new( Server.default, \audio, 2 );
recorder.source = { |bufnum=0, in=0, amp1=0.5, amp2=0.5, prelevel=0.5, reclevel=0.5, run=0, focus=1|
RecordBuf.ar( SoundIn.ar( [in,in+1] ) * [amp1,amp2], bufnum, recLevel: reclevel, preLevel: prelevel, run: run );
};
recorder.set( \bufnum, buffer );
player = NodeProxy.new( Server.default, \audio, 2 );
player.source = { arg bufnum = 0, rate=1, ratemod=1, amp=1, lag=0.5;
PlayBuf.ar(2,bufnum,rate*ratemod,loop:1) * amp.lag(lag);
};
player.addSpec( \rate, [0.1,10,\exponential].asSpec );
player.set( \bufnum, buffer );
comb = NodeProxy.new( Server.default, \audio, 2 );
comb.source = {
CombC.ar(
Resonz.ar( player.ar,
\freq.kr( 1200 ) * LFNoise1.kr( TRand.kr( 1, 10, Dust.kr(0.1) ), \freqdev.kr(0.2), 1 ) * [1,4/3] * SinOsc.kr( 0.05, 0, 0.5, 1 ),
\rq.kr(0.1)
), 0.2, \delay.kr(0.01, 0.25) * Array.fill(2, { LFNoise1.kr(2, 0.025, 1 ) }), \decay.kr(2)
) * \amp.kr(1).lag( 0.2 ) ;
};
comb.addSpec( \freq, [100,2000,\exponential].asSpec );
pitcher = NodeProxy.new( Server.default, \audio, 2 );
pitcher.source = {
PitchShift.ar(
CombC.ar(
Resonz.ar(
player.ar,
\freq.kr( 1200 ) * LFNoise1.kr( TRand.kr( 1, 10, Dust.kr(0.1) ), \freqdev.kr(0.2), 1 ) * [1,4/3] * SinOsc.kr( 0.05, 0, 0.5, 1 ),
\rq.kr(0.1)
),
0.2, \delay.kr(0.01) * Array.fill(2, { LFNoise1.kr(2, 0.025, 1 ) }), \decay.kr(2) ),
0.2, \pitchRatio.kr( 1.1 ), 0.02, 0.02 ) * \amp.kr(1).lag( 0.2 );
};
pitcher.addSpec( \freq, [100,2000,\exponential].asSpec );
filter = NodeProxy.new( Server.default, \audio, 2 );
filter.source = {
RLPF.ar(
RHPF.ar(
player.ar,
\freq.kr( 1200 ) * \freqmod.kr(1) * LFNoise1.kr( TRand.kr( 1, 10, Dust.kr(0.5) ), \freqdev.kr(0.2), 1 ) * [1,4/3] * SinOsc.kr( 0.05, 0, 0.5, 1 ),
\rq.kr( 0.1 )
),
\freq.kr * 2.5, \rq2.kr(0.25)
) * \amp.kr(1).lag( 0.2 );
};
filter.addSpec( \freq, [100,2000,\exponential].asSpec );
recorderMono = NodeProxy.new( Server.default, \audio, 1 );
recorderMono.source = {
|bufnum=4, in=0, amp=1, prelevel=0.25, reclevel=0.75, run=0|
RecordBuf.ar( SoundIn.ar( in ) * amp, bufnum, recLevel: reclevel, preLevel: prelevel, run: run );
};
grainer = NodeProxy.new( Server.default, \audio, 2 );
grainer.source = {
arg bufnum = 4, rate=1, ratemod=1, amp=1, lag=0.5;
var trig, duration;
trig = Dust.ar( \dens.kr(100) );
duration = (\dur.kr(1) / \dens.kr).max( 0.0001 );
GrainBuf.ar(2,
trig, duration, bufnum, rate*ratemod, \position.kr(0.5) * TRand.ar( 0.9, 1.1, trig ), pan: \pan.kr(0),
maxGrains: 1024 ) * amp.lag(lag);
};
grainer.addSpec( \rate, [0.1,10,\exponential].asSpec );
grainfilter = NodeProxy.new( Server.default, \audio, 2 );
grainfilter.source = {
var lag = \lag.kr(0.1);
RLPF.ar(
RHPF.ar(
grainer.ar,
\freq.kr( 1200 ) * \freqmod.kr(1) * LFNoise1.kr( TRand.kr( 1, 10, Dust.kr(0.5) ), \freqdev.kr(0.2), 1 ) * [1,4/3] * SinOsc.kr( 0.05, 0, 0.5, 1 ),
\rq.kr( 0.1 ).lag( lag )
),
\freq.kr * 2.5, \rq2.kr(0.25).lag( lag )
) * \amp.kr(1).lag( lag ) * \amp2.kr(1).lag(lag);
};
grainfilter.addSpec( \freq, [100,2000,\exponential].asSpec );
}
// direct.set( \amp )
// recorder.set( \run )
// recorderMono.set( \run )
// player.set( \amp )
// player.setUni( \rate )
// grainer.setUni( \rate )
// comb.setUni( \freq )
// pitcher.setUni( \freq )
// filter.setUni( \freq )
// grainfilter.setUni( \freq )
// start-stop of each layer (player, comb, pitcher, filter)
// amplitude of each layers
// rates of playback
// freqs of layers
// scrempler controls / pressure:
// rate modification
// delay, decay
// acceleration / hands playing:
// mean: freqmod, position, ratemod, pan
// stddev: rq, rq2, amp, dur, dens
}
`