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

Subject: [stella] 2600 Sound, that time of year..
From: "Andy Mucho" <andy@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Jul 2003 19:22:03 +0100
You resident lurking newbie here :) There's 3 parts to this, so please bear
with me..

    Pitfall2 style sound
    Sound specific emulator
    technical bits'n'bobs about the sound..

After browsing though the list archives and seeing all the previous mentions
of multi-channel sound and then seeing ot much more after each resurgence
(it seems to happen about once a years or so ;) ), its got to be be time for
another TIA-Sound time..

Like several others on the list I'm taken with the idea of synthesing sound
on the 2600 and getting something a little better than hardware usually
allows..

I've been prodding away, and after several rather false starts[1] I went
back to basics and set out to attempt to emulate Pitfall2 style sound 3 PWM
channels.. Now the only problem is that none of the emulators seem to handle
good sampling of the AUDVx registers at anything like the rate and stability
they should, hence all my attempts sound rubbish on the emulators..

What I'm curious about is if this sounds okay on a real 2600, and if
possible can someone record the output off a real 2600 and send me an mp3
(or something) of it so I can see how well this actually works in the real
thing..

Which brings me to part 2..

In light of the emulators being so bad at playing back AUDVx sample playback
methods, I embarked on a little endeavour this afternoon. That of writing a
*simple* emulator that does nothing but pickup writes to WSYNC and the AUDVx
registers[2]..  Is there enough interest from others to want to use this, or
is it just me ? Bear it mind ot was written solely due to the poor emulator
side of things, but it's enough to write sound stuff with and, I think, get
a good approximation of what it sounds like on a real 2600 instead of the
spluttering clicking, repeated emulators[3].. Admittedly it's not too bad on
the PWM core I've got here, but once you chuck in anything remotely
non-square wave it starts to sound really really terrible :(

It's a stand alone windows command line app, plays abck through DirectSound,
and also streams to a file.. Is anybody interested in this ? And does
anybody (the sound hard-core brigade I suspect) fancy giving it a go ? Or do
I suspect I'm the only one who wanted something like this ?

So there we go :)

The sound engine basically synthesises 3 pulse width modulated channels
summing them in a style very close to Pitfall2.. The easy part was writing
this 3 voice core, which eats 84 cycles per samples generated which includes
loading it into AUDV and the call overheads..

The hard part was writing a *proper* Song,Pattern,Sequence,Note style system
that didn't eat up huge amounts of ROM rendering the thing useless.. So it
really a proper player along the lines of the typical C64(and just about any
other 8bit music routine) music players.. It's not a mod style pattern!!

The really hard part was to process the sequence events, notes etc without
exceeding the remaining time of the two line kernel aim.. So I end of with
everything being broken up into lots of little states, one of which gets
processed during the sequencer processing time.. Each event state is written
to not consume more than 40cycles..

Some of the event states can get quite hairy..

For example..
To get the next pattern in the song, and get and process the first event in
that sequence results in exeecuting 7 states..
To process a note-on event, takes 5 event states..
    1/    Get the new note, and transpose it..
    2/    Get the length, and set the wait timer for the voice..
    3/    Fetch the notes real integer:fraction values..
    3/    Set the note integer:fraction into the correct voice..
    4/    Reset the EG, and reset the voice..

Just examples but that's how they are..

Basic Song commands are:
    Transpose
    PlayPattern
    EndOfSong

Basic sequence commands are:
    NoteOn
    NoteOff
    Length
    Patch
    Rest
    EndOfPattern

Sequence commands are 8bits, with the top 3 bits being the command, and the
bottom 5 bits being the command data..

I'm in the process if adding other more gltizy bits..
    Envelope generators, (AR only, processing that sustain phase is killing
my 40 cycle limit, and my imposed RAM limti as well ;)
    Apeggios
    Portamento
    Pulse Width modulation (either LFO or EG source)

Possibly a 4th channel using the as yet unused second 2600 channel, perhaps
dedicated to percusion sounds..

Possibly, if this sounds okay a real 2600, I'll move back to the more
complicated original plans, and possibly a sample channel or 2.. Time will
tell..

This will of course eat up more time, but as long as I can keep the
sequencing overheads within overscan/vblank limits I'll have achieved my
goal.. Which I think is doable..

Of course, this is with three channels.. Using less than 3 is doable as
well..

Anyway once I get a few more things in I'll up the source to it, but for now
lets hear more about 2600 Sound programming ;)

The core is designed at the moment to perform no sequencing processing
inside the visible frame, so you can have lines 0-192 doing just synthesis
using 84 cycles per 2 lines, with the rest free for hopefully drawing
something useful.. Once into the overscans, the sequencing runs for 16 state
events per voice, plus some overhead states, like switching voices updating
internal tables, but at not point does it ever break out of the 2 scanline
restriction.. It always produces a new sample bang on cue every 2 scanlines
never missing. So it's useable.. It's only a 7.8Khz replay rate, but it's
good enough I think.. I don't realistically think a one line update for a
15.6Khz rate is achievable not without actually displaying anything..

Again this all leads up to a grand master-plan, which is to write a clone of
Park Patrol for the 2600, but with cool music :) But that's another things..

Anyway enough of the waffling.. Please can somone as above let me know (and
record it and mp3 it or something) what it's like on a real 2600.. Please,
pretty please.. :)

And no I'm not a musician, it's just a terrible test set of notes and stuff
:) Not pretty on the ears but ample to test with..

regards
andym

[1] Ideas too grandoise for my own liking
[2] I plan on bolting on Ron Fries TIA Sound, but it's not high on my list,
and also implemetning the timers maybe
[3] I'm not dissing the emulators, but they do sound bad on the sample
playback count.. If they were done properly there'd be no need for the
special hackery of Pitfall2 emulation in particulat, it'd just work with the
emulation of the DPC, without having to special case it's loading of AUDV
and effectively clocking the sound generation of the DPC seperately from the
2600..

Attachment: pitsound.bin
Description: Binary data

Current Thread