Dynamic DSP Libraries
-
I am getting some weird thing.
The effect in effect slot is still working when I set it bypassed. It is bypassed only when I set effect slot bypassed. The bypass button of effect itself does not working. -
And I want to get the name of effect in Effect Slot, such as "IRVerb" or "Script FX Delay".
-
The Bypass works now.
However the ID will be mercilessly overwritten as soon as you change the effect in the slot, so I wouldn't count too much on that information. For which purpose do you need this?
-
I am going to swap effects of slots on runtime. And so I want to know the effect name or type of each slot on runtime.
-
I have tried to change script fx name as customized one like "3BandEQ", and "Save File as XML Backup". Then I can see "3BandEQ.js" saved in "ScriptProcessors" folder.
However, when I restart HISE standalone and reload backup XML file I can see all the script fx names become same as "ScriptFX". And when I save file as XML backup again all the script js files are lost except one.
Please check these issues. -
Hello, @Christoph-Hart! Any answers here?
-
Sorry, I am on the train and internet is terrible.
You don't need the IDs for swapping the effects on runtime. Calling
SlotFX.setEffect(typeId)
returns a reference to the created module. Just store this module and change its parameters using the ordinary scripting methods.This example lets you toggle between a SimpleGain and a ScriptFX with a simple script and lets you control the first parameter from a external slider. It uses the Base64 encoded state feature:
/* This is a Base64 exported state: 1. select the module, 2. Edit->Create Base64 encoded state 3. Paste the string from the clipboard This contains the whole state (script, parameter values, etc) (actually it's just the encoded XML element) */ const var scriptState = "383.3ocYR0sRCCCE9D0JtB5yPoW0AiQ20hHroBhnNVGh2l0dzELKmRRp5T7AY24qiuE9lnIsc5DCgP99NmSx24mwZJGMFRCrcltrDAVXPVtVTZO6V37S9Cb3xRtwfE.iscCIv9LXDoLjD6WpEJaRbignyUBqfKEFtUPp3tGteXXtySazibczEJZVzQQtPsnx1mWT3YRh8mw8hRc6tGFte3cUpbe7QkZrjqwozXIeYhgunThS3VrWzLIk+Pl3Era3qgcBeayXpSsgdGRxmyUJTZ9mWjxqBMISTUKlg5dNAJq940bkkSKDVRmYcemAX6MjJVlMmdRArsCF.2HLhYRrAjQRxeKEHkuBbcI151eRf0zovlZ7W1ezzuT4MkpM9XXzbgrX759mA.XBUYEp6uja0hmAVvUUKxnJcNNpM6cbrs.en03TO1AgLTUTC9xsZMNviYsFGr1Hz1y.2PPqHcxwVO4bP6nRlTTfZP3FT1Mv2Rg5RJv5ri64de0pONF9FXYl+RE"; const var Slot = Synth.getSlotFX("Slot"); Slot.setEffect("EmptyFX"); // Use this variable to store the current Effect reg currentEffect; const var ClearButton = Content.addButton("ClearButton", 10, 11); // [JSON ClearButton] Content.setPropertiesFromJSON("ClearButton", { "saveInPreset": 0, "radioGroup": "1" }); // [/JSON ClearButton] inline function onClearButtonControl(component, value) { // Load a Simple Gain module and store it in the variable. currentEffect = Slot.setEffect("SimpleGain"); FirstParameter.set("enabled", true); FirstParameter.setValue(currentEffect.getAttribute(0)); }; ClearButton.setControlCallback(onClearButtonControl); const var ScriptButton = Content.addButton("ScriptButton", 150, 10); // [JSON ScriptButton] Content.setPropertiesFromJSON("ScriptButton", { "saveInPreset": 0, "radioGroup": "1" }); // [/JSON ScriptButton] inline function onScriptButtonControl(component, value) { FirstParameter.set("enabled", true); // Create a empty script fx and store it currentEffect = Slot.setEffect("ScriptFX"); // Load the exported state (loads the script, compiles it and restores the // interface values) currentEffect.restoreState(scriptState); FirstParameter.setValue(currentEffect.getAttribute(0)); // ... You can do any sort of initialisation of this effect here // (etc. load impulse responses, set table curves, etc). }; ScriptButton.setControlCallback(onScriptButtonControl); const var FirstParameter = Content.addKnob("FirstParameter", 300, 0); // [JSON FirstParameter] Content.setPropertiesFromJSON("FirstParameter", { "enabled": false, "saveInPreset": 0 }); // [/JSON FirstParameter] inline function onFirstParameterControl(component, value) { // Check if a effect was loaded and set its first attribute. if(currentEffect) currentEffect.setAttribute(0, value); }; FirstParameter.setControlCallback(onFirstParameterControl);
Example Patch:
HiseSnippet 2070.3ocuX01bhibDV30jZMW7U4Rke.SwWB9NexBvurrakbGfAuXavr.FicpT2MHM.isjF4YFgAtr+Wymxmy+fjdjDKBLmW65pao7KnY5tmmtmmtaZZxYlDgfw0R7Ucl5QzR7GS1dpqbT4QXpqVsi0R70IqiERBGEtTo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9zsSFlBs.ralrZuuvCiFgkWmL7SBG.i+PvCKCjUX7u54Ajm2jvoRNuOavwG6w0L5ah+cRfyJfgJ08fYQ+TSZTsk5VkdkdCp5+qqif5uPU6nt.wp23wIvTpjNrl13oYDX0mhrE376h5ayLuqMcF4Q0M7BcsRJAxXNB65RrEu7pKatbr90OuX8p0RVxAVTCHNFexhEOtZ0ZX0sX9Rp6v5XnCvDsDIa36zl4yMIki7d025yFp5LgOandVkj0l3ZYL+qDJZyrpmSDsY14atnDUhDQfDfiLf470QTk11TKBWiZoHupqTsfPZTV8OOXv+4G9h.0uDmgC1jy9IyvHgJi50Aq.wD2fustsRVW8LJ67Xf5xzgZQ+ISSUIluGtHWuF4dwZj+Eqw9uXMN3EqwguXMN5EqwadBMTe6hE8kLmvFNZZ+evFvqZl
-
Thanks for your reply.
I have one more question.
If I use a dynamic library which will be loaded in the plugin or standalone app, then shall I have to add such library file(like .dylib) in the installer?
And if so, where should I have to install such library? -
On OSX, the library must be at
Application Support/Company/Product/lib
On Windows:
%APPDATA%/Company/Product/dll
But iOS apps can't use dynamic libraries, so you have to build a static library and link the HISE project with it (this is a bit complicated, but NSK uses this method and it works fine).
-
Hello, @Christoph-Hart!
I am going to add script fx like following.<?xml version="1.0" encoding="UTF-8"?>
<Processor Type="ScriptFX" ID="ScriptFX" Bypassed="0" Script="function prepareToPlay(sampleRate, blockSize) { vkfx_ampEq.prepareToPlay(sampleRate, blockSize); } function processBlock(channels) { vkfx_ampEq >> channels; } function onControl(number, value) { } ">
<EditorStates BodyShown="1" Visible="1" Solo="0" onInitOpen="0" prepareToPlayOpen="0"
processBlockOpen="1" onControlOpen="0" Folded="0"/>
<ChildProcessors/>
<RoutingMatrix NumSourceChannels="2" Channel0="0" Send0="-1" Channel1="1" Send1="-1"/>
<Content/>
</Processor>But when I make BASE64 encoded state and call restoreState on runtime, HISE freezes and then crashes.
I guess it is because of function "processBlock". If I let it empty then it won't crash.
Please check this issue. -
Ah yes, it's a deadlock situation where the audio thread holds the compile lock and the message thread the swap lock.
This is fixed now. However beware the AmpReverb is producing nasty bursts if uninitialised (take a look at the NSK code how I tamed it). Definitely keep your speakers down until you are safe :)
Edit: Set these parameters:
vkfx_ampEq.setParameter(vkfx_ampEq.Volume, 0.5); vkfx_ampEq.setParameter(4, 0.0); // Reverb Level (enum is defect) vkfx_ampEq.setParameter(5, 1.0); // Amp Bypass (enum is defect)
-
ok, I got. Thanks.
-
Hello, man!
It still crashes when I add the code "vkfx_ampEq >> channels;" in processBlock function.
-
Is the crash happening if you compile or if you select the effect with the drop down?
-
It crashes when I compile script.
-
I added "vkfx_ampEq >> channels;" line in processBlock function and then compiled that script first.
And next I created Base64 encoded state and set it as a const string variable.
Finally when I compile Midi Script Processor, it freezes and becomes not responding.
Please resolve this issue asap. -
I can't reproduce this crash with the latest versions, and it's impossible to fish in the dark with issues like this (I assume it's still the deadlock, but please hook up the debugger to confirm this).
I've made some tiny changes that decreases the duration that the locks are held, maybe this fixes something.