Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Simple wrapper class for VSTPlugin
name
code content
/////////////////////////////// // To use: // Install VSTPlugin // available here: https://git.iem.at/pd/vstplugin/-/releases // Create a NodeProxy as a sound source for testing ( Ndef(\sine, { var sig = SinOsc.ar(440); var env = Decay2.kr(Impulse.kr(0.5)); Splay.ar(sig) * env * 0.1; }) ) // display discovered keys Vst(\delay1).keys.do({arg k; k.postln;}); // load a vst by key or path Vst(\delay1).load('/Library/Audio/Plug-Ins/VST/ValhallaDelay'); // route the test sound source to the internal node proxy Vst(\delay1).node.source = Ndef(\sine); // monitor the vst with fade in Vst(\delay1).node.play(fadeTime:4); // view the editor if enabled (see PR-4499 for mac) Vst(\delay1).editor; // view the default gui Vst(\delay1).gui; // toggle bypass: 1 or 0 Vst(\delay1).bypass(1); // stop monitoring the vst with fade out Vst(\delay1).node.stop(fadeTime:4); // since the vst is output through a node proxy // it can be further routed as a regular node proxy ( Ndef(\fx, { var in = \in.ar([0, 0]); PitchShift.ar(in, 0.2, 2, 0.01, 0.01); }); ) Ndef(\fx) <<> Vst(\delay1).node; Ndef(\fx).play; /////////////////////////////// // copy the below code to SC extensions folder // e.g. ~/Library/Application Support/SuperCollider/Extensions Vst { classvar <all; var <key; var <outergrouop, <innergroup, <vstgroup; var <vstctrl, <node, <synth; var func; *new {arg key; var res = all[key]; if (res.isNil) { res = super.new.prInit(key); all.put(key, res); }; ^res; } prInit {arg inKey; key = inKey; ^this; } load {arg name; func = { Routine({ var inbus; SynthDef.new(key, { var in = \in.kr(0); var bypass = \bypass.kr(0); var sig = VSTPlugin.ar(input:In.ar(in, 2), numOut:2, bypass:bypass, id:key) * \amp.kr(1); ReplaceOut.ar(\in.kr(0), sig); }).add; Server.default.sync; outergrouop = Group.new(Server.default).debug(\outergroup); innergroup = Group.new(outergrouop).debug(\innergroup); if (node.isNil) { // TODO: still have to reset the source // after cmdperiod in order for sound to contine // but i'm not sure why "initialize nodeproxy".postln; node = NodeProxy.audio(Server.default, 2); }; node.group_(innergroup);//.play; inbus = node.bus; vstgroup = Group.new(target:node.group.debug(\node), addAction:\addAfter); synth = Synth(key, [in: inbus], target:vstgroup.debug(\fx), addAction:\addToTail); vstctrl = VSTPluginController(synth, key); vstctrl.open(name, editor:true); }).play; }; func.value; // TODO: is this the right way to do this? CmdPeriod.add(func); } bypass {arg bypass=0; synth.set(\bypass, bypass) } set {arg key, val; vstctrl.set(key, val) } map {arg key, val; vstctrl.map(key, val) } get {arg key, cb={arg v; v.postln;}; vstctrl.get(key, cb); } editor { vstctrl.editor; } gui { vstctrl.gui; } keys { var result = List.new; VSTPlugin.search(verbose:false); VSTPlugin.readPlugins.keysValuesDo({arg k, v; result.add(k)}); ^result.asArray; } free { synth.free; vstgroup.free; innergroup.free; outergrouop.free; node.clear; CmdPeriod.remove(func); } *initClass { all = (); } }
code description
This is a class to streamline some of the boilerplate code for wiring up the VSTPlugin extension. It is intended to make using VSTPlugin with a NodeProxy somewhat easier. It's only been tested on a Mac with develop branch build of SuperCollider with PR-4499 merged.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change