77 lines
1.4 KiB
Python
77 lines
1.4 KiB
Python
// A track receiving from a bus. Synth and FX in their own groups
|
|
Track : Fadable {
|
|
/*
|
|
TODO: don't instanciate if name already exist ?
|
|
*/
|
|
var out, <group, <groupFX, <groupSynth, <track, <trackFX, busTrack, busFX, busOut, level;
|
|
|
|
*new {
|
|
|out|
|
|
^super.new.init(out);
|
|
}
|
|
|
|
*initClass {
|
|
StartUp.add {
|
|
SynthDef(\fader, {
|
|
|in, fxIn, out|
|
|
var sig, fx, dry, wet;
|
|
wet = \wet.kr(1);
|
|
// TODO: what if i want 1 or 12 channels
|
|
sig = In.ar(in, 2);
|
|
fx = In.ar(fxIn, 2);
|
|
// FX loop?
|
|
dry = (1 - wet).clip(0, 1);
|
|
sig = [sig * dry, fx * wet].sum;
|
|
sig = Pan2.ar(sig, \pan.kr(0));
|
|
sig = sig * \amp.kr(1);
|
|
sig = Limiter.ar(sig);
|
|
Out.ar(out, sig);
|
|
Out.ar(\monitor.kr(0), sig);
|
|
}).add;
|
|
}
|
|
}
|
|
|
|
init {
|
|
|out|
|
|
level = 1;
|
|
busTrack = Bus.audio(Server.default, 2);
|
|
busFX = Bus.audio(Server.default, 2);
|
|
busOut = Bus.audio(Server.default, 2);
|
|
group = Group.new(Server.default);
|
|
groupSynth = Group.head(group);
|
|
groupFX = Group.after(groupSynth);
|
|
trackFX = Dictionary();
|
|
track = Synth(
|
|
\fader,
|
|
[
|
|
in: busTrack.index,
|
|
fxIn: busFX.index,
|
|
out: out,
|
|
monitor: busOut.index
|
|
],
|
|
target: group,
|
|
addAction: \addToTail
|
|
);
|
|
}
|
|
|
|
in {
|
|
^busTrack.index;
|
|
}
|
|
|
|
inFX {
|
|
^busFX.index;
|
|
}
|
|
|
|
appendFX {
|
|
|fxName, params=#[]|
|
|
var fx;
|
|
fx = Synth.new(fxName, params ++ [in: this.in, out: this.inFX], this.groupFX);
|
|
trackFX.put(fxName, fx);
|
|
}
|
|
|
|
out { ^busOut.index; }
|
|
|
|
// printOn {
|
|
// |stream|
|
|
// }
|
|
} |