Creating a single code-source module


#1

Just figured, if we make a single module featuring codes for multiple kinds of algorythms, we could make a "source" module that can be used by other modules, turning these other modules into multi-function-modules without having to copy all those codes for every single added module.

So my idea is to make some community-objects with a pre-defined amount of controls and functions (different soundsources, fast/slow modulations (LFO's/envelopes), distortions or delays etc etc).

The source module will then contain all the functions written out as object-based-algorithms. Each algorithm will write to the same internal value "out".
like:

int32_t out;
int32_t sine(int32_t phase)
{
SINE2TINTERP(phase,out)
}
int32_t cos(int32_t phase)
{
SINE2TINTERP(phase+(1<<30),out)
}

The multifunction modules will contain a switch-function, switching between the different algorithms to select a certain algorithm to be used.
like:

phase+=freq;

switch(inlet_s>0?inlet_s:0)
{
case 0: attr_source.sine(phase);break;
case 1: attr_source.cos(phase);break;
}

outlet_out=attr_source.out>>5;

This will allow universal modules that can do multiple functions.
So instead of having to add both a LFO, envelope and sequencer to be able to use any one of these, we have just a single "source-code" module and could add lots of "universal" modules that can all choose between different kinds of algorithms.

To get this all together, I propose we write down our algorithm in this post and then I or someone else could add them to the source/use modules (code into the source module, the reference into the "use" module).
Also it might be a good idea to make some subdivisions based on the amount of controls needed, function, a/k-rate, and whether or not table-arrays are needed. But, I have to quit writing now.. gotta go to work..