sensorium / Mozzi

sound synthesis library for Arduino
https://sensorium.github.io/Mozzi/
GNU Lesser General Public License v2.1
1.05k stars 184 forks source link

Optimization of `Oscil::phMod()` #245

Open tomcombriat opened 3 months ago

tomcombriat commented 3 months ago

Currently, Oscil::phMod() uses a Q15n16 (or SFix<15,16>) as argument for the phase modulation of an oscillator:

where the fractional n16 part represents almost -1 to almost 1, modulating the phase by one whole table length in each direction.

So, in theory, one do not really need the integer part at all, as modulating by 1 brings you back to the original position, hence modulating by 0. The overflow of a 16bits should be able to reproduce this behavior.

The sign might be a problem, I have not though that completely through yet, but this could be a point of optimization.