Jump to content
IGNORED

How are sound effects and music programmed?


Recommended Posts

For some reason, I doubt that when programmers program music and sound effects for their games, they use raw assembly language. Is there a tool or other program that programmers use to program sound chips such as the SID or the OPL series?

Link to comment
Share on other sites

1 hour ago, bluejay said:

For some reason, I doubt that when programmers program music and sound effects for their games, they use raw assembly language. Is there a tool or other program that programmers use to program sound chips such as the SID or the OPL series?

Any chip is going to require some parameters that the chip understands, and maybe a stream of sound data.   Any decent language will allow you a way to write to the sound chip's ports directly or maybe provide an API to make the task easier

  • Like 1
Link to comment
Share on other sites

Hmm, and the programmer just has to be really good at programming music using generic commands? I would have expected a program to let you compose music in a more... musical way, and outputs raw data that can be inserted into another program or whatever.

Link to comment
Share on other sites

38 minutes ago, bluejay said:

Hmm, and the programmer just has to be really good at programming music using generic commands? I would have expected a program to let you compose music in a more... musical way, and outputs raw data that can be inserted into another program or whatever.

Not necessarily,  in the case of the OPL series,  plenty of games would play midi music,  so the programmer would just initialize the sound chip and tell it what music to play.   There are plenty of apps to let musicians to compose midi songs.

 

The 8-bit systems were very limited by memory, so they didn't really have fancy APIs, and often the programmer would be sending music note-by-note.   But I did find a utility that could play already composed songs in the background from a BASIC program on the Atari.

  • Like 1
Link to comment
Share on other sites

That’s rather depressing. The computer I am designing has a YM3812 and I was wondering if there was some easier way to program music apart from programming it byte by byte.  Apparently I’ll be doing some tedious work now. 

Edited by bluejay
  • Like 1
Link to comment
Share on other sites

6 minutes ago, bluejay said:

That’s rather depressing. The computer I am designing has a YM3812 and I was wondering if there was some easier way to program music apart from programming it byte by byte. 

Is that a PC with an Ad-lib, or something else?

 

I'm sure there are tools out there to make it easy for programmers.  

  • Like 1
Link to comment
Share on other sites

Essentially there are two ways to make music:

 

1. Develop a player/tracker routine that reads binary data in some higher order, translates those into frequencies and timed loops when to shift notes. Like it was mentioned above, you then send parameters regarding e.g. frequency, volume, envelope, waveform to the chip in due order. Each musician/programmer tended to have their own music format and player, which is why e.g. High Voltage SID Collection consists of thousands of C64 programs where usually the video and I/O sections are stripped off, so all the program does it playback music. A SID player then emulates the 6510, SID chip, RAM and other peripheral chips enough to have the program executing.

 

1.1. Like above, but with a standardized music format like MIDI or SoundTracker modules. In that case the music data and the playback routine are more separated, but may to a lesser degree take advantage of the sound chip capacities.

 

2. Stream sampled data directly from memory into the sound chip. This is costly as you know, a few seconds of data at a reasonable sample frequency and your memory is used up. The SoundTracker modules mentioned above have a library of instruments consisting of often 8-bit samples that can be played at various speeds to generate different notes. The tracker part of the music data contains the actual music, then the instrument sample is looked up to determine at what speed to play it.

Link to comment
Share on other sites

Recently I watched this interview with Rob Hubbard (C64-SID music wizard).

Yes, he programmed in raw assembly. That's probably why some chip tunes are so cool. Direct interaction between custom assembly program and sound chip, done by someone who knows what he does.

In general, he says, he had about 10% of the memory for his tune (the rest was for the game code and the artwork of the other programmers): 10% - That's just 4 to 6K. Probably would be hard to do without manipulating each byte directly:

 

 

The YM3812 seems to be the OPL2-chip in Adlib- and Soundblaster cards. Maybe you could use something like:

http://www.adlibtracker.net

The chip was also used in some Arcade machines. I'm not sure, if you could use a tracker to write music for such a machine.

Wikipedia also says, the chip was compatible to an earlier OPL1-chip, that was used in MSX computers. Maybe you could find a sound program for these.

Edited by Pokeypy
Link to comment
Share on other sites

8 hours ago, zzip said:

Is that a PC with an Ad-lib, or something else?

 

I'm sure there are tools out there to make it easy for programmers.  

Thanks everyone. It's a 6502 based computer. Decided to put a YM3812 in it because it seemed like the most logical choice.

8 hours ago, carlsson said:

Essentially there are two ways to make music:

 

1. Develop a player/tracker routine that reads binary data in some higher order, translates those into frequencies and timed loops when to shift notes. Like it was mentioned above, you then send parameters regarding e.g. frequency, volume, envelope, waveform to the chip in due order. Each musician/programmer tended to have their own music format and player, which is why e.g. High Voltage SID Collection consists of thousands of C64 programs where usually the video and I/O sections are stripped off, so all the program does it playback music. A SID player then emulates the 6510, SID chip, RAM and other peripheral chips enough to have the program executing.

 

1.1. Like above, but with a standardized music format like MIDI or SoundTracker modules. In that case the music data and the playback routine are more separated, but may to a lesser degree take advantage of the sound chip capacities.

 

2. Stream sampled data directly from memory into the sound chip. This is costly as you know, a few seconds of data at a reasonable sample frequency and your memory is used up. The SoundTracker modules mentioned above have a library of instruments consisting of often 8-bit samples that can be played at various speeds to generate different notes. The tracker part of the music data contains the actual music, then the instrument sample is looked up to determine at what speed to play it.

I'll look into SoundTracker to see what use I can make out of it. It seems to be made for PC or Amiga, but maybe it still be useful in some way.

 

Otherwise, I'll have to make my own program or just program the chip byte by byte... Hope I won't have to do that.

Link to comment
Share on other sites

I've never used the YM3812 but if you need a somewhat "simple" 6502 music player routine, send me a PM. I have used essentially the same routine on VIC-20 (6560/6561), Plus/4 (TED) and CreatiVision (SN76489). I never ported it to use SID because there is a ton of better routines on the C64. That is assuming the YM chip has a PSG part so it isn't entirely FM and sample based.

 

I'm not sure about OPL1 in MSX, perhaps that refers to Konami SCC, MoonSound or some other expansion. The default PSG in those otherwise is the trusty old AY-3-891x which does square waves fine but no FM features.

 

And yes, by setting up a raster interrupt that once per frame, i.e. vertical blank calls the player routine that handles 1 tick of music, you get a steady speed rather than updating the music in the main loop that may run at varying speed.

Edited by carlsson
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...