PDA

View Full Version : Help with Commodore sounds.....



marc.hull
December 12th, 2009, 11:22 AM
This may seem like a cross post but please bear with me. I have finished an interface that allows a SID chip to be memory mapped into my TI99 (I know.... we have always had SID envy.) It apparently works.....

....http://www.youtube.com/watch?v=cxqvE3-d0jg...

but I have come to the conclusion that I have no real idea on how to program it. What I need is a tutorial or other information on how to make this thing rev up a little. The C64 manual is a bit slim on detailed info. All information is welcome. Thanks in advance...

billdeg
December 13th, 2009, 08:31 PM
You know when I finally got it, and was able to put the concept together - when I read the original BASIC 1960's manual by Kemeny and Kurtz. That was my stumbling block, how the sound data is read into the system for playback. The key is to understand the DATA and READ commands and the Kemmney and Kurtz's book starts with good examples of READ and DATA. NOTE These examples were written 15-20 years before the SID was invented. Once you get READ/DATA down, all the rest falls into place because the code that "sets up" the SID/sound is used over and over no matter what music you're writing.
Bill

carlsson
December 13th, 2009, 11:08 PM
I suppose you have studied the list of registers and want to know in which order they should be set up and to what values?

The five most basic registers would be the 16-bit frequency, waveform and 16-bit ADSR settings. The ADSR usually only needs to be set once unless you want to change the sound between notes. The frequency obviously needs to be changed for every new note, and the waveform is the last bit to toggle on/off for each note.

I don't know to which memory address or I/O port you have mapped your SID chip so I will give examples based on the default location in a C64 = $D400, decimal 54272.

First we turn on the volume [$D418] by POKE 54296,15. It is four bits wide. Honestly I can't remember where the upper four bits would go, probably into void.

Then we set the ADSR. First byte is Attack + Decay. A value of $58 would mean an attack period of $5 and decay $8. Look up in the datasheet what those correspond to in micro seconds. POKE 54277,88 [hex $58]

Sustain keeps the note playing, let's set it to $A and a final release time of $9 = $A9 = decimal 169. POKE 54278,169.

Now it is time to set up the frequency. The datasheet has ready calculated values for a well tempered scale. Otherwise you can calculate your own using a formula. For this practical purpose we can set the frequency to any arbritrary value. The SID chip just like the 6502 is little endian, so the low 8 bits go into the first byte followed by the high 8 bits. A frequency value of $1234 thus would be stored as POKE 54272,52 (hex 34) followed by POKE 54273,18 (hex 12).

Finally, we choose a waveform. You have four basic ones to choose from, plus a couple of mixed waveforms. For keeping the simplicity, we use sawtooth that does not require setting up any other registers: POKE 54276,33

It can be worth looking closer at the waveform registers:

xxxxxxxN = toggle gate bit. When set to 1, the sustain will keep sounding. 0 will start the release phase, letting the note go away.
xxxNxxxx = select triangle waveform
xxNxxxxx = select sawtooth waveform
xNxxxxxx = select pulse waveform, requires setting up pulse width as well
Nxxxxxxx = select noise waveform

You saw I skipped three bits, which deal with synchronization, ring modulation and so on. You can read more about those in the datasheet or elsewhere. In order to understand how the SID chip produces sound, they are not required to know.

So, we got a somewhat shrill note sounding. POKE 54276,32 to let it go away.

As Bill mentions above, if you want to play a tune it is a good idea to set up a frequency table and use DATA statements to select notes from the frequency table. Then you would read pairs of note index and duration from the data statements, look up the exact frequency, set up registers and play the note. You use a FOR loop to determine when to fetch the next note.

By the way, POKE 54296,0 to turn off the volume alltogether.

Besides I have no idea if you can access your interface from TI (Extended) Basic or are forced to use TMS9900 assembly. Hopefully you know your way around that, it is a field I can't help with.

marc.hull
December 15th, 2009, 06:26 AM
Thanks Carlsson, that's the kind of info I am looking for. I know this is quite a powerful IC (considering the time) and there are probably many nuances and much info I need to know. If possible I would also like to create a TI sid player to play all those great .MUS songs on the TI. I have found some info on the structure of the data file, but some of the terms are confusing. Is there a comprehensive site or book out there?

BTW the interface can be accessed through XB or 9900 AL.

Also.... I am having trouble getting the square wave to respond. Is there a particular order the pulse registers need to be set relative to the others?

Thanks... Marc

carlsson
December 15th, 2009, 06:46 AM
I think you should set the pulse width before you enable the waveform. Otherwise it should work quite well. Just look up the range of values: 54274 would be the low 8 bits, 54275 the upper .. 4 bits or whatever the range is.

As for existing music, you have a few different formats. The .MUS files should probably be easy to play but are quite basic sounding. All those .SID files you find in HVSC are harder, since each file contains its own playback routine in 6502 machine code. Many people new to the SID have some difficulty to understand this. Unlike later Sound-Tracker MOD formats, there never was a standard SID music format. All people and companies would make their own data formats and playback routines.

In order to collect them all, the SID player on your PC actually emulates a whole 6502 CPU + 6581 SID + 6526 CIA, possibly even parts of the VIC-II chip. The .SID files contain a common header with song name, execution address and some flags, followed by the actual playback routine. Thus I'm afraid you would need a 6502 emulator for TI-99/4A to have any chance of playing those.

Raven
December 15th, 2009, 08:03 AM
Not that I personally could make use of this, but you should post a circuit diagram.

marc.hull
December 15th, 2009, 03:16 PM
<The .MUS files should probably be easy to play but are quite basic sounding...>

Well as far as basic sound goes perhaps you need to listen to some TI music to really understand basic. ;) Thanks for the tip on pulse rate, I'll check it out when I get a chance. I just bought the Compute! Music System Book from Ebay so perhaps that will shed some light on the situation.

The SID Player.64 file system may seem straight forward on the surface it does include a lot of mnemonic commands in the files themselves that seem fairly cryptic. I found a reverse engineered data sheet of sorts that shed some light but it will be a while until I even understand what the player is capable of doing much less what it is doing.

Anyhow thanks for the tips and if there is a .MUS expert reading I'd appreciate some proctoring....