So what you are saying is that you can program the SPC, but don't know how to make a fully functional sound engine ?
Well then you should fist think how your tracks are going to be stored.
Then you need to have a routine that is called regularly in time, using one of the SPC timers. How regularly is up to you, but a faster routine can be used for more precise effects, but you might not want to spend a lot of time optimizing your code for speed if it's the first time you write a sound engine so make it not too fast or it'll end up lagging anyways. (if the timer has already overflown when your routine returns to your idle loop, the routine will be called a second time etc... and the music will play gradually slower as the engine takes too much time to execute).
In your routine you'll need to do a loop for each track that decrease some kind of counters, and if they are down to zero, treat the next event in the track (be it a note, rest, or effect command, etc...)
You'll also need a pitch table. Since samples can be recorded at different pitches, it's more complex to do than, for exmaple, on the NES. There is several ways arround this, for exmaple have a generic pitch table of a lot of entires, and have a different offset for each sample. Also you only need a table for the highest octave (pitches 0x2000 to 0x3FFF) because lower octaves can be derived from it by shifting the value right.
You should probably first try to play simple melodies without effects, don't use echo or such effects on your first try. Also an ADSR enveloppe of 0xFF, 0xE0 will mean basically no envelope effect (full sustain forever) so you might want to keep that in mind for your first experiments, before implementing something more sophisticated.
One thing you should be very careful is to delay key-ons by a "frame". If you change a note from another and key off and on on the same frame, there will have a click sound, so you need to key off one frame, and key on the next frame.
This can be tricky to implement, but it's important to get it work right.
I have successfully written a sound engine for the SPC - and to get pretty complex effects working - and I'd gladly share the source if I didn't lost it ! I can share the compiled SPC but I'm afraid it wouldn't be of much use - not more than a compiled SPC from any existing game.
PS :
Quote:
Serious tech documents shouldn't be written in the first person. If there's something you don't know, just write "unknown". "I never used this" also doesn't mean much unless we know how much experience the writer had with the console.
This is right, however, there were other doccuments that claimed the SPC had 32k of memory, and I remember one where the author started by saying something like :
"I hate, hate the SPC so much, it's such a piece of crap !"
Then why are you writing a document about it ?