I've been playing around with this code
dzlonline/the_synth - A simple to use 4 polyphonic wavetable synthesizer library for Arduino.
It works well, and I understand how to play notes and sounds with it. However, I'm trying to understand how it works by looking at the code.
I understand part of it. There are wave tables that have the shape of various sound waves like sine, triangle, etc. But there is a lot going on that I don't understand. I want to be able to modify it, but I'd like to get an overall feeling for how it works.
My goal is to understand why every calculation is done and then rewrite the code with clearer variable names and lots of comments. Should then be easier for me and others to modify.
It does appear that when the waves of all 4 voices are combined at every point in time, the final output is shifted right by 2 to get the final value back down to a byte value. I'd like to change this so that the output is louder. Most of the time, the 4 waves won't add up to be more than 255, so I'd like to increase the dynamic range for softer sounds without clipping.
Any ideas?