Array usage in SNEX
-
@Christoph-Hart Oh while pasting the code here I forgot to include the
float getSamples(float input)
function. Now the code is updated.Input
is the sample input. -
@orange Lol you're doing that for each sample with 8x oversampling? What's the CPU?
-
@Christoph-Hart said in Array usage in SNEX:
@orange Lol you're doing that for each sample with 8x oversampling? What's the CPU?
Yes I am doing that :D I can't even see the CPU usage because there is a silence ahahah
-
@orange Yeah, my guess is you're at 1000%.
You have to change the logic of that algorithm (I think we talked about this before). You should be able to remove the entire inner loop and replace that with a single lookup table (and probably some interpolation which you aren't doing at the moment BTW.
The silence is the least of your problem :)
-
@Christoph-Hart Once you've said that there is a built in interpolator, but I couldn't find an example.
Is there any example for interpolator & lookup table to use together?
-
So I removed that loop and tried the below hardcoded one (9 points), it seems the way much better. I couldn't even use the 9 points with a
for
loop (with 8x oversampling) before.If the points will be increased to around 150, so the
else if
checks will be increased to this amount too, would that be a safe use case?span<float, 9> LkpTbl = {-10.0f, -0.7f, -0.65f, -0.5f, 0.0f, 0.5f, 0.89f, 0.96f, 10.0f}; float getSample(float input) { if (input >= 0) { if (input >= LkpTbl[8]) input = 0.9; else if (input >= LkpTbl[7] && input < LkpTbl[8]) input = input * 0.85; else if (input >= LkpTbl[6] && input < LkpTbl[7]) input = input * 0.5; else if (input >= LkpTbl[5] && input < LkpTbl[6]) input = input * 0.4; else if (input >= LkpTbl[4] && input < LkpTbl[5]) input = input * 0.24; } else if (input < 0) { if (input <= LkpTbl[0]) input = -0.82; else if (input > LkpTbl[0] && input < LkpTbl[1]) input = input * 0.79; else if (input >= LkpTbl[1] && input < LkpTbl[2]) input = input * 0.43; else if (input >= LkpTbl[2] && input < LkpTbl[3]) input = input * 0.35; else if (input >= LkpTbl[3] && input < LkpTbl[4]) input = input * 0.3; } return input; }
-
@Christoph-Hart is there a limit to the size of a span? I have one with about 2000 elements, but only 1024 show up in the Data Table.
-
@Dan-Korneff I think I capped the display in the watch table in order to prevent the UI to slow down for big tables, but the real size should not be limited.
-
@Dan-Korneff said in Array usage in SNEX:
@Christoph-Hart is there a limit to the size of a span? I have one with about 2000 elements, but only 1024 show up in the Data Table.
Are you able to use these elements with 8x oversampling? In Hise works, but doesn't work on the exported plugin here.
-
@orange I haven't gotten that far yet. I'm still trying to debug my dsp :(
-
@Dan-Korneff To be honest at some point it makes more sense to move the SNEX class in the ThirdParty folder and debug within Visual Studio like the big boys do.
I'm always starting with SNEX JIT compiled nodes but then find myself wanting to set proper breakpoints and inspect memory states pretty quickly. The nice thing is that you haven't wasted any time because the code should be 100% portable to C++.
Just create a C++ template, then paste your snex node class instead of the dummy class and hack away in VS / XCode.