I have this little synthesizer oscillator thing which can read one of several wavetables and output to a PWM pin. it works fine, but i would like to mix 2 of the wave tables together by a third amount
it happens inside an ISR so it has to be quick, and even mixing the 2 values equally
outputvalue = (outputvalue1 + outputvalue2)/2;
takes too long. and starts causing missed notes as the ISR starts taking up too much time for the rest of the program to do much.
(it recieves MIDI and generates an envelope and LFO values)
What i would like to have is the outputvalue mixed between the value of outputvalue1 and outputvalue2; with a third value "mix" determining the proportion of each (can be any type, whatever would work the best)
I was wondering if there might be some bitwise trickery that would work much faster.
Well, the obvious one is ">>1" instead of "/2", but it is so obvious that the compiler probably already does it.
Can't you mix it in the background, i.e. a one-off, instead of on-the-fly?
Ok that has kind of worked, i have even got it mixing by varying amounts, unfortunately because they are signed bytes the ">>1" does not work properly because the leftmost sign bit is always kept when that operation is done.
I will change all my wavetables to uint8_t and convert them to int8_t at the very end.
edit:
It worked! thanks it has no problem reading 2 wavetables at once and adding them
now if i can modulate the phase of the second one i can actually get a detuned second oscillator for extra phat!