Audio, Design

Advanced Audio for Compy: FM synthesis and more

As I said in my post about the dual POKEY included with Compy, I’ve been in the search of the advanced audio option for this 8 bit computer and I finally have made a decision! But as I love telling stories and retrieving some knowledge from them I will explain the whole process, the candidates chosen and finally what is the final decision. Well, if you are in a hurry just skip to the end.

I think Compy should encourage people to experiment, write their own programs, port games from other systems and make better versions of them. To accomplish this, in the audio area one would like to have the simplest way to produce a sound and at the same time to have the flexibility to create interesting sounds and music. It’s hard to have both at the same time, that’s why I started with the POKEY, because it allows one to create a sound just writing two values containing the frequency, type of sound and volume. Just as simple as that. This is the simplest way to produce a sound.

Creating more complex sounds with FM Modulation

Now, what is the way to create more interesting sounds? Here comes FM or Frequency Modulation, a technique to alter a simple wave using other waves called operators or modulators. These operators usually come in configurations of 2 or 4 operators per channel. This technique is frequently combined with envelope modulation, a technique to use the same base wave to produce different kind of sounds, for example a piano like sound and a violin like sound can be built from a similar sine wave, where the only difference is how quickly the sound reaches its highest volume before decaying. This is known as Attack/Decay/Sustain/Release or ADSR envelope.

FM synthesizers were the rage in the ’80, just in the time where Compy is designed to be based on! There were popular ones like the Yamaha DX7 used in professional music, and the ones inside arcade machines and computers from the late ’80 and early ’90.

But we are skipping a beat here.

The Programmable Sound Generator: PSG

Before going full into FM audio there is a middle ground – and this is very important if I want Compy to make it easy to port games from popular computers like the ZX Spectrum, Amstrad and (maybe) the MSX machines.  There was another extremely popular sound chip that was used in these machines and even bigger ones like the Atari ST: It’s the famous PSG, also known as the SSG, the AY-3-8910, the YM2149, Ben Sobel…Leone, Benny the Groin, Elmer the Fudd, Tubby the Tuba and the fuckin’ doctor. That’s it, bada-bing, bada-boom, very good.

The PSG is a three channel sound chip that can create pure square wave tones or noise with ADSR. It’s simple like the POKEY and it has a distinctive sound but most importantly, it was widely used. Think that the first version of Castlevania called Vampire Killer in MSX had its well known spectacular music coming from a PSG. A lot of games from Konami and other companies like Compile made an impressive use of this simple sound chip, so in some way the PSG must be included in Compy.

Hold on and you will see that this interruption will make sense at the end.

Yamaha FM audio alternatives

Coming back to FM audio there are a lot of alternatives to choose from. In this case it would be very tempting to choose the most powerful FM sound chip around, but this would not be realistic for a computer from 1988, it would give it an anachronistic sound. Also the programming interface must be simple enough to allow the 6502 or the z80 to handle it, the only permission that I would give is to use a higher frequency clock just to allow the computer play a song while running a game, if not, the CPU would only be able to play a song and nothing more.

Yamaha has several FM chips, and after studying all of them, I considered only these ones: OPL, OPLL, OPL2, OPL3, OPL4, OPM, MSX-AUDIO, OPN, OPNA and OPN2

From that set of sound chips and considering the characteristics of this computer I discarded OPL3, OPL4, OPN2 and OPM for being just too advanced, they are more appropriate for the next CLC-92 computer.  Basically the OPL3 is an stereo OPL2 with twice the channels and more wave forms, it was used in the popular Sound Blaster 16 (I told you it was too advanced for 1988). On the other hand the OPL4 is an OPL3 with wavetable synthesis from.. 1993. Totally out of the Compy timeframe. The OPN2 was used in the Sega Genesis, a 16 bit console, and finally the OPM is a special case…

