addEffect to a Synth through scripting
-
I am dealing with many FX's which I need to add to several projects, so I am looking to script this to speed up the process.
I am trying to just add a single Simple Gain to a single Synth "COWBELL" at the moment. This is not doing it:
const var COWBELL = Synth.getChildSynth("COWBELL"); Synth.addEffect("Simple Gain", "PercSimple Gain1", COWBELL);
I get an error:
Interface:! Line 30, column 16: Module with type Simple Gain could not be generated.
What am I doing wrong?
-
@gorangrooves I think the "String type" should be "SimpleGain" no space in-between, and the "index" should be number, in this case (FX) it should be 2
-
@gorangrooves the child synth, doesn't seem to have that function, only the synth
-
@ulrik thank you.
hmmm so I can't really go this route, right? There doesn't seem to be a way to specify to which synth I want to add the FX.
-
@gorangrooves If the order of the effects is the same for each project just do it in one project, open the xml and copy the fx tree to the other projects.
-
@gorangrooves I guess not, I couldn't find any way to do it via scripting.
It's possible to add modulators to a child synth via scripting, I don't know why it not could be implemented for effects as well, maybe it involves a lot of complexity that I know nothing off? -
Alright guys, another installment of "why the hell is this feature not documented better?": Use the Builder class to programmatically build your module tree. I'm using this in a project with lots of duplications and the entire module tree is created with this class so whenever I need to make a change to one of the 12 modules, I'll just change a line of code and recompile.
Be aware that this is a development tool and should not be used in a product to create a dynamic module tree - there are all kinds of stability issues, especially when clearing the module tree and rebuilding it from scratch, so as long as you expect it to crash whenever you call this method, you're in the right mindset :)
// This class is a helper tool to programmatically build up the module tree const var b = Synth.createBuilder(); // Create a sine wave generator. const var s = b.create("SineSynth", "Sine", 0, b.ChainIndexes.Direct); // If the generator already exists, use this function instead of the create function //const var s = b.getExisting("COWBELL"); // Add the simple gain, pass in the reference for the sine synth and the magic number for the FX chain const var g = b.create("SimpleGain", "MyGain", s, b.ChainIndexes.FX); // This needs to be called at the end so it sends a rebuild message to the UI b.flush();
-
@Christoph-Hart there's a lot in your back pocket I assume?
-
@Christoph-Hart Thank you! That's all very new to me.
I can make sense of it all except for one thing.
What's the "ChainIndexes"?
-
@gorangrooves a collection of magic numbers that let you specify in which chain you want to add the modules. For FX it‘s pointless but if you add modulators you can define whether they should be added to gain or pitch modulation.
-
@Christoph-Hart Is there a way to create samplers? I'm trying ModulatorSampler, but no work.
void ModulatorSynthChainFactoryType::fillTypeNameList() { ADD_NAME_TO_TYPELIST(ModulatorSampler); ADD_NAME_TO_TYPELIST(SineSynth); ADD_NAME_TO_TYPELIST(ModulatorSynthChain); ADD_NAME_TO_TYPELIST(GlobalModulatorContainer); ADD_NAME_TO_TYPELIST(WaveSynth); ADD_NAME_TO_TYPELIST(NoiseSynth); ADD_NAME_TO_TYPELIST(WavetableSynth); ADD_NAME_TO_TYPELIST(AudioLooper); ADD_NAME_TO_TYPELIST(ModulatorSynthGroup); ADD_NAME_TO_TYPELIST(JavascriptSynthesiser); ADD_NAME_TO_TYPELIST(MacroModulationSource); ADD_NAME_TO_TYPELIST(SendContainer); ADD_NAME_TO_TYPELIST(SilentSynth); }
-
Found it:
SET_PROCESSOR_NAME("StreamingSampler", "Sampler", "The main sampler class of HISE.");
-
@Christoph-Hart This is sick! Building redundant processes is a breeze now.
// This class is a helper tool to programmatically build up the module tree const var b = Synth.createBuilder(); inline function createDrumSampler(samplerName, samplerNumber) { local sampler = b.create("StreamingSampler", samplerName + "_" + samplerNumber, 0, b.ChainIndexes.Direct); local directGain = b.create("SimpleGain", samplerName + "_" + samplerNumber + "_Direct", sampler, b.ChainIndexes.FX); local monoGain = b.create("SimpleGain", samplerName + "_" + samplerNumber + "_Mono", sampler, b.ChainIndexes.FX); local ohGain = b.create("SimpleGain", samplerName + "_" + samplerNumber + "_OH", sampler, b.ChainIndexes.FX); local roomGain = b.create("SimpleGain", samplerName + "_" + samplerNumber + "_Room", sampler, b.ChainIndexes.FX); return { sampler: sampler, directGain: directGain, monoGain: monoGain, ohGain: ohGain, roomGain: roomGain }; } // Usage example: const var kick1 = createDrumSampler("Kick", 1); const var kick2 = createDrumSampler("Kick", 2); const var snare = createDrumSampler("Snare", 1); const var tom1 = createDrumSampler("Tom", 1); const var tom2 = createDrumSampler("Tom", 2); const var tom3 = createDrumSampler("Tom", 3); const var floor1 = createDrumSampler("Floor", 1); const var floor2 = createDrumSampler("Floor", 2); // This needs to be called at the end so it sends a rebuild message to the UI b.flush();