[sdiy] Wavetables
Matthew Smith
matt at smiffytech.com
Sat Jan 22 11:41:25 CET 2011
Quoth Paul Maddox at 22/01/11 19:54...
...
> ok, though you could it using two AT2313's and a single DAC in very few parts.
Having discovered that my flipflops are a bit slow for 128 samples per
cycle, I'll probably be going to direct drive of the DAC in the first
instance.
> with the discrete logic you're planning on using you could use a
> variable sample rate playback
> i.e. the DAC updates whenever a change arrives, be it 10 times a
> second or 100,000 times a second.
I *think* that's what I had in mind, but getting a bit confused now!
My plan was to work out the worst-case scenario, how many samples per
cycle of a waveform do I need to avoid aliasing at the lowest frequency
(around 8Hz, it turns out.) I then have a table of that many samples in
my PROM. The prom is then scanned and the data fed to the DAC at f.n
where f is the frequency of the desired note and n is the number of
samples in the waveform (what I've been calling the cycle.)
Which - I think - corresponds to what you are saying. The same *number*
of samples are always played to produce the waveform, but the *rate* at
which the samples are played is dependent on the desired output frequency.
I'm certainly not creating a table for every note, scanning at the same
rate but changing the address to get the notes.
The address changes will be to select different waveforms so it will be
something like:
0x00 .. 0x80 1 cycle of a sine wave
0x81 .. 0xFF 1 cycle of a sawtooth wave
(etcetera)
Selection of the higher address bits might be by means of a mechanical
switch.
> excel is your friend for this :-)
I was very surprised to discover that OpenOffice Calc (I'm a Linux shop)
does all its trig in radians, by default.
> they need to be 50% above "zero" and 50% below "zero". if you you're
> using 256 samples, and 8 bits, you'd have "zero" as something like
> 127, which means you have 126 values below that and 127 above. so you
> need to be a little careful.
I ended up doing it in Perl - I've never got on as well with
spreadsheets for calculations as I have with programming languages! But
I have achieved and "above the line" sine table that looks OK when
graphed. Now for the others.
> There's a formula out there for that, but to get from your frequency
> to your value in your control word for your counter you'll need to
> understand your sample rate, bit depth and so on.
Yup, found the MIDI note number to frequency formula (tuneable by
redefining middle A,) will be Perl-ifying that soon.
> For examples of how I did the monowave oscillators have a look at the
> schematics in this zip file ;
> http://www.vacoloco.net/synths/monowave/downloads/MonowaveFiles.zip
Ta.
> I used an an AT90s1200 to provide more "oscillator" this was
> controlled from a main CPU using a look up table, out of that comes a
> variable speed square wave. This is fed into a counter chip (4024) and
> this drives the lower 8 bits of an EPROM, the output of the EPROM goes
> straight to a DAC. so every time I update the address on the EPROM the
> DAC changes.
> the other "fringe" benefit was that from the 4024 I also got a sub
> oscillator "for free" by using the next step output in the counter :-)
Thanks, that pretty well validates my concept.
> For the at90s1200 I used what's called a phase-accumulator approach to
> generating the signal.
> there's a techy explanation here that I wrote a while back -
> http://ppg.synth.net/wave22/
> basically the idea is this, and try it you'll see what I mean..
....
Right - think I'll have to re-read that in the morning when I've got
caffeine inside me ;-)
> So, my advice, avoid fixed sample rate playback systems if you can,
> especially when you're looking at building hardware that allows you to
> use variable sample rate playback.
Question is - what I'm proposing, is it fixed or variable rate playback?
Ta muchly for your input!
Cheers
M
--
Matthew Smith
Smiffytech - Technology Consulting & Web Application Development
Business: http://www.smiffytech.com/
Blog/personal: http://www.smiffysplace.com/
LinkedIn: http://www.linkedin.com/in/smiffy
Skype: msmiffy
Twitter: @smiffy
More information about the Synth-diy
mailing list