The OPM (YM2151) is a sound chip from 1983, but it is quite powerful! It is like an OPL3 but with less channels. It was used in the Sega System 16 arcade board (Out Run) and the X68000 computer which is a computer from the 32-bit generation, just too way into our future. Even when the OPM is from 1983, it would cost a fortune to have that one in a home computer in 1988.  Now, I know that the Commander X16 by The 8-bit guy will use the OPM but they had their own criteria to choose it.

This shortens our list to: OPL, OPLL, OPL2, MSX-AUDIO, OPN and OPNA

The chosen one

The OPL is quite interesting, this is the foundation of all PC FM audio cards that started with the Adlib and continued with the Sound Blaster. The OPL has 2 operators per channel and nothing more. It was used in some early arcade machines like Bubble Booble and the C64 sound expander. It is a great option for Compy.

The OPLL is a cost reduced version of the OPL. Basically it is an OPL with 15 predefined sounds, meanwhile the OPL is fully programable. Now it may seem quite limited but it was successfully used in the MSX-MUSIC expansion and the Sega Master System console. There are some interesting tunes made with it. It’s a good option for Compy, but OPL is better.

The OPL2 is an improved OPL with more waveforms and additional algorithms. This sound chip was what made the Adlib the standard FM audio for PCs, and it is included in some way or another on every PC computer up to today. It’s quite versatile and using good programming you can make a masterpiece with it, the music made by Vibrants and games like Tyrian are the best examples of what can be achieved. Unfortunately this sound chip also has the characteristic sound of bad programmed music, and it is quite hard to not think of a PC game with horrible music when listening to it. It doesn’t add something new to what we already have been listening for years so that makes it quite boring. I discarded it for all that.

The MSX-AUDIO is basically an OPL with PCM sound. This is: samples!  You can combine your FM Music with real sounds like short voices or drums, which is what it is most used for. The PCM part is not like what we have today but it is ADPCM, a sort of compressed PCM that can use less memory with a little reduction on quality. This option is more interesting than the OPL one.

The OPN (YM2203) is a quite different beast from 1983. While the OPL is a 2 operator chip, the OPN has 4 operators like the OPL3 only with 3 channels instead of the 9 that the OPL has. So it has better sound than the OPL only that it has less channels, but hold my beer… it has 3 additional channels from a PSG!! I told you that this would come back! This is the perfect combination to have 6 channels with FM and PSG in the same chip. This sound chip was used in the NEC PC and some Sega boards like Hang On and Space Harrier. This is the perfect candidate for Compy but oh wait.. oh wait.. oh god lord please wait…

There is one more chip, the OPNA (YM2608). This is backwards compatible with the OPN but with big improvements. First, it has 6 FM channels that are compatible with the OPN, it also has the 3 PSG channels and grab to your seat because – por la cresta que es bueno este chip – it has 7 ADPCM channels. In its original design 6 ADPCM channels are connected to a ROM with predefined drum sounds and 1 ADPCM channel is user programmable. Using this chip you can have incredible good FM music combined with PSG and ADPCM. Quite a beast!!

The OPNA was used in the NEC PC computers and the japanese musicians made it shine with their music. It totally adds a new dimension to what we are used to listen from computers without moving away from 1988. When you hear it, you hear the ’80.

As you may have guessed, the OPNA is the selected sound chip for advanced audio in the CLC-88 Compy. There are emulators written for it and there are FPGA cores as well. The music made for the OPN (YM2206) will also be playable using this chip. Most importantly there are FM trackers that can be used to create new music or port existing ones… I only need to port the players to the 6502 and Z80 but that’s another story.

Now, I must admit that 7 ADPCM channels can be an overkill and probably I will use only one ADPCM channel. Also the design must consider probably 256K of additional RAM that will be directly connected to this chip without using the system bus. The programs must upload the ADPCM data to this exclusive memory and send commands to the chip to replay this data.  The other part, 6FM + 3PSG is just perfect.

Now, just listen to these videos to have a sense of what this baby can do.

(I know what you may been thinking… the OPNA seems more advanced than the OPM which I discarded, well the OPM is already used in the CX16 and it doesn’t have a PSG, so let’s bring something new to the table)