0
\$\begingroup\$

Some time ago I found that the audio of a game called Ninja Gaiden 1 (NES) is around 1 hour. This is excluding the sound effects like jump and hit e.t.c. Then I found that the entire game size is actually quite small and the sound data is not stored as actual sound samples. Rather, it is stored as "instructions to a sound chip". This makes the whole thing look mysterious to me.

How precisely was game music stored during the 8-bit console era that made it possible to store so much music without exceeding even 1MB of space in hardware??

\$\endgroup\$
  • 8
    \$\begingroup\$ This seems like a better fit for the retrocomputing SE. It is a fascinating topic, though! \$\endgroup\$ – Hearth May 28 '19 at 23:44
  • 2
    \$\begingroup\$ FM Synth chips compressed music to 64kB per hour with only a few voices. MIDI is about 24KB per minute with 24 voices. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 May 28 '19 at 23:59
  • 5
    \$\begingroup\$ how do you store music on a sheet of paper? \$\endgroup\$ – jsotola May 29 '19 at 3:00
  • \$\begingroup\$ FM Synth chips? FM as in FM radio? \$\endgroup\$ – quantum231 May 29 '19 at 21:54
6
\$\begingroup\$

Each console had a few channels, each with a different "instrument" built into hardware and set in stone. It's not like today where you literally just record the audio. It was more like sheet music that the console reads and plays. Sometimes they had to shuffle things around the different channels to make things work. It was kind of like how vector graphics are to a bitmap.

I don't think we're not supposed to do video links here, but this video explains it far better than in text:

https://www.youtube.com/watch?v=q_3d1x2VPxk

\$\endgroup\$
  • 1
    \$\begingroup\$ Some sound chips as the Commodore SID had been quite versatile for their time already. \$\endgroup\$ – Janka May 28 '19 at 23:39
3
\$\begingroup\$

Old devices have a sound chip of some sort, also known as programmable sound generator (PSG). Usually there are a few channels or tone generators, each with registers for things that describe the tone like pitch, volume and waveform selection. The game has a piece of code know as sound driver or music driver, which reprograms the registers according to the played song data. The song data just contains usually instructions what note to play on which channel and how much time until a note is turned off, much like paper music sheet or MIDI. Most likely the format is not MIDI because custom formats are more compact and different formats suite better for different features of different PSGs.

\$\endgroup\$
2
\$\begingroup\$

Mostly, the CPUs didn't have to tick out the sound pulses; they had an ASIC to generate the tones - you just had to tell it to turn on, which tone, and any modulation it was capable of. It would stay on until turned off.

So what you did in software is watch the time, and set or disable the tone generators at appropriate times.

Typically you made a table of tones+modulations and time durations, optimized for compression. The on-vertical-blank subroutines crawl that table, timing out each note, and telling the ASIC to change or quiet notes at a particular time.

A diatonic scale is 7 notes per octave, a chromatic scale 12... so 5 bits (31+silence) supports 2.5-4.5 octaves depending on how many flats, sharps or keys you support. Add 3 bits for duration and you've packed a primordial channel into a table of 1 byte width, in a super simple programming language. I mention that because you could make the "language" more complex if it makes the table smaller.

MIDI has way more complexity than is needed; there's no reason to support it when table space and code bandwidth is at a premium.

\$\endgroup\$
-1
\$\begingroup\$

Old games used a MIDI system (Musical Instrument Digital Interface) for sounds, so the recording was not an actual audio track, it was a file of the sound COMMANDS that would go to an FM Synthesizer to recreate the sounds, often only 2 channels. That made the sound file relatively small, but what we would now consider "primitive" in terms of sophistication.

\$\endgroup\$
  • 3
    \$\begingroup\$ Did 8-bit consoles actually use MIDI? MIDI seems far too flexible for what the consoles were capable of at the time. The Playstation and Nintendo 64 were using still using MIDI all of its music is far more varied and sounds far better than the 8-bit consoles. \$\endgroup\$ – DKNguyen May 28 '19 at 23:19
  • 1
    \$\begingroup\$ @DKNguyen They did not actually use MIDI, no. \$\endgroup\$ – Hearth May 28 '19 at 23:44
  • 1
    \$\begingroup\$ This is incorrect, for a number of reasons. First, MIDI never came into it, though the principle is similar. Secondly, FM synthesis was not universal by any means and the earliest consoles did not use this method. FM synthesis has a distinct sound, and is why the Sega Genesis/Megadrive sounds so different from its competitors. Thirdly, I'm not aware of any widely used sound chip that had only two channels. The SID had three (four-ish), the 2A03 had five, the SN76489 had five... \$\endgroup\$ – Hearth May 28 '19 at 23:48
  • \$\begingroup\$ Sound chips did not work with MIDI data. If the music was stored as MIDI, the music driver would have to read in MIDI data and reprogram the sound chip registers with appropriate values to play tones. While possible, it is unlikely and more efficient custom music formats were used, as CPU time was better spent elsewhere than interpreting MIDI. \$\endgroup\$ – Justme May 29 '19 at 5:14
  • 1
    \$\begingroup\$ On PC, Philips SAA1099P aka GameBlaster, Yamaha YM3812 aka OPL2 aka Adlib, Tandy 3-voice which is a standard sound chip. On C64, the SID, on Atari, the AY-something. On NES, the 2A03. On Amiga, the PAULA. \$\endgroup\$ – Justme May 29 '19 at 22:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.