You are on page 1of 7

// WazMatrix Mixer V.

1
// by scacinto

Server.local.options.numInputBusChannels = 2;
Server.local.options.numOutputBusChannels = 20;
s.boot;
(
//******************************************************************
// the groups
//******************************************************************
~feedback = Group.new;
~input = Group.new(~feedback, \addAfter);
~mixer = Group.new(~input, \addAfter);
~processing = Group.new(~mixer, \addAfter);
~master = Group.new(~processing, \addAfter);

//******************************************************************
// the synthdefs
//******************************************************************
// ** inFeedback
SynthDef("feedback1", {
var in = InFeedback.ar(17);
in = LeakDC.ar(in);
Out.ar(3, in);
}).add;
SynthDef("feedback2", {
var in = InFeedback.ar(18);
in = LeakDC.ar(in);
Out.ar(4, in);
}).add;
SynthDef("feedback3", {
var in = InFeedback.ar(19);
in = LeakDC.ar(in);
Out.ar(5, in);
}).add;
// **
SynthDef("in1Src", {arg source=0, amp=0;
var a = [SoundIn.ar(0), SinOsc.ar(LFNoise1.kr(1, 25, 440))];
Out.ar(11, Select.ar(source,a) * amp);
}).add;
SynthDef("in2Src", {arg source=0, amp=0;
var a = [SoundIn.ar(0), SinOsc.ar(LFNoise1.kr(1, 90, 1394))];
OffsetOut.ar(12, Select.ar(source,a) * amp);
}).add;
SynthDef("in3Src", {arg source=0, amp=0;
var a = [SoundIn.ar(0), SinOsc.ar(LFNoise1.kr(1, 60, 1394))];
OffsetOut.ar(13, Select.ar(source,a) * amp);
}).add;

// ** MASTER OUT
SynthDef("masterMixer", {

var outa, outb, outc, sound;
// outputA synth
outa = In.ar(17, 1);
// outputB synth
outb = In.ar(18, 1);
//outputC synth
outc = In.ar(19, 1);
sound = Limiter.ar([outa, outb, outc], 0.5);
sound = LeakDC.ar(sound);
Out.ar(0, sound);
}).add;
// ** CHANNEL MIXERS
SynthDef("input1Mixer", {arg amp = 0, inA=0, inB=0, inC=0, outA=0, outB=0, outC=0;
var in1Src, sound, in1A, in1B, in1C, mix, out1, out2, out3;
// input1 synth
in1Src = In.ar(11,1);
in1A = In.ar(3, 1);
in1B = In.ar(4, 1);
in1C = In.ar(5, 1);
in1A = in1A * inA;
in1B = in1B * inB;
in1C = in1C * inC;
mix = Mix([in1Src, in1A, in1B, in1C]).clip;
out1 = Out.ar(14, mix * outA);
out2 = Out.ar(15, mix * outB);
out3 = Out.ar(16, mix * outC);
}).add;

SynthDef("input2Mixer", {arg amp = 0, inA=0, inB=0, inC=0, outA=0, outB=0, outC=0;
var in2Src, in2A, in2B, in2C, mix, sound, out1, out2, out3;
// input1 synth
in2Src = In.ar(12,1);
in2A = In.ar(3, 1);
in2B = In.ar(4, 1);
in2C = In.ar(5, 1);
in2A = in2A * inA;
in2B = in2B * inB;
in2C = in2C * inC;
mix = Mix([in2Src, in2A, in2B, in2C]).clip;

out1 = Out.ar(14, mix * outA);
out2 = Out.ar(15, mix * outB);
out3 = Out.ar(16, mix * outC);
}).add;

SynthDef("input3Mixer", {arg amp = 0, inA=0, inB=0, inC=0, outA=0, outB=0, outC=0;
var in3Src, in3A, in3B, in3C, mix, sound, out1, out2, out3;
// input1 synth

in3Src = In.ar(13,1);
in3A = In.ar(3, 1);
in3B = In.ar(4, 1);
in3C = In.ar(5, 1);
in3A = in3A * inA;
in3B = in3B * inB;
in3C = in3C * inC;

mix = Mix([in3Src, in3A, in3B, in3C]).clip;
out1 = Out.ar(14, mix * outA);
out2 = Out.ar(15, mix * outB);
out3 = Out.ar(16, mix * outC);
}).add;
//** PROCESSORS
SynthDef("processA", {
var in, sound;
in = In.ar(14,1);
sound = DelayC.ar(in, 3, MouseY.kr(0.1,3), MouseX.kr(1,10));
Out.ar(17, sound.tan);
}).add;
SynthDef("processB", {
var in, sound;
in = In.ar(15,1);
sound = DelayC.ar(in, 3, MouseY.kr(0.1,3), MouseX.kr(1,10));
Out.ar(18, sound.tan);
}).add;
SynthDef("processC", {
var in, sound;
in = In.ar(16,1);
sound = DelayC.ar(in, 3, MouseY.kr(0.1,3), MouseX.kr(1,10));
Out.ar(19, sound.tan);
}).add;
//******************************************************************
// Create the Synths and add to groups
//******************************************************************
~feedBckSyn1 = Synth("feedback1", target:~feedback);
~feedBckSyn2 = Synth("feedback2", target:~feedback);
~feedBckSyn3 = Synth("feedback3", target:~feedback);
~input1Mixer = Synth(\input1Mixer, target: ~mixer);
~input2Mixer = Synth(\input2Mixer, target: ~mixer);
~input3Mixer = Synth(\input3Mixer, target: ~mixer);
~processA = Synth(\processA, target: ~processing);
~processB = Synth(\processB, target: ~processing);
~processC = Synth(\processC, target: ~processing);
~masterMixer = Synth(\masterMixer, target: ~master);
)
(
//******************************************************************
// GUI

//******************************************************************
var input1, input2, input3, output1, output2, output3, outL, outR;
var fader1, fader2, fader3, fader4, fader5, fader6, fader7, fader8, fader9;
var window = Window.new("",Rect(168, 275, 584, 581));

StaticText.new(window,Rect(30, 30, 500, 38))
.string_("WazMatrixMixer V.1")
.font_(Font("Arial", 40))
.action_{|v|};
//******************************************************************
// buttons
//******************************************************************

// ~in1Src button - mic and noise
Button.new(window,Rect(11, 89, 79, 20))
.states_([ [ "off", Color(0.75, 0.75, 0.75, 1.0), Color.black(0.5,0.5)],["noise", Color(0.0,
0.0, 0.0, 1.0), Color.red(0.7,0.5) ], [ "mic", Color(1.0, 1.0, 1.0, 1.0), Color.blue(0.7, 0.5) ] ])
.action_{|v|
case {v.value == 0 && ~in1Src.notNil } { ~in1Src.free; currentEnvironment.removeAt(\in1Src) }
{ v. value == 1 } { ~in1Src = Synth("in1Src", [\source, 1], target: ~input) }
{ v. value == 2 } { ~in1Src.set(\source, 0) }
};
// ~in2Src button - mic and noise
Button.new(window,Rect(11, 209, 79, 20))
.states_([ [ "off", Color(0.75, 0.75, 0.75, 1.0), Color.black(0.5,0.5)],["noise", Color(0.0,
0.0, 0.0, 1.0), Color.red(0.7,0.5) ], [ "mic", Color(1.0, 1.0, 1.0, 1.0), Color.blue(0.7, 0.5) ] ])
.action_{|v|
case {v.value == 0 && ~in2Src.notNil } { ~in2Src.free; currentEnvironment.removeAt(\in2Src) }
{ v. value == 1 } { ~in2Src = Synth("in2Src", [\source, 1], target: ~input) }
{ v. value == 2 } { ~in2Src.set(\source, 0) }
};
// ~in3Src button - mic and noise
Button.new(window,Rect(11, 329, 79, 20))
.states_([ [ "off", Color(0.75, 0.75, 0.75, 1.0), Color.black(0.5,0.5)],["noise", Color(0.0,
0.0, 0.0, 1.0), Color.red(0.7,0.5) ], [ "mic", Color(1.0, 1.0, 1.0, 1.0), Color.blue(0.7, 0.5) ] ])
.action_{|v|
case {v.value == 0 && ~in3Src.notNil } { ~in3Src.free; currentEnvironment.removeAt(\in3Src) }
{ v. value == 1 } { ~in3Src = Synth("in3Src", [\source, 1], target: ~input) }
{ v. value == 2 } { ~in3Src.set(\source, 0) }
};

//******************************************************************
//** CONTROLSPECS
//******************************************************************

// ROW1 Knobs
~in1SrcKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in1OutAKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in1OutBKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in1OutCKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in1InAKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in1InBKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in1InCKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");

// ROW2
~in2SrcKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in2OutAKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in2OutBKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in2OutCKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in2InAKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in2InBKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in2InCKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
// ROW3
~in3SrcKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in3OutAKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in3OutBKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in3OutCKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in3InAKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in3InBKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");
~in3InCKnbCtl = ControlSpec(0.0, 1, 'linear', 0.01, 0, "dB");

//******************************************************************
//** KNOBS
//******************************************************************

//** row 1
// input1 vol
Knob.new(window,Rect(30, 130, 40, 35))
.color_([Color.red(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3), Color.black.alpha_
(0.7)])
.action_{|v| v = ~in1SrcKnbCtl.map(v.value);
if ( ~in1Src.notNil, { ~in1Src.set(\amp, v)});
};
// inA-C
Knob.new(window,Rect(110, 130, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in1InAKnbCtl.map(v.value);
~input1Mixer.set(\inA, v);
};
Knob.new(window,Rect(190, 130, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in1InBKnbCtl.map(v.value).postln;
~input1Mixer.set(\inB, v);
};
Knob.new(window,Rect(270, 130, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])

.action_{|v| v = ~in1InCKnbCtl.map(v.value);
~input1Mixer.set(\inC, v);
};
// OutA-C
Knob.new(window,Rect(350, 130, 40, 35))
.action_{|v| v = ~in1OutAKnbCtl.map(v.value);
~input1Mixer.set(\outA, v);
};
Knob.new(window,Rect(430, 130, 40, 35))
.action_{|v| v = ~in1OutBKnbCtl.map(v.value);
~input1Mixer.set(\outB, v);
};
Knob.new(window,Rect(510, 130, 40, 35))
.action_{|v| v = ~in1OutCKnbCtl.map(v.value);
~input1Mixer.set(\outC, v);
};
//** row 2
Knob.new(window,Rect(30, 250, 40, 35))
.color_([Color.red(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3), Color.black.alpha_
(0.7)])
.action_{|v| v = ~in2SrcKnbCtl.map(v.value).postln;
if ( ~in2Src.notNil, { ~in2Src.set(\amp, v)});
};
Knob.new(window,Rect(110, 250, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in2InAKnbCtl.map(v.value);
~input2Mixer.set(\inA, v);
};
Knob.new(window,Rect(190, 250, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in2InBKnbCtl.map(v.value);
~input2Mixer.set(\inB, v);
};
Knob.new(window,Rect(270, 250, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in2InCKnbCtl.map(v.value);
~input2Mixer.set(\inC, v);
};
Knob.new(window,Rect(350, 250, 40, 35))
.action_{|v| v = ~in2OutAKnbCtl.map(v.value).postln;
~input2Mixer.set(\outA, v);
};
Knob.new(window,Rect(430, 250, 40, 35))
.action_{|v| v = ~in2OutBKnbCtl.map(v.value).postln;
~input2Mixer.set(\outB, v);
};
Knob.new(window,Rect(510, 250, 40, 35))
.action_{|v| v = ~in2OutCKnbCtl.map(v.value).postln;
~input2Mixer.set(\outC, v);
};
//** row 3
Knob.new(window,Rect(30, 370, 40, 35))

.color_([Color.red(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3), Color.black.alpha_
(0.7)])
.action_{|v| v = ~in3SrcKnbCtl.map(v.value).postln;
if ( ~in3Src.notNil, { ~in3Src.set(\amp, v)});
};
Knob.new(window,Rect(110, 370, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in3InAKnbCtl.map(v.value);
~input3Mixer.set(\inA, v);
};
Knob.new(window,Rect(190, 370, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in3InBKnbCtl.map(v.value);
~input3Mixer.set(\inB, v);
};
Knob.new(window,Rect(270, 370, 40, 35))
.color_([Color.yellow(0.7,0.5), Color.green(0.8,0.8), Color.black.alpha_(0.3),
Color.black.alpha_(0.7)])
.action_{|v| v = ~in3InCKnbCtl.map(v.value);
~input3Mixer.set(\inC, v);
};
Knob.new(window,Rect(350, 370, 40, 35))
.action_{|v| v = ~in3OutAKnbCtl.map(v.value).postln;
~input3Mixer.set(\outA, v);
};
Knob.new(window,Rect(430, 370, 40, 35))
.action_{|v| v = ~in3OutBKnbCtl.map(v.value).postln;
~input3Mixer.set(\outB, v);
};
Knob.new(window,Rect(510, 370, 40, 35))
.action_{|v| v = ~in3OutCKnbCtl.map(v.value).postln;
~input3Mixer.set(\outC, v);
};
window.onClose_({
currentEnvironment.clear;
s.freeAll;
});
window.front;
)