SNEX Saturation snippet does not compile
-
template <int NumVoices> struct saturator { SNEX_NODE(saturator); static const int NUM_CHANNELS = 2; // SNEX has a special float object that handles automatic smoothing // they are stateful, so we need two of them for stereo operations span<sfloat, NUM_CHANNELS> k; float getSample(float input, float ck) { return (1.0f + ck) * input / (1.0f + ck * Math.abs(input)); } template <typename T> void process(T& data) { const int numChannels = Math.min(data.getNumChannels(), NUM_CHANNELS); for(int i = 0; i < numChannels; i++) { for(auto& s: data[i]) { s = getSample(s, k[i].advance()); } } } template <typename T> void processFrame(T& data) { for(auto& s: data) s = getSample(s); } void reset() { // this resets the smoothing and will be called when there // needs to be a reininitialisation in the signal stream for(auto& ck: k) ck.reset(); } void prepare(PrepareSpecs ps) { // change 1000 to 50 for a normal smoothing // I set it to 1s fade time so you can clearly hear it in action const double SMOOTHING_TIME = 1000.0; for(auto& ck: k) ck.prepare(ps, SMOOTHING_TIME); } void setExternalData(const ExternalData& d, int index) { } template <int P> void setParameter(double v) { if(P == 0) { const auto s = Math.min((float)v, 0.999f); const auto nk = 2.0f * s / (1.0f - s); for(auto& ck: k) ck.set(nk); } } };
That's the code from the snippet. But the error is:
Line 34(17): Can't resolve saturator::getSample(float)Now the getSample function takes two input arguments; the input and then another one called "ck" which I don't know what it represents, but the code snippet isn't giving the getSample call on line 34 two arguments. So that might be one reason why it isn't compiling.
There are a lot of references to ck, but I don't see ck being defined anywhere?? Is ck meant to be every sample inside of 'k' itself?
-
@Orvillain Looks like ck is defined everywhere it's being used
-
@d-healey
Ahhh because it's always preceeded by a loop??? IE:for(auto& ck: k)
So I guess ck is every entry in k then.
Anyway, it is Line 34(17): Can't resolve saturator::getSample(float) that throws an error.
-
@Orvillain I think I've updated the example in the snippets that fixed that error, it's a simple typo. Make sure you use the latest snippets.
-
@Christoph-Hart Ahhh didn't realise. Yep, works now. Cheers!
-
-