//-> Example Xenakis Metastaseis in Iannix
/*
sc + iannix = ~80% system cpu on a 2.93GHz Intel Core 2 Duo
(but see cpu protection in the defined globalActions[\cursors], ~maxSynths)
*/
(//1: settings...
~inx !? {~inx.removeAll}; //free synthGroup and objects if exist
~inx = Iannix.new;
s = Server.local.waitForBoot {
SynthDef(\gendy, {|out= 0, t_trig = 1.0, freq = 500, detune = 0, bpf_freq = 1000, lagTime = 0.1, vol = 1.0, pan = 0.0|
var synth, numcps, nbGendy = 5, pollAmp;
numcps= Rand(2, 10);
freq = Lag.kr(freq, lagTime);
detune = detune.clip(0, 10);
synth = Pan2.ar(
Mix.ar(
Gendy3.ar(
ampdist:1,
durdist:1,
adparam:1.0,
ddparam:1.0,
freq: freq * { LFNoise2.kr(3).range(detune.neg, detune).midiratio }!nbGendy,
ampscale:0.02,
durscale:0.01,
initCPs:12,
mul:0.8,
add: 0.0
)
)
, pan);
synth = BPF.ar(synth, Lag.kr(bpf_freq, 0.1), 2);
synth = Line.kr(0, 1, 2) * synth;
synth = synth * vol * (1/nbGendy) * SinOsc.ar(Rand(1.0, 6)).range(0.8, 1);
Out.ar(out, synth)
}).send(s);
//FX
SynthDef(\tank, {|inBus = 0, mixFx = 0, feedback = 0, spread = 0.3|
var local, in, amp;
in = In.ar(inBus, 2);
amp = Amplitude.kr(Mix.ar(in));
//in = in * (amp > 0.04); // noise gate
// in = in * 0.5;
local = LocalIn.ar(2) * feedback;
local = OnePole.ar(local, spread);
local = Rotate2.ar(local[0], local[1], 0.237);
local = AllpassN.ar(local, 0.05, {Rand(0.01,0.05)}.dup, 2);
local = DelayN.ar(local, 0.3, {Rand(0.15,0.33)}.dup);
local = AllpassN.ar(local, 0.05, {Rand(0.03,0.15)}.dup, 2);
local = LeakDC.ar(local);
local = local + in;
4.do {
var t;
t = {Rand(0.005,0.02)}.dup;
local = AllpassN.ar(local, t, t, 1);
};
LocalOut.ar(local);
ReplaceOut.ar(inBus , ( local * mixFx ) + ( in * (mixFx-1) ) );
}).send(s);
};
)
//check that the server is on, then...
(//2: launching...
~maxSynths = 60; //reduce this in case of cpu peak
~synth !? { ~inx.synthGroup.free };
~inx.createSynthGroup;
//~inx.synthGroup.run;
~synths = ();
//{Synth(\gendy)}!30
{
//fx_______
0.2.wait;
~fxGroup = Group(~inx.synthGroup, \addToTail);
~fxGroup.run(false);
0.2.wait;
~fx = Synth(\tank, [\inBus, ~inx.mixInputID], target: ~fxGroup);
~inx.listen(\cursors)
}.fork;
c = 0;
~inx.globalActions[\cursors] = {|args|
var cursor_id, cursor_value_x, cursor_value_y;
#cursor_id, cursor_value_x, cursor_value_y = args; //messages sent by Iannix.app cursors
if ((~synths[cursor_id].isNil) && (c < ~maxSynths)) //auto creation of synths, based on existing ID in ~Inx, + cpu protection
{c = c+1; ~synths[cursor_id] = Synth(\gendy, target: ~inx.synthGroup); ~inx.synthGroup.set(\vol, -10.dbamp) };
~synths[cursor_id].set( \freq, cursor_value_y.linexp(0, 1, 100, 800), \pan, cursor_value_y*2-1 );
}; //can be redefined while playing...
~inx.listen(\cursors);
)
//3: playing...
//on/off LISTENING Iannix osc messages and sending back play/stop to it
//(evaluate each line separately):
~inx.play(0.4);
~inx.fadeTime_(0.5, 1);
~inx.stop;
~inx.fastrewind; //must be done twice here...
~inx.play(0.1);
~inx.speed_(-0.3) // specific speed command (negative value: reverse )
~inx.speed_(10) // another one
//_________________________________________________________________________
//______________________________________________________________________
//VOLUME
~inx.synthGroup.set(\vol, -10.dbamp)
s.meter;
/////
(//some settings for the synths and fx...
//(evaluate each line separately):
~inx.synthGroup.set(\detune, 3); //in semitones
~inx.synthGroup.set(\detune, 0.1); //wooow, back to normal!
~inx.synthGroup.set(\vol, 1/10);
~fxGroup.run; ~fx.set(\mixFx, 0.3, \feedback, 0.3, \inBus, ~inx.mixInputID) //fx ON
~fxGroup.run(false); //fx OFF
)
~inx.objects.postcs;"";
//everything has an end...
(
~inx.stop;
~inx.removeAll;
)