I'm using a nice bit of code that you can find here to make a nice midi-controlled oscillator. It's nicely working, however i'd like to add an LFO (low-freq osc) to get some sweet modulation.
I added another osc (o2), and tweaked the output computation :
The main idea behind this is to make o1.amplitude vary in function of the o2 oscillator.
More readable translation :
output = ([vol osc 1]{[vol osc 2][phase osc 2]})*[phase osc 1]
BUT
It's not working, i get no sound, and can't understand why.
I just had to take the output calculation out of the interrupt routine
The bit manipulation stuff is fast, so you could probably get by with that in the ISR, but the multiplication and modulo stuff isn't. They definitely do not belong in the ISR.
I might have pointed that out, if I was aware that the one line of code you posted was in an ISR.
Haha, no, i did not solved the problem, i just figured that i could debug the calculation outside of the ISR AND get a right computation, because that would have been mad to put some serial.print in a 16khz ISR So i've put the phase calculation in the main loop, and i'm grabbing data via serial. Looks like i have a rollover issue, my multiplication exceeds 255 very often.