BTW VSTPlugin’s setup is not that complicated in the end, but if you haven’t used it before, sorting out the commands you need can take some effort.
So here’s a quick example for sfizz.
s.boot;
// only once, before first use
// the search will be cached,
// don't need to repeat it unless you install more plug-ins
VSTPlugin.search;
// ... wait for scan (can take awhile...)
(
SynthDef(\vstInst, { |out = 0|
Out.ar(0, VSTPlugin.ar(numOut: 2));
}).add;
)
a = Synth(\vstInst);
c = VSTPluginController(a);
c.open("sfizz.vst3", editor: true);
c.editor;
// GUI opens -- choose the sfz file for your piano
// save a preset so you can recover without GUI next time
c.writeProgram("~/piano.vstpreset".standardizePath);
c.close;
a.free;
// now, when you need to just play it
(
a = Synth(\vstInst);
c = VSTPluginController(a);
c.open("sfizz.vst3", action: { |vstctl, success|
if(success) {
c.readProgram("~/piano.vstpreset".standardizePath, { |vstctl, success|
if(success) {
"OK, ready!".postln
} {
"Couldn't read preset".warn;
};
})
} {
"Couldn't open VST plugin".warn;
};
});
)
m = c.midi;
// fake Milton Babbitt
(
p = Pbind(
\type, \midi,
\midiout, m,
\midinote, Pwhite(36, 84, inf),
\dur, Pexprand(0.1, 0.4, inf),
\legato, Pexprand(0.2, 6, inf),
\amp, Pwhite(0.2, 0.8, inf)
).play;
)
p.stop;
a.free;
For the quick example, I just saved the preset file in the home directory. In practice, I would save it in the same location as the scd file, and specify the path as thisProcess.nowExecutingPath.dirname +/+ "piano.vstpreset"
. (Keeping all the resources together is simpler for project maintenance.)
hjh