[sdiy] Coding digital waveforms

Scott Gravenhorst music.maker at gte.net
Thu Dec 17 13:40:01 CET 2009


Justin Owen <juzowen at googlemail.com> wrote:
>Hello,
>
>I've started writing some code for Arduino to output digital 
>waveforms to use as tempo synced LFOs - but was hoping for some 
>general guidance in case there's a better way of approaching it. 
>
>At the moment I'm just using a counter to increment through an 
>array of values that output to a DAC. It's a fixed frequency at 
>the moment - but the plan is to set up a variable to tell it how 
>'fast' to run through the array - or how many of the values to 
>use. It's basic and there's loads of room for improvement - but 
>so far it works. 
>
>So firstly - considering that my code game is pretty basic - is 
>there a better way of handling it than this? 
>
>and secondly - to smooth the output (which is obviously 'stepped' 
>right now) - should I be looking at some type of 'lag' circuit 
>(i.e. the resistor/diode/cap combo) - or something else? 
>
>Thanks again to everyone that helped with the whole 
>micro-DAC-Multiplexer-S&H set up . Works like a charm. 
>

Hi Justin,

What you describe sounds like wavetable synthesis, it's a pretty
standard method.  

As for smoothing the output, you could interpolate the values in the
table.  Even linear interpolation would be better than the steps you
can get directly from the table.  Increasing the output sample rate
would be required to do interpolation.

While you could use an external filter to smooth it out, the filter can
also cause a significant reduction in output amplitude where
interpolation will give you the full output range.  The amount of
attenuation depends on the corner frequency of the lowpass filter you
use so if you change the filter's Fc, then you also need to change the
amplitude compensation.

-- ScottG
________________________________________________________________________
-- Scott Gravenhorst
-- FPGA MIDI Synthesizer Information: home1.gte.net/res0658s/FPGA_synth/
-- FatMan: home1.gte.net/res0658s/fatman/
-- NonFatMan: home1.gte.net/res0658s/electronics/
-- When the going gets tough, the tough use the command line.




More information about the Synth-diy mailing list