Now that I have things where they should be, I made the ADC input adjust the frequency of the signal by introducing an a small delay in the main loop. The DAC is still updated at the same rate and the ADC is still read at the same rate, but the logic that advances the DAC along the selected LUT is slowed to produce the desired frequency.
While I was at it, I did some cleaning up, removing unused code from earlier experiments, and added a couple new output functions. The first new function is a new LUT copied from the DOOM II source code. DOOM's RNG used a 256-byte LUT where the index would advance every time the anything in the game needed a "random" number. Used as a wavetable the resulting noise is a bit repetitive but it has a certain quality I like. The other new function also uses the DOOM LUT, but adds a 16-bit cycle counter and an XOR so the noise isn't so repetitive.
These new functions, and the rest of the code, can be found in this commit on GitHub.
Speaking of noise, I fed the DAC's output to a JBL powered speaker to see how it sounds. I know these speakers have a lot of DSP to clean up the signal, but the waveforms really do sound pretty great. The Sine wave has a high-frequency harmonic that only comes out when the frequency is very low, but otherwise things sound acceptable and maybe a simple low-pass filter will be enough to deal with that. After all, this is an LFO not a VCO, so these signals aren't intended for listening anyway!
Another issue I noticed from monitoring the scope while listening on the speaker was that the DAC's output gets some noticeable distortion when the speaker is connected, I assume from some capacitive loading. I'll have to make sure the output is sufficiently buffered.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.