Hey, i'm looking at audio synthesis and have succeeded in using DDS (Direct Digital Synthesis) implemented using a for loop and delayMicroseconds. I’ve also succeeded in doing this using the if, sample time method (kind of like arduino’s blink without delay) all I’m wondering though, the maximum frequency I need to produce is only 392Hz (G4) though frequencies below this, I need quite high precision. To keep to a high precision, I’m only using a 6bit sine array. Now as you can all imagine, 6 bit is pretty darn poor quality at only 64 values, an oscilloscope can quite clearly show the steps, especially at low frequencies.
for(aval = 0; aval<64; aval++){
pwmWrite(sinearray[aval]);
delayMicroseconds(Period);
Period being 1/(2^bitdepth * F), in this case 1/(64F)
As you can see, if I use this for a higher bit rate, say 8bit, producing 392Hz would require a delay time of 9.92uS, now since I don't know how to implement none integer delay times, that would have to be rounded to either 10uS or 9uS where at 10uS (closest rounding) will produce a value of 390.6Hz, not too far off but still producing a 3.5 cent error.
What better ways are there for producing audio digitally? 10bit would be optimal but I can settle on 8bit! Would taking an interrupt route be better and setting the interrupt to write the table value to pwm every x microseconds? Where x is dependent on the frequency that I want to produce.
Cheers,