[sdiy] Wavetable Design Update

Scott Gravenhorst music.maker at gte.net
Wed Feb 2 13:36:21 CET 2011


Dave Manley <dlmanley at sonic.net> wrote:
>On 2/1/2011 10:28 PM, Matthew Smith wrote:
>
>> * How to convert from my note numbers (these will be all the 
>MIDI-defined notes plus intermediate detune values) to the 
>prescaler/counter values to plug into AVR's onboard counter. I 
>would appear to > have two options: a lookup table (would not fit 
>in ATTINY2313 FLASH) or to calculate these at note-on. I'm 
>favouring the second approach for flexibility (would even allow 
>an actual frequency to be > specified rather than a note number) 
>but haven't the foggiest how to work out the algorithm required. 
>
>roughly:
>
>note number mod 12 -> note
>note number / 12 -> octave
>
>12 entry look up table followed by divide/mult by power of 2 for octaves

I did what Dave described for my phase accumulator oscillator designs.  What I
learned, however, was the it is best to consider the 12 values for note to be the
lowest pitches that will be produced and use the octave number to left shift.  This
ensures that octaves are true octaves.  If one right shifts, significant bits get
shifted into the bit bucket and notes that should be octaves will beat because the
are not exactly 1/2 the frequency of the higher one.  I chose to calculate the octave
value in my MIDI microcontroller - which does not have a divide instruction - I did
the division with a "subtract 12 many times" loop which was plenty fast enough.  The
divide loop provided both the octave number (quotient) and the note number
(remainder).  This method works very well for me.



-- 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