I'm creating a multi-pole morphing multimode filter which uses some internal non-linearity shapers.
Thing is, after adding a "switch" function to select between the different shaping types, it suddenly asked way more then it should (when using the same "default", previously used shape, it asked 5% more than before.. does the switch-function really adds so much cpu usage??)
So, instead of this, I thought it might be a good idea to use a function-pointer, that's being used within the filter-objects, but to which I can assign a certain function when the selector changes.
I'm trying my best to find out how to do this on the internet, but all the examples I run into are way more complex than I need, containing all kinds of extra code of the threat starters, making it pretty hard to see what is the basic "build up" of a function-pointer. So could someone help me out on this and show me how to make a simple function-pointer?
The basic functions I'm using are build like this:
int32_t SIN( int32_t in ) //just a single input
{
SINE2TINTERP( in , in ) //some kind of math function
return in; //returning the result
}
int32_t COS( int32_t in ) //just a single input
{
SINE2TINTERP( in + (1<<30) , in ) //some kind of math function
return in; //returning the result
}
for a start, I'ld like to have a function pointer that I could embed in a filter like *SHAPE(....)
int32_t *SHAPE() and int32_t FILTER() would be put in the local data and *SHAPE() should be pointed to some function in the krate code along this line (though this seems to be the wrong way..)
if(param_shape==0)
{
SHAPE()=&SIN();
}
int32_t FILTER( int32_t *in, int32_t *val, int32_t f )
{
*val = ___SMMLA( *SHAPE( *in ) - *SHAPE( *val ) <<1 , f, *val ) ;
*in = *val;
}
So can someone tell me the right syntax to do this?? Or point me to an axoloti object that uses int32_t function-pointers, so I can find out myself?