Hard Clipper
-
@Dan-Korneff Hey Dan, did you ever get anywhere with this?
-
@DanH I did! What's tree best way to share a project with SNEX?
-
@Dan-Korneff project/DspNetworks/CodeLibrary/snex_node/yournode.h
-
@Dan-Korneff Hmmm, not sure, guess a snippet won't suffice in this case! DM me a link?
-
@DanH Here ya go! I've been playing with a bunch of different clipping circuits, including a more advanced one that does some creative EQ to the "overs", but this simple clipping circuit with a variable "soft/hard" control is pretty nice.
https://hub.korneffaudio.com/index.php/s/AHJtWRTRaMjnmGf
template <int NumVoices> struct snex_shaper { SNEX_NODE(snex_shaper); float amount = 0.0; float getSample(float input) { return Math.sign(input) * Math.pow(Math.atan(Math.pow(Math.abs(input), 1 / amount)), amount); //return input; } // These functions are the glue code that call the function above template <typename T> void process(T& data) { for(auto ch: data) { for(auto& s: data.toChannelData(ch)) { s = getSample(s); } } } template <typename T> void processFrame(T& data) { for(auto& s: data) s = getSample(s); } void reset() { } void prepare(PrepareSpecs ps) { } void setExternalData(const ExternalData& d, int index) { } template <int P> void setParameter(double v) { if(P == 0) // soft/hard value amount = v; } };
If you want a straight up Hard clipper, try something like:
f_hard(x, threshold, ceiling) = (abs(x) >= threshold) ? (min(threshold * sign(x), ceiling)) : x
-
@Dan-Korneff are you working on a clipper? I was thinking of picking up flatline by submission audio but i'd wait to see what you can come up with first
-
@Dan-Korneff oh you absolute beauty! :smiling_face_with_heart-eyes:
Can't thank you enough!
-
What's tree best way to share a project with SNEX?
Yeah that's been nagging me for quite some time as I can't embed the SNEX code into the snippet for reasons I already forgot. I'm usually ending up pasting the entire SNEX code along with an example snippet and let the poor reader assemble it manually (the advantage of this is that it makes the SNEX code readable in the forum).
-
@Christoph-Hart I'm trying to export the project @Dan-Korneff posted above. I've followed instructions on how to compile the SNEX node for export from this thread: https://forum.hise.audio/topic/4364/snex_node-needs-to-be-wrapped-into-a-compileable-dsp-network?_=1683724590086
So:
- set 'Allow Compilation'
- Select SNEX node and Wrap into Compiled DSP Network
- Reload project and choose Export -> Compile DSP Networks
- reload project and select Export -> Export as FX Plugin
However I run into the 'Snex_node Needs to be wrapped into a compilable DSP Network' error every time.
@Dan-Korneff suggested this is an existing bug with the SNEX Shaper node?
-
@DanH if you 'allow compile network' you don't need to wrap the SNEX node. You need to do that if you don't compile the entire network.
It's either one or the other but not both. -
@Matt_SF ok thanks, well doing it or not ends up in the same place. My node looks ok I think, the green icon is 'on' as it's meant to be...
Any chance anyone else can test?
-
@DanH I'll try to redo with the SNEX node today. That should work
-
@DanH I get the same "Need to be wrapped...." stuff as you
-
@ulrik Thank you for testing :folded_hands_light_skin_tone:
-
@DanH @ulrik it's working well here. If you first messed up the DLL compilation, maybe try to redo it in a new project folder (to start from scratch).
@Dan-Korneff well done, it sounds nice :thumbs_up:
-
@Matt_SF Wish I could take credit. This is a variable clipping equation from 20 years ago.
-
@Dan-Korneff well, old doesn't mean bad, so thanks anyway
-
@Matt_SF just tried in a new project and get the same result...
I get this error message in the dll compilation though, but says process completed and there's a dylib file created and the node looks correct in Hise...
DLL_EXPORT scriptnode::Error getError() ^ ⸠Compiling RNBO.cpp ⸠Linking CLIPPER.dylib ⸠Build Succeeded Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. [Process completed]
-
@Matt_SF so you managed to export the project as a plugin?
-
@DanH yes, it's working just fine. I don't know why it won't work on your computer.
These are the steps I followed (as usual actually) :- new project, create a scriptFX module
- create a snex_shaper node
- create a new file called "snex_shaper"
- create a new parameter called "soft/hard"
- copy/paste @Dan-Korneff 's code into it
- set allow compilation to "enabled"
- Done
I'm sure you know how to do it though...
If the snex node doesn't work for you, and you still want to use it, try to use a
Math.expr
node and put the algorithm @Dan-Korneff used in the SNEX code in it.