Add inputs and outputs
Audio, sidechain, MIDI, and modulation plugs.Declare plugs in describe. As many as you want. Full list in the ports
reference.
Audio
m.addPort(audioIn("In", 2)); // 2 = stereo
m.addPort(audioOut("Out", 2));Loop over the live channel count so it works in mono or surround too:
for (let i = 0; i < ctx.n; i++) {
for (let ch = 0; ch < ctx.inChannels(); ch++) {
ctx.output(ch, i, ctx.input(ch, i));
}
}Sidechain
A second audio input you listen to but don't pass through, like the kick that ducks a pad. Declare it after the main input and read it from the channels that follow:
m.addPort(audioIn("In", 2));
m.addPort(sidechainIn("SC", 2));
m.addPort(audioOut("Out", 2));Notes and modulation
midiIn("MIDI")/midiOut("MIDI"): see Emit MIDI.modulationOut("Mod"): see Be a modulation source.