SNEX inheritance
-
Is inheritance not possible in SNEX?
class Filter { public: float processFilter(float s) { for (int i = 0; i<nb; i++) s += 0.05f * (float)i; // fake the filter order return s; } void setFilterOrder(int n) { nb = n; } private: int nb = 0; // filter order }; class Distortion : public Filter { public: float processDistortion(float s) { s = Math.abs(s); // apply filter from inherited Filter class return processFilter(s); } }; // instantiate the class per channel span<Distortion, 2> dist; using Index = index::clamped<2, false>; Index idx; // Process the signal here template <int C> void processFrame(span<float, C>& data) { for (int i = 0; i<C; i++) { idx = i; // inheritance would be more direct than dist[idx].getFilter().setFilterOrder(4); dist[idx].setFilterOrder(4); data[idx] = dist[idx].processDistortion(data[idx]); } }
I could go by instantiating
Filter
as a member ofDistortion
but I wanted to try that out...I get a
inliner for classInheritance_Filter_processFilter_ff not found
This reminds me that the console errors are often very confusing (this one doesn't write in the console but at the very bottom)