I just wanted to show how this could be done in a way that could be made universal. I wrote this code from my head, not being totally sure whether it were the correct values. Good to see you got the point!
Anyways, to make the different waveforms, you can combine the tables in several ways:
-use one long table containing all the values of the different waveforms, but add an offset of 4 for each waveform:
int phs[8] ={0,0,0,0,0,2,0,2}; // put all the values into one table, make sure it's big enough to fit all of them
int mute[8] ={0,0,0,0,0,0,0,0};
int flp[8] ={0,0,0,0,1,1,1,1};
int wave=param_waveform<<2;
int32_t pos=(Phase>>30)+wave; //turns the phase into an integer from 0-3 and adds an offset for each waveform
you can also make a combined array (not sure what the correct technical term is for this), like
phs[8][4]=
{
{0,0,0,0},
{3,2,1,3},
{0,2,1,2},
etc...
}
the waveform selector would then select from the 8 different tables, each containing 4 values.
Anyways, these tables could of course be used to do all kinds of different things, eg. self-fm amounts:
-store the waveform output in the memory, so you can use it in the next cycle to do frequency modulation. Don't forget to use a hp-filter to remove DC-offsets, to prevent it from pitch-shifting away from it's base frequency.
-use different waveforms for output and self-fm, multiplying the phase of either one of them with an integer value creates harmonic overtones which can further increase the amount of spectra you can create. Also, giving the phase an offset can give totally different results, even though you're using the same waveform. Eg. in the case of a normal sine, no offset will generate a pulse-wave, but a 45 degrees offset will generate a saw-like waveform.
-perhaps a randomise function of the tables to find other interesting waveforms. Here, a hp-filter over the output is advisable, as some might create waveforms with an offset.
-use another table to multiply the phase to create seperate harmonic overtones in the 4 parts of the phase.
-another thing that might be interesting is to use the actual phase-offset, amplitude and flip values (eg. (1<<30)=45 degrees) and morph between the table values to morph between waveforms.
int a,b;
int32_t mix,value;
a=(uint64_t)param_morph*8>>27;//turns the parameter value in the range of 0-7
b=(a+1)%8;//offset of 1 to select the value of the next waveform
mix=((uint32_t)param_morph*8<>1;//gives the remainder without using the bits used by the wave-selection (a/b) and turns it into a range of 0-(1<<31)
value=phs[a][0]+(___SMMUL(phs[b][0]-phs[a][0],mix)<<1);//mixes between wave selection by a and selection by b.
ps I normally use a simple lp/hp filter calculation for dc-offset removal:
hp+=wave-hp>>9; (simple 6dB lowpass function around 30hz if I'm right, not sure though, but works well enough for self-fm, sometimes I even use 8,7 or 6, which will increase the frequency of the hp filter)
wave-=hp; (subtract lowpass from original to create hp-filtered wave)