miditest
A method of Instr and SynthDef allowing quick-and-dirty testing of a synth using your midi keyboard. It makes a 20-node voicer, plugs it into a VoicerMIDISocket, creates global controls (see Voicer) for all arguments except freq, gate and outbus which will appear in a GUI window and can be controlled by the mouse. If your MIDI controller has enough continuous controls (I'm using a Novation ReMOTE 25 with 8 knobs, 8 encoders and 8 sliders), each argument will be MIDI-controllable as well. A button on the GUI closes the test, printing a list of arguments and their last settings.
The usage is slightly different depending on whether you're using Instr or SynthDef. See below for more details.
hjh, jamshark70@dewdrop-world.net
Instr-miditest(channel, initArgs, target, bus)
channel: The midi channel your keyboard is sending on. May be specified as [port#, channel#] or simply [port#] for channel 0 on that port. Nil will give you port 0, channel 0.
initArgs: Initial arguments, which should be in the Voicer format: [name1, arg1, name2, arg2...]—more like Synth or Set than like Patch. Fixed arguments like envelopes should be specified here.
target: Where you want the synths to be placed.
bus: The bus you want them to play on.
If target and bus are not specified, Server.local's RootNode will be used, along with the default audio outs.
(
i = Instr([\test, \miditest], {
arg freq = 440, gate = 0, env, pb = 1, ffreq = 1000, rq = 1;
var out, amp;
amp = Latch.kr(gate, gate);
out = EnvGen.kr(env, gate, doneAction:2) *
RLPF.ar(Pulse.ar(freq * pb, 0.25, amp), ffreq, rq);
[out,out]
}, [\freq, \amp, nil, nil, \freq, \rq])
.miditest(nil, [\env, Env.adsr(0, 0.05, 0.5, 1), \ffreq, 1500]);
)
Note that pb will automatically use the MIDI controller's pitch bend wheel, if you have CCAllocator set up properly. See the CCAllocator help file.
miditest will pull specs for the GUI sliders from the instrument definition, so be sure to specify them in the Instr.
SynthDef-miditest(channel, specs, target, bus)
Because SynthDef does not include specs in its definition, you must supply them here if you want the GUI to work right.
(
SynthDef("sd-miditest", { arg outbus = 0, freq, gate, amp, pb=1;
Out.ar(outbus, SinOsc.ar(freq*pb, mul:amp) * EnvGen.kr(Env.adsr, gate, doneAction:2))
}).miditest(nil, [nil, nil, nil, [0, 1, \linear, 0, 0.5]]);
)
Note that the first 3 arguments have a nil spec because they will not be reflected on the GUI. Freq and gate will be different for every node, so it makes no sense to show a global value for the whole voicer. Also, the pitch bend spec is not provided because it will be constructed by miditest. Initial values for the arguments should be supplied as the "default" value in the spec.