NB: these examples work only if you have the associated plugin installed. Remember to issue Rescan Plugins… after installing any new plugins.
Surge XT is a powerful open-source
synthesizer supporting a variety of synthesis techniques. It is also
a leader in the promotion and adopton of the CLAP plugin standard.
As such, it works well with Hz and the combination offers new
potential synergies not available with typical point-and-click DAWs.

Installing Surge XT may also result in the installation of its
effect-only plugin, Surge XT Effects. You can use this plugin
independant of Surge XT to add effects to another synthesized signal.

NB: these examples will only work if you have
Surge XTinstalled on your system.
This example shows you how to create and instantiate a Surge XT Synth anode
and initialize it via a preset (.fxp) file. You can create your own preset
files in Surget XT with its Save Patch menu option
in its Patch Browser. Note that we issue surge.Show() to raise
the GUI window. This causes it to appear in the
Audio Monitor's Window Panel
where you can Show and Hide it manually.
Here's a snippet from the example:
let thisDir = path.dirname(this.GetFilePath());
let id = `f${this.GetId()}:`;
let ascene = await Ascene.BeginFiber(this);
let surge = ascene.NewAnode("Surge XT");
let dac = ascene.GetDAC();
ascene.Chain(surge, dac);
await ascene.Sync();
let preset = path.join(thisDir, "presets/Plucks_Woody.fxp");
console.log(`${id} loading Surge preset ${preset}`);
await surge.LoadPreset(preset);
This example shows you how to programatically save the state of a
running instance of Surge XT. The would presumably be useful
only if you alter its initial state by "munging" its parameters.
For this reason the example creates the Surge XT instance then
waits 30 seconds before issuing SaveState().
snippet
// First resolve the target directory which must already exsit.
let thisDir = path.dirname(this.GetFilePath());
let dnm = await ResolveWSFile(path.join(thisDir, "_saved"));
// Next build a new filename, here with a timestamp for clarity.
let ts = Util.GetFileTimestamp();
let fn = path.join(dnm, `mystate_${ts}.surge`);
console.info(`saving ${fn}`);
let err = await surge.SaveState(fn); // err:{err: 0} = success
console.info(`done err: ${JSON.stringify(err)}`);
This example shows you how to create and instantiate a Surge XT Synth anode
and initialize it via a state (.surge) file. You can create your own state
files in Surget XT via the its Options Menu at top. Note that we issue
surge.Show() to raise the GUI window. This causes it to appear in the
Audio Monitor's Window Panel
where you can Show and Hide it manually.
snippet
let thisDir = path.dirname(this.GetFilePath());
let id = `f${this.GetId()}:`;
let ascene = await Ascene.BeginFiber(this);
let surge = ascene.NewAnode("Surge XT");
let dac = ascene.GetDAC();
ascene.Chain(surge, dac);
await ascene.Sync();
let state = path.join(thisDir, "states/fragile4.surge")
console.log(`${id} loading Surge state ${state}`);
await surge.RestoreState(state);
This example simply dumps the list of all known parameters to the Log Panel. Note that you can also use Plugin Explorer for this.
Note: there are almost 800 parameters here!
In this simple example we automate the 3 Surge parameters.
Examine the Surge XT GUI carefully to observe the effects.
Parameter names can be found as discussed in above.
This example shows how to use Surge XT Effects with another plugin.
It's unclear how to identify oscillator mode-specific parameters.
After loading a preset, it appears that some time is needed prior to invoking SetParam.
Plugin hasn't implemented preset loading to date. You can,
however, use RestoreState() of files saved by the standalone
Surge XT Effects app.
Plugin has an optional Side Chain input that may be
required by some effects (cf Vocoder).
Parameters are generically named ('FX Type', 'FX Parameter *'), so it's not clear how useable
SetParam is.