Here’s an Engine script for a 3-channel (Kick/Snare/Hat) MiPlaits drum kit.
Engine_BEPlaits : CroneEngine {
var <kick;
var <snare;
var <hat;
*new { arg context, doneCallback;
^super.new(context, doneCallback);
}
alloc {
//////////////////
// DEFINE SYNTH //
//////////////////
SynthDef(\MiPlaits, {
arg out, pitch=60.0, eng=0, harm=0.1, timbre=0.5, morph=0.5, trigger=0.0, level=0, fm_mod=0.0, timb_mod=0.0, morph_mod=0.0, decay=0.5, lpg_colour=0.5, model=0.0, mul=1.0;
var sound, primarySound, auxSound, mixed;
sound = MiPlaits.ar(pitch,eng,harm,timbre,morph,trigger,level,fm_mod,timb_mod,morph_mod,lpg_colour,1.0);
primarySound = sound[0] * mul;
auxSound = sound[1] * mul;
mixed = XFade2.ar(primarySound,auxSound,model);
Out.ar(out, [mixed, mixed]);
}).add;
context.server.sync;
////////////////
// Kick Synth //
////////////////
kick = Synth.new(\MiPlaits, [
\out, context.out_b.index,
\pitch, 60.0,
\eng, 13,
\harm, 0.1,
\timbre, 0.5,
\morph, 0.5,
\trigger, 0,
\level, 1,
\fm_mod, 0.0,
\timb_mod, 0.0,
\morph_mod, 0.0,
\decay, 0.5,
\lpg_colour, 0.5,
\mul, 0.6
],
context.xg);
// Kick Commands
this.addCommand("trig_kick", "f", {|msg|
kick.set(\trigger, 1);
kick.set(\level, msg[1]);
SystemClock.sched(0.01, {
kick.set(\trigger, 0);
});
});
this.addCommand("pitch_kick", "i", {|msg|
kick.set(\pitch, msg[1]);
});
this.addCommand("harm_kick", "f", {|msg|
kick.set(\harm, msg[1]);
});
this.addCommand("timbre_kick", "f", {|msg|
kick.set(\timbre, msg[1]);
});
this.addCommand("morph_kick", "f", {|msg|
kick.set(\morph, msg[1]);
});
this.addCommand("model_kick", "f", {|msg|
kick.set(\model, (msg[1]*2)-1);
});
this.addCommand("level_kick", "f", {|msg|
kick.set(\mul, msg[1]);
});
/////////////////
// Snare Synth //
/////////////////
snare = Synth.new(\MiPlaits, [
\out, context.out_b.index,
\pitch, 60.0,
\eng, 14,
\harm, 0.1,
\timbre, 0.5,
\morph, 0.5,
\trigger, 0,
\level, 0,
\fm_mod, 0.0,
\timb_mod, 0.0,
\morph_mod, 0.0,
\decay, 0.5,
\lpg_colour, 0.5,
\mul, 1.0
],
context.xg);
// Snare Commands
this.addCommand("trig_snare", "f", {|msg|
snare.set(\trigger, 1);
snare.set(\level, msg[1]);
SystemClock.sched(0.01, {
snare.set(\trigger, 0);
});
});
this.addCommand("pitch_snare", "i", {|msg|
snare.set(\pitch, msg[1]);
});
this.addCommand("harm_snare", "f", {|msg|
snare.set(\harm, msg[1]);
});
this.addCommand("timbre_snare", "f", {|msg|
snare.set(\timbre, msg[1]);
});
this.addCommand("morph_snare", "f", {|msg|
snare.set(\morph, msg[1]);
});
this.addCommand("model_snare", "f", {|msg|
snare.set(\model, (msg[1]*2)-1);
});
this.addCommand("level_snare", "f", {|msg|
snare.set(\mul, msg[1]);
});
///////////////
// Hat Synth //
///////////////
hat = Synth.new(\MiPlaits, [
\out, context.out_b.index,
\pitch, 60.0,
\eng, 15,
\harm, 0.1,
\timbre, 0.5,
\morph, 0.5,
\trigger, 0,
\level, 0,
\fm_mod, 0.0,
\timb_mod, 0.0,
\morph_mod, 0.0,
\decay, 0.5,
\lpg_colour, 0.5,
\mul, 0.6
],
context.xg);
// Hat Commands
this.addCommand("trig_hat", "f", {|msg|
hat.set(\trigger, 1);
hat.set(\level, msg[1]);
SystemClock.sched(0.01, {
hat.set(\trigger, 0);
});
});
this.addCommand("pitch_hat", "i", {|msg|
hat.set(\pitch, msg[1]);
});
this.addCommand("harm_hat", "f", {|msg|
hat.set(\harm, msg[1]);
});
this.addCommand("timbre_hat", "f", {|msg|
hat.set(\timbre, msg[1]);
});
this.addCommand("morph_hat", "f", {|msg|
hat.set(\morph, msg[1]);
});
this.addCommand("model_hat", "f", {|msg|
hat.set(\model, (msg[1]*2)-1);
});
this.addCommand("level_hat", "f", {|msg|
hat.set(\mul, msg[1]);
});
}
free {
kick.free;
snare.free;
hat.free;
}
}
And the params definitions to control it.
Note “model” parameter crossfades between the two MiPlaits outputs. If you want, you could just pass the engine 0 or 1 to switch between them.
I might experiment with ControlSpec presets for the Pitch param (does that show the MIDI note # in the params list?).
----------------------
-- Drum Edit Params --
----------------------
params:add_separator("drum edit")
params:add_control("bdp1","bassdrum pitch",ControlSpec.new(0,127,'lin',1,32))
params:set_action( "bdp1", function(x) engine.pitch_kick(x) end)
params:add_control("bdp2","bassdrum harmonics",ControlSpec.new(0,1,'lin',0,0.1))
params:set_action( "bdp2", function(x) engine.harm_kick(x) end)
params:add_control("bdp3","bassdrum timbre",ControlSpec.new(0,1,'lin',0,0.5))
params:set_action( "bdp3", function(x) engine.timbre_kick(x) end)
params:add_control("bdp4","bassdrum morph",ControlSpec.new(0,1,'lin',0,0.5))
params:set_action( "bdp4", function(x) engine.morph_kick(x) end)
params:add_control("bdp5","bassdrum model",ControlSpec.new(0,1,'lin',0,0))
params:set_action( "bdp5", function(x) engine.model_kick(x) end)
params:add_control("bdlvl","bassdrum level",ControlSpec.new(0,1,'lin',0,0.6))
params:set_action( "bdlvl", function(x) engine.level_kick(x) end)
params:add_separator()
params:add_control("sdp1","snaredrum pitch",ControlSpec.new(0,127,'lin',1,32))
params:set_action( "sdp1", function(x) engine.pitch_snare(x) end)
params:add_control("sdp2","snaredrum harmonics",ControlSpec.new(0,1,'lin',0,0.1))
params:set_action( "sdp2", function(x) engine.harm_snare(x) end)
params:add_control("sdp3","snaredrum timbre",ControlSpec.new(0,1,'lin',0,0.5))
params:set_action( "sdp3", function(x) engine.timbre_snare(x) end)
params:add_control("sdp4","snaredrum morph",ControlSpec.new(0,1,'lin',0,0.5))
params:set_action( "sdp4", function(x) engine.morph_snare(x) end)
params:add_control("sdp5","snaredrum model",ControlSpec.new(0,1,'lin',0,0))
params:set_action( "sdp5", function(x) engine.model_snare(x) end)
params:add_control("sdlvl","snaredrum level",ControlSpec.new(0,1,'lin',0,1))
params:set_action( "sdlvl", function(x) engine.level_snare(x) end)
params:add_separator()
params:add_control("hhp1","hat pitch",ControlSpec.new(0,127,'lin',1,32))
params:set_action( "hhp1", function(x) engine.pitch_hat(x) end)
params:add_control("hhp2","hat harmonics",ControlSpec.new(0,1,'lin',0,0.1))
params:set_action( "hhp2", function(x) engine.harm_hat(x) end)
params:add_control("hhp3","hat timbre",ControlSpec.new(0,1,'lin',0,0.5))
params:set_action( "hhp3", function(x) engine.timbre_hat(x) end)
params:add_control("hhp4","hat morph",ControlSpec.new(0,1,'lin',0,0.5))
params:set_action( "hhp4", function(x) engine.morph_hat(x) end)
params:add_control("hhp5","hat model",ControlSpec.new(0,1,'lin',0,0))
params:set_action( "hhp5", function(x) engine.model_hat(x) end)
params:add_control("hhlvl","hat level",ControlSpec.new(0,1,'lin',0,0.75))
params:set_action( "hhlvl", function(x) engine.level_hat(x) end)
Might be useful to someone.