Re: 6581 phase-accumulating oscillators

From: Nate / DAC (
Date: 2000-11-21 14:29:17

> On Sun, 19 Nov 2000, Nate / DAC wrote:
> > Yes, it does.  It achieves something like 33 kHz 8-bit stereo (with two
> > SIDS) and I think somewhere close to 60 kHz in mono.  Since the SID can
> I think there is a misunderstanding of what PWM is/how it works.  There
> will be an article in the next C=Hacking on this very subject, which will
> hopefully clear things up.

See my explaination below [1].

> Regardless, I don't think this is what Richard was talking about.  He was
> talking about modifying the frequency register to generate arbitrary
> waveforms -- I think this is described in disC=overy issue #2.  For

I was answering someone else's query though, not directly related to
Richard's idea.

> the 24-bit counter.  So now imagine setting the frequency to some high
> value, then zero, then some high value.  The output would look
> something like [Snip] a new waveform.  To answer Richard's original
> question, I have not heard of anyone trying this, and would be
> interested in the result.

Same here.  It would certainly be cleaner than any other methods used so

I can see only two hurdles with his method - frequency response would be
limited to low-amplitude sounds because of the time it takes for the
oscillator to rise or fall from one setting to the next (maybe use the
high-pass and band-pass filters to help out here?), and his timing is
going to have to be super-precise to keep the oscillator from wandering.


[1] The way I understand it is that a PWM signal, like that used to
control the speed of an electric motor in some applications (like a food
processor or a mixer), is used to generate an arbitrary voltage level
according to the duty cycle of that pulse train.  The 1351 uses this
method as well, I believe.

Varying the pulse rate, or more preferrably the duty cycle, leads to
arbitary waveforms being generated, the voltage output at any given point
being higher as the pulses get wider.  In the c64 it works pretty much
this way as well, except that the SID has limited resolution.

The limit is such that as far as I know, the SID can only count through
the duration of a pulse (or any other waveform) in 1/1022727 second steps
(Phase2 clock), and it takes 256 steps (voltage levels) to make a full
8-bit range available.  At that range, you can only get about 4 kHz
(1022727/256 = 3995.027 Hz).

If you go with a higher sample rate (thus a shorter maximum pulse width)
you lose cycles from the length of those pulses, according to your sample
rate.  Double the sample rate and you cut your resolution in half (was 256
steps, now 128 steps).  So at a hair under 64 kHz you are limited to four
bits (1022727/16 steps = 63920.4375 Hz).

If one voice produces the upper four bits of the original sample data (
thus a waveform like you would get out of the Volume register), you can
make that voice crank out 64 kHz if you can process the data that fast
(Super CPU).

SID mixes and updates all voices within one clock cycle, as far as I know
anyways, which means you can use two or three voices (and even two or
three separate sample streams) and still get ~64 kHz.  So, to fill in the
rest of the space between those 4-bit steps produced by the first voice, I
simply feed the other four bits of the 8-bit sample to another voice at
about 1/16 of the amplitude (controlled by the Sustain settings) of the
primary voice.

The result is about 8 bits of resolution, which seems to depend on the SID
chip though.  The SID I was using sounded great, but the SID I have in my
machine now (6581 in both cases) reveals some loss of resoltuion, which
means I probably need to add user adjustments for the two voices' sustain
levels to get them to mix right.

I could try using all three voices, making two produce the upper four bits
in unison (just plain 4 bits, at twice the amplitude) and one to produce
the lower four bits (set the Sustain register to a higher value than
normal), to more accurately fill in the gaps.  The Sustain values aren't
what you might expect though, I figured them out by trial and error using
my oscilloscope and ears.

At any rate, it's true 8-bits of output if I mix the two 4-bit streams
right and keep my sample rate constant (clean timing, which I'm not that
good at :).

 ________________________________________ ___ _____
|         .       .        :             /XXZ| ___ |
|   _  _ _|_ _   _| _   _  : C64/C128-  /X/   |ZZ/ |
| |/ \ _| | / \ / | _| / ` :  What's    LH     __  |
| |  |/ | | L-'|  |/ ||    :  *YOUR*    \`\__ |__\ |
| |  |\_|_\_\_. \_|\_|_\_. :  hobby?     \___|     |

This message was sent through the cbm-hackers mailing list.
To unsubscribe: echo unsubscribe | mail

Archive generated by hypermail 2.1.1.