[sdiy] "AVR synthesizer"
Jaroslaw Ziembicki
aon.912230836 at aon.at
Tue Feb 15 17:54:14 CET 2005
> Could you give us a very high-level description on how you programmed
> the oscillator, and especially the filter?
OSCILLATOR:
I used the "direct frequency synthesis". A three-byte counter (= phase) is
being incremented by a value which is proportional to the sound frequency
(= phase delta). The increment takes place every sampling period, i.e. each
32 us. The most significant byte of the counter is the sawtooth wave.
The square wave is a result of comparing the sawtooth wave to 128.
Each oscillator has its own "phase" and "phase delta" registers.
The contents of each "phase delta" register depends on the frequency
being generated:
PHASE DELTA = 2^24 * Freq / SamplingFreq
where:
SamplingFreq = 31250 Hz
Freq = 440 * 2^((n-69+d)/12)
where in turn:
n = MIDI note number
d = transpose/detune (in halftones)
FILTER:
This is probably the simplest low pass digital filter ever invented; the
formula is:
y[i] = y[i-1] + m*( x[i] - y[i-1] )
The greater the m, the higher the cutoff frequency. For m=0 there is no
AC signal on the output, and for m=1 the output is a copy of the input.
I used 16 bit shifts in order to multiply by m because the AT90S8535
has no multiplier.
OK, I hope it helps.
Regards, Jarek
More information about the Synth-diy
mailing list