How to build SNEX Playground?
-
Hey!
How do you build SNEX Playground, tried doing it the same way as building hise, but when trying to open the exe (debug), I had errors saying multiple ipp DLL files were missing, any ideas?
Thanks!
-
@Casmat I don't think the SNEX playground has been updated for a long time. I'm not sure it has any advantage over just working directly in HISE.
-
@d-healey ooh, how do I work directly in hise? I tried pressing the snex popup button in the snex shaper node in scriptnode to edit, but it does nothing
-
@Casmat Click the 3 dots at the left, create a new file. The SNEX editor will open in the same panel as the script editor.
-
@d-healey the SNEX playground is still functional but the main use case for it is me making unit tests for testing specific SNEX language features.
-
@Christoph-Hart @d-healey Nice! I found this code on musicdsp.org:
x < a: f(x) = x x > a: f(x) = a + (x-a)/(1+((x-a)/(1-a))^2) x > 1: f(x) = (a+1)/2
How would I turn this into something snex can understand? Wouldn't it use if statements and how should X and A be swapped? It's supposed to make a soft saturation
Thanks!
-
@Christoph-Hart Oh I think I was thinking of the SNEX workbench.
-
@Casmat said in How to build SNEX Playground?:
x < a:
f(x) = x
x > a:
f(x) = a + (x-a)/(1+((x-a)/(1-a))^2)
x > 1:
f(x) = (a+1)/2This translates to something like:
float out = 0.0; if (x < a) out = x; else if (x > a) out = a + (x - a) / (1.0 + Math.sqr((x - a) / (1.0 - a))); else if (x > 1) out = (a + 1.0) / 2.0;
Although it can probably be optimised depending on the use case...
-
@ustk I was trying to write it out and got this:
float getSample(float input, float a) { if(input < a) { return input; } else if(input > 1) { return (a + 1) / 2; } else { return a + (input - a) / (1 + ((input - a) / (1 - a))**2); } }
definitely wrong in all sorts of cases, I haven't ventured into dsp code, and this is by far the deepest, so thanks for helping! Have one more request, how in the world do I put this into the snex code editor? I tried reading the docs on snex, but was a bit stumped. I'm trying to build a saturation in a snex shaper node with one "Saturation" control. How do I continue?
Thanks a ton!
-
@Casmat The implementation of your function looks like this:
float getSample(float s) { //return your stuff here } template <typename ProcessDataType> void process(ProcessDataType& data) { auto f = data.toFrameData(); while (f.next()) { for (auto& s: f) s = getSample(s); } } template <int C> void processFrame(span<float, C>& data) { for(auto& s: data) s = getSample(s); }
-
@Casmat And as I wrote above, the constants should be float if you don't want to get casting errors
-
@Casmat And one other thing, have you tried to plot your formula to see what you get out from it? Because it's going over the -1/+1 gain factor so you either need to scale the output or rework the formula...
-
@ustk thanks for the info! I don’t think ive done anything with the formula, i found it on music dsp and I was clueless from the start on how to get it to be a simple saturator,
is the gain factor related to the gain matching on a saturator?Edit: so the gain factor is x?
-
@Casmat So I imagine
a
is your gain, right?
What do you get as a result? Is it at least sounding "something"?
Does the level need to be tamed a bit perhaps? -
@ustk as far as I know when looking at it, I thought that x was the input signal and a was the saturation amount
-
@Casmat said in How to build SNEX Playground?:
Edit: so the gain factor is x?
f(x) means the it's the output, so a should be the gain
-
@ustk ohh yeah! Polynomials (or maybe not)!
-
@Casmat At first, does it look the way you want?
![Screenshot 2023-08-18 at 20.47.17.png](Imgur is temporarily over capacity. Please try again later.)
EDIT @Christoph-Hart @Dominik-Mayer Apparently there's still this Imgur over capacity issue that prevents us to see images...
-
@ustk why was there an float s in the arguments? And I should be declaring a as a variable, right? I put the code you gave
if (x < a) out = x; else if (x > a) out = a + (x - a) / (1.0 + Math.sqr((x - a) / (1.0 - a))); else if (x > 1) out = (a + 1.0) / 2.0;
In the get sample func?
Edit: didn’t see your post yet, the img seems broken
-