HrWrapSynth a general purpose SynthDef wrapper for Hadron
Inherits from: Object : HadronPlugin
This Hadron plugin is shipped with the Hadron distribution. Hadron plugins are not meant for instantiating by hand in code, they are used internally by the Hadron system.
This plugin is a SynthDef wrapper, that reads the metadata of the SynthDef from SynthDescLib.default, builds a GUI for it and handles its connections within the Hadron system.
Arguments: Takes the name of the SynthDef as an argument.
Requirements:
For the plugin to understand the desired inputs and outputs for your synthdef, you should follow a naming guideline. The input busses should be supplied as arguments and named as inBus[n] where [n] is the bus index that starts from 0. Similarly, for your output busses, you should supply the arguments in outBus[n] format. All indexes start from 0, and you should NOT skip an index.
Bad: arg inputBus1, inputBus2, output1, output2;
Bad: arg inBus1, inBus3, outBus0, outBus2;
Good: arg inBus0, inBus1, outBus0, outBus1;
For the automatic GUI creation to work, you should fill the specs event with specs, relevant to your control arguments in your SynthDef. For more info see: ControlSpec
To see how the metadata and specs scheme work in detail, see the relevant sections in the help files for SynthDesc and SynthDef.
To register your SynthDef controls on SynthDescLib, you MUST use SynthDef.memStore or SynthDef.store when sending your SynthDef to server (instead of .send or .load).
Examples:
This is a sine oscillator synth with two outputs:
s.boot; //remember to boot before .memStore
(
SynthDef(\sineOsc,
{
arg outBus0, outBus1, freq;
var sound = SinOsc.ar([freq, freq+10], 0, 0.2);
Out.ar(outBus0, sound[0]);
Out.ar(outBus1, sound[1]);
},
metadata:
(
specs:
(
freq: [80, 880, \exponential, 1, 220].asSpec;
)
)).memStore;
)
Now launch Hadron:
Hadron.new;
Now create a HrWrapSynth instance with the argument sineOsc:
(right click on the canvas)
HrWrapSynth sineOsc
You should see the auto-generated GUI now, with 2 outputs (outBus0, outBus1). Connect this instance to a HrDAC and you should be able to hear the sine tones.
The specs entry in metadata is used as a reference for the generated GUI. Here is a more complicated SynthDef:
(
SynthDef(\karplusPipe,
{
arg outBus0, outBus1, freq, pressure, angle, whistle, knack;
var generator, envelope, delCompensate, delTime, fed, inloop, finOut;
delCompensate = Server.default.options.blockSize / SampleRate.ir();
delTime = freq.reciprocal - delCompensate;
fed = LeakDC.ar(LocalIn.ar(1));
envelope = EnvGen.ar(Env([0, 1, 0.8], [0.3, 1], -5), 1);
generator =
(
LPF.ar(WhiteNoise.ar(0.5), freq * knack) * envelope) +
(envelope + (fed * whistle)
);
inloop = LPF.ar(HPF.ar(generator, angle + freq), pressure + freq);
LocalOut.ar(DelayC.ar(inloop, 1, delTime.lag(2)).distort);
finOut = Limiter.ar(inloop);
Out.ar(outBus0, finOut);
Out.ar(outBus1, finOut);
},
metadata:
(
specs:
(
freq: [15, 680, 'exponential', 1, 220].asSpec,
pressure: [20, 20000, 'exponential', 0, 2500].asSpec,
angle: [20, 20000, 'exponential', 0, 120].asSpec,
whistle: [1, 3, 'linear', 0.01, 1.2].asSpec,
knack: [0.1, 10, 'linear', 0.1, 4.5].asSpec
)
)
).memStore;
)
As you can see, we provided a spec for each argument. After sending this to server, create a HrWrapSynth with the argument karplusPipe and you should see the auto-generated GUI and the instance with 2 outputs.
Modulatable parameters: All controls can be modulated.
Inputs: Defined by user in the SynthDef.
Outputs: Defined by user in the SynthDef.
The slider controls in the auto-generated GUIs use the HrSlider widget which is midi aware and automatable. For details, see the help file for HrSlider.
See also: HrDAC HrADC HrFreeVerb HrStereoMixer HrStereoSplitter HrSimpleModulator HrDIYSynth