(
//PUT HERE THE NUMBER OF POLYPHONY VOICES
var nbVoices = 16;

//PUT HERE THE PATH TO THE JUCE VST3 PLUGIN
var vst3Path = "Users/thomas/Desktop/MOscilloscope.vst3";


// LFO Synth
~lfo = Synth(\lfo, [\out, ~lfoBus.index]);


// Synth array for voice allocation
~synths = Array.fill(nbVoices, {
    Synth(\rgbSynth, [\out, ~bus, \lfoBus, ~lfoBus.index], target: ~synthGroup, addAction: \addToTail)
});


// Filter envelope
~filterEnv = Synth(\filterEnv, [\out, ~filterEnvBus.index]);


// Array to keep in memory active synths (i.e. active notes)
~activeNotes = Array.fill(nbVoices, { nil });


// Function to modify a parameter for all synths
~setSynthsParam = { |param, value|
    ~synths.do { |synth|
        synth.set(param, value);
    };
};


~filter = Synth(\lpf, [
	\in, ~bus,
	\out, ~fxBus,
	\lfoBus, ~lfoBus.index,
	\envBus, ~filterEnvBus.index
], target: ~filterGroup, addAction: \addToTail);


~vst = Synth(\juceVST, [\in, ~fxBus, \out, 0], addAction: \addToTail);


~ctl = VSTPluginController(~vst);

// Open the JUCE plugin as a VST3
~ctl.open(vst3Path, info: true, verbose: true, editor: true);
//~ctl.editor;


"Voice allocation arrays loaded".postln
)


//~setSynthsParam.(\lfoDepth, 0.05);

//~filter.set(\cutoff, 10000, \resonance, 0, \lfoDepth, 2, \envDepth, 0);

//~filterEnv.set(\attack, 0, \decay, 0, \sustain, 0);