XaiJu
JOTEGO
JOTEGO

patreon


Sound Timing Explained

As you know, sound is a repetition phenomenon. Each note is a complex waveform repeating at a given frequency. And the music itself advances at a fixed pace.

In all the CAPCOM cores released so far, the sound frequency source was closely related to the rest of the system: a pixel clock was the basis for all clocks in the system. Including the sound synthesizer and the sound CPU. Once the sound synthesizer is fed a fixed frequency clock, it can count cycles in order to produce sounds. So if your input clock is, say 1MHz, and you produce a high voltage every 500 counts, and a low voltage for the next 500 counts, then you are producing a 1kHz signal. That is the very core of digital sound synthesis.

But the CPU also needs to be aware of time. If the music runs at 100 beats per minute, the CPU needs to count precisely that time. But the CPU does not have dedicated circuits to count clock cycles so if you try to count in a software loop you will find that it is very hard to make a fixed duration loop of instructions.

The solution is to use interrupts. Yamaha knew it and prepared its chips with dedicated counters that generate a pulse at a pin, which the CPU can use as an interrupt. If the CPU tells the synthesizer to produce a note and knows that the next note should come 14ms later, it can just tell the synth. to produce an interrupt at that time. Very elegant, but that's not the way Ghosts'n Goblins, GunSmoke and all the others seen so far worked.

For those games, even though the YM2203 can produce interrupts, the engineers at CAPCOM decided to provide the Z80 CPU with a fixed frequency interrupt. Usually at ~240Hz. The music driver used these interrupts to progress through the music score and send the note data to the YM2203.

This is a straight forward method. Easy to understand and program but limits the sound resolution. You cannot accurately produce sounds that require control better than the 240Hz resolution. As CAPCOM started trying new technologies (M68000, higher resolution) they also welcome the YM2151 and for the first time tied the IRQ pin (interrupt request) to the Z80 INT pin, making it possible to produce a wider variety of sound effects and instruments.

The schematic diagram shows the connection between the YM2151 and the Z80 in Bionic Commando (1987). Bionic Commando is CAPCOM trying a new CPU (M68000) for the gameplay and a new synthesizer while keeping the best of the previous video technology.

Sound Timing Explained

Comments

I like your posts. It reminds me of early days mame dev logs which I liked to read back in the day too.

Manuel Antoni

Like SJohansson said: rocket sience for the experts, but very interesting lecture for the novices. Many thanks for that. This is giving us a deep look behind the curtain.

Oliver Jaksch


More Creators