thetraintomars
Member
I am upgrading a simple oscillator project from an Arduino to Teensy 4.1 and saw that the audio library will save me a ton of coding. One key aspect of my project is that it lets you slowly change from a sawtooth wave, to a triangle then to a reverse saw (changing the slope of the rise and fall similar to changing the duty cycle on a square wave). I saw in the code there was "WAVEFORM_TRIANGLE_VARIABLE" but I didn't know if it only did saw to triangle or it kept going to reverse saw.
At the moment my Arduino calculates a table of 256 samples with Bresenham any time the control knob is changed, but this looks like an easy way to do it on the fly and not need tables. I only keep half the waveform in memory now, when I hit the end I count backwards and do some subtraction to get the right value for the negative half of the wave. At the moment all the values are unsigned ints and I deal with the DC offset in hardware. It was just easier to get rid of bugs using unsigned plus my DAC was just 2 RC filters on a PWM output. A real 12bit I2C DAC is on the way.
I did try to search, but no luck. Thanks in advance.
At the moment my Arduino calculates a table of 256 samples with Bresenham any time the control knob is changed, but this looks like an easy way to do it on the fly and not need tables. I only keep half the waveform in memory now, when I hit the end I count backwards and do some subtraction to get the right value for the negative half of the wave. At the moment all the values are unsigned ints and I deal with the DC offset in hardware. It was just easier to get rid of bugs using unsigned plus my DAC was just 2 RC filters on a PWM output. A real 12bit I2C DAC is on the way.
I did try to search, but no luck. Thanks in advance.