sensorium / Mozzi

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

8-bit Sine tables to not describe sines, but rather negative cosines #279

Closed eclab closed 2 weeks ago

eclab commented 1 month ago

Most of the sine tables do not start at the origin, but rather at -128. This is bad because it can cause a click if the wave is played raw. They should start at 0, then increase from there, then back down to -128.

tomcombriat commented 1 month ago

Hi, I am not sure I completely understand the issue. Looking at the sine tables, only sin1024_int8.h starts at -128, the others correctly start at 0. I agree that the stated types of the tables are not always coherent (and tables/sin1024_uint8.h looks a bit weird with a lot of padding). A bit of cleanup might be needed.

Or are you talking about the cos tables? In that case, the cosphase are also of interest.

eclab commented 1 month ago

sin1024_int8.h sintest_int8.h sin1024_uint8.t sin8192_uint8.t

These four start at the wrong values. The uint ones should be starting at 128 (that's their origin).

I use sin1024 heavily for 8-bit sounds and this discovery was unfortunate.

So let me change "most" to "several".

tomcombriat commented 1 month ago

Okay, thanks for the clarification. Here is my take on these tables:

I am interested to have the opinions of @tfry-git and @sensorium before further action though.

eclab commented 1 month ago

sin1024_int8 creates a click when you start the wave in an Oscil because it's not starting at 0 so it pops from 0 to -128 for its first sample output. As to the uint variants, I presumed they're for unipolar modulation.

sensorium commented 1 month ago

I am all for a clean up if someone has the attention to do it!
No objections to re-aligning tables to match their titles. The scripts in /extras for generating tables were written while I was re-aquainting myself with Python, and quite likely adapted and re-used with many inconsistencies etc. They're only a guide and obviously they can also be tidied up if anyone wishes to do it. PR's welcome! @tomcombriat, you do too much already...

I think deprecating old tables would be good to give others time to adapt their software in case they depend on particular (erroneous) behaviours.