Re: [stella] 2600 Sound, that time of year..

Subject: Re: [stella] 2600 Sound, that time of year..
From: John Saeger <john@xxxxxxxxxxx>
Date: 01 Aug 2003 18:45:21 -0700
On Fri, 2003-08-01 at 13:33, Eckhard Stolberg wrote:
> > So I'm curious now, if with a correct frame time and VSYNC at the right
> > time, why does Pitfall2 still require a special work around ?
> 
> It doesn't require it. That's just for speed. Everytime Pitfall2
> reads a sound value from the DPC a new value is created. This
> value always gets put into AUDV0. Channel 0 is solely dedicated
> to playing the DPC sound. Since we need about 31000 sound values
> per second in z26, it saves some processing time not to emulate
> TIA sound channel 0 normally, but instead use the emulated DPC
> sound values directly.

There were sound quality issues too.  It's kinda complicated to explain
but it boils down to timing.  On a 2600, the processor, the video and
the sound all run from the same crystal and the instant the processor
writes to AUDV the sound output changes.  It's predictable and
deterministic.  On a PC, none of these things are inherently related and
there is always some slop in the audio stream.  To try to get things to
match up you add or subtract bytes from the audio stream.  Typically
whenever you do this, you get distortion.

With normal TIA sound, z26 attempts to minimize the distortion
associated with this sample rate conversion.  So let's say the operating
system tells us it needs the next sound buffer and we're short a hundred
bytes.  We know the state of the TIA registers, and if the sound output
changes during this hundred bytes we can figure it out.  Instead of just
stuffing sound bytes with the same value to fill the buffer, we can
generate extra sound without distortion when a buffer goes empty.

The Pitfall II code works on the same principle.  We know how to
generate Pitfall II sound so that when the buffer goes empty we can
generate more.  But there's a little more to the story.  The Pitfall II
carts have their own little oscillators so a sample rate conversion is
needed in addition to the generation of sound.  But we can a pretty good
job of this conversion since it is deterministic.  We assume an exact
Pitfall II sample rate and an exact TIA sample rate and do the
conversion to within a single byte of resolution.  The ratios between
the sample rates were chosen in such a way that the chords sounded *in
tune* and such that the pitch was slightly higher than PCAE so that PCAE
sounded a little *flat*.  This was perfectly legitimate since the pitch
of Pitfall II carts is quite variable.  I have two of them and they
sound different.

AUDV sound is different.  There is no way to know what the next AUDV
value is going to be or how to generate a stream of sound based on some
register values.  So we're stuck doing a non-deterministic sample rate
conversion with lots of distortion because we are often off by many
bytes of sound.  I'm pretty sure it's possible to do a better job at it
than we're currently doing, but you don't have to do a great job to hear
*quadrun quadrun quadrun*. 

John


----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread