AY Crudentials: SID Sound

Probably the most technical forum around. It does not have to be coding related, or assembly code only. Just talk about how you can use the AY chip to do cool sounding things :)
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

AY Crudentials: SID Sound

Post by Twilighte »

SID Sound is a method of reproducing sounds similar to those commonly employed on the hardware of the Commodore 64 computer through software.
In its simplest form, a single SID channel is a software generated square wave that acts on the Volume register and at twice the frequency of the hardware chip tone frequency.

This is generally performed in the interrupt routine.
At each interrupt interval, the volume is set to an alternate value, therefore each interval generates one half of the Waveform cycle.
This is the reason for playing the waveform as double frequency.

The Commodore 64 (C64 or C128) has a very versatile Sound Chip called the SID (Sound Interface Device) and amongst its many features can produce 3 separate hardware channels of square waves whose pulsewidth of each can be changed (at a resolution of 16Bit).

The ability to change the pulsewidth of a waveform permits the sound to be altered by timbre (tone) whilst the pitch and volume remains constant.
Commonly SID tunes used a 'Sweep' routine that cycled through the pulsewidths producing a very dynamic sound.
The dynamic sounds could synthesise electric guitar leads, Dynamic Bass rythms and a plethora of other effects.

SID sound on the other hand is not so dynamic in its simplest form, but does sound similar to this pulsewidth Sweep.
SID invariably acts on the Volume register since this is best to control the final output of the chip channel.
Alternatives to using the volume register include the Pitch register (To produce a fake chord (high speed ornament)), Status Register (I think uniquely used in Pulsoids Game (Status Buzzer)) and Envelope Cycle register (Known on AtariST as Buzzer or Sync-Buzzer).

By using SID as a trigger on the Cycle register, it is possible to generate both higher frequency Triangle/sawtooth waveforms and have a crude control over volume.
The latter is achieved by incrementing the Envelope Period (Which gives the slope less time to rise or fall which in effect reduces the volume.
BSC
Private
Posts: 2
Joined: Mon Sep 28, 2009 10:49 pm

SID sound

Post by BSC »

Hi there,

I accidentally stumbled upon your post about SID sound and I am really curious to learn more about it. I have programmed an AY tracker for the Amstrad in the good old days (you can find some information about it here: http://www.grimware.org/doku.php/docume ... kker/start) and I like the SID sound so much, that I actually wonder if I might go back to the Z80 keys to build a new SID sound capable version. Do you think you could help me with more insight into the "trick" or point me somewhere helpful? Any hint is appreciated!

Cheers,
BSC
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

Hi BSC, i thought the first message was explanatary enough to understand the method. Perhaps i have not explained it enough?
I am not so familiar with the hardware of the CPC but i believe (unlike the Spectrum) it has programmable hardware timers that can trigger interrupts?
If so then SID is relatively easy so long as you have fast access to one AY register.

Let me know what else you need to know.
BSC
Private
Posts: 2
Joined: Mon Sep 28, 2009 10:49 pm

SidAy

Post by BSC »

Hi Twilighte,

I was mainly relating to that part you wrote: "a software generated square wave that acts on the Volume register and at twice the frequency of the hardware chip tone frequency.

This is generally performed in the interrupt routine.
At each interrupt interval, the volume is set to an alternate value, therefore each interval generates one half of the Waveform cycle.
This is the reason for playing the waveform as double frequency."

On the CPC you have 6 interrupts per VBL that you could adjust, but not very freely. I wonder if that's enough to change the volume as needed (I haven't done any math yet ;-)

If I got you right, it works like that: When playing e.g. a sound at 1000 Hz, I have to change the volume 2000 times a seconds, while sequencing through values from the square wave you mentioned?

I also wonder about how that wave form should look like to get a good or any effect at all ...

/BSC
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

I'm not sure if you're not rewriting the wheel on the CPC since i do remember a Channel party (regular demo party of CPC enthusiasts) where the main guy Madrigal or Madrigel did loads of stuff for that machine including 3 channel samples and i believe SID.
You need to priv msg Jede who may have more info.

I guess it depends if u intend to do this on the oric or cpc?
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

I've managed to draw possible waveforms that SID Buzzer is able to produce. These are in a PDF document..

http://www.defence-force.org/ftp/forum/ ... buzzer.pdf

The waveforms are shown as pure outputs of SID so with the AY Pitch square wave turned off.
The code in the bottom left corner of each of the 4 sets refers to the codes entered in the WAVE editor.
These are in no way the total possible waveforms and the actual waveform produced will be very much dependant on the pitch and EG Period chosen.
This is a forrunner document for the upcoming next version of Wave which will support SID in 3 guises..

SID Status
Acts on the single bit of the status register
SID Channel
Classic SID on the Volume channel
SID Buzzer
Tao(AtariST Musician) inspired SID acting on the Cycle register and what the document above is related to.
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

The main drawback of SID was (until last night) that i had assumed only one interrupt could be processed at one time and that overlaying interrupts was not possible. For example the music routine runs on an interrupt and whilst it is executing it interrupts the SID sound from playing.

This is demonstrated in Pulsoids. The sound reproduction of SID is very crude because SID keeps being interrupted by the music needing updates.

So in Wave 200 (still not released yet) i had placed the music routine outside of interrupts and had SID as the only interrupt.
This meant SID ran continuously with minimal audible interruption but on playing a tune and moving around the editor the music slowed down.
Running such an environment in any game would be horrendous, slowing the music at every moment of the game.

So Dbug came to my rescue and suggested that when an interrupt was entered the I flag is set in the Processor Status Register. By resetting this it should allow the Interrupt to be entered again, so permitting interrupt on interrupt. So when the 50Hz Music interrupt occurs the code begins to set up the next musical change but the processor may intercept this routine with a SID interrupt which will then process the next SID change and return to the music routine. At the end the Music routine will RTI and the main code can continue as normal.
It sounds complex but is actually quite simple. The only real complication is when we have finished processing the music change and want to send the AY the changes.

So i wrote a special AY bank send routine which permits the SID interrupt to act at the end of sending a new register change.

Its not tested yet but it looks as if Wave 200 will really work properly and SID will be in Times of Lore, which i'm currently working on again.
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

This is just a little test program i have just written thanks primarily to Xeron.. the first app completely developed on my netbook with Oriculator (which whilst swearing blind) worked perfectly all through testing.

I will use it to calculate the correct Timer (SID) values for each Wave Note. Some might say i could have calculated it but it is always more fun this way :)

The utility allows you to play a chip tone alongside a simple SID square wave on another channel. the Chip tone is represented in music notation B-0 to C-6 and the SID value as a 16 bit hex value from 0000(don't go lower that 0030 as ths may freeze program) to FFFF.

Keys shown on screen.
Not that useful i guess, only to me but hell, i want to show i'm making progress rather than simple promises :P

oops, forgot ftp password so wait a mo[/img]
User avatar
ibisum
Wing Commander
Posts: 1643
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Post by ibisum »

This is really interesting .. I'd love to have a play with this .. what about a MIDI interface, would it be easy to whip up?
Post Reply