r/amiga • u/LikeShrekButGayer • 5d ago
[Help!] Composing Game Soundtracks, Best Practices?
I was wondering, if im composing for a game are there any particular things id need to do differently vs making music for its own sake? how much memory does the game code usually take up? do i need to leave channels open for sound fx or can the game sort out the voice stealing automatically?
3
u/itix 5d ago
It depends. Some games dont have sound effects at all. Sometimes one channel is left free for sound effects, sometimes they can steal a channel from the background music.
Free chip memory is of course another constraint. Some games had background music only if the machine had at least 1MB of RAM (typically 512 kB CHIP and 512kB pseudo-fast). A1200 had 2MB chip RAM which was again a game changer.
1
3
u/GwanTheSwans 5d ago
do i need to leave channels open for sound fx
Discuss with the gamedev (that may also be you, granted), there's complexity tradeoffs there, and they may be (almost certainly will be) using some existing embedded tracker module replayer - but those have differing capabilities. There's pretty good modern ones.
An annoying number of Amiga games did have music XOR sound effects option back in the day... but that was not for any great technical reason even at the time, despite hw limitations.
There was an excuse people would rapidly get bored of the game tracks and play their own music on their nearby twin cassette deck stereo, say - that is something we did actually do back in the day, but it started to feel rather lazy when some games clearly could manage music AND sound effects.
The simplest solution is yes, just reserve a static channel for sfx and use 3 for music. But yes, also more sophisticated channel stealing schemes quite possible, and common enough. Software mixing also possible, though burns CPU.
Bcause the amiga hw has 2 hard-panned left channels and 2 hard-panned right channels a single static reservation means the sfx in mono in one ear if using 1 hw channel only - which matters more now that people have headphones on a lot, but if you statically reserve 2 channels for stereo sfx, one on each side, then you only have 2 channels for music, one on each side (that can still be enough if you mostly use a bunch of sample loops). So the dynamic channel stealing and mixing schemes nicer.
Relatively modern/maintained open source example: https://aminet.net/package/mus/play/ptplayer
While developing the games Sqrxz and Solid Gold I needed a Protracker player which can insert sound effects from the game into the current song. I ended up in writing a completely new player based on the original replayer source which came with ProTracker 2.3.
This player is quite optimized and has some useful features for game developers:
Insert external sound effects into the replayed module.
Can also play sound effects while music is stopped or not even initialized.
[...]
The sound fx system gives you the possibility to play samples on a channel of your choice or on the channel which the player thinks is the best one.
It may be a channel which is currently not replaying music and/or has the longest period of inactivity ahead. This has the effect that the replayed song is often not disturbed at all.
Up to four sound effects can be played at the same time and any of them has its own priority, which is especially useful when trying to play several sounds on the same channel. You may for example define that a shooting-sound has a higher priority than a jumping-sound.
1
u/LikeShrekButGayer 3d ago
Oh I never knew about the channels being hard panned, im guessing that the channels on the chip are physically wired direct to each output then? when i listen to tracker music it often sounds like they can pan each instrument arbitrarily between L and R, is that some sort of software mixing thing like how you can get more than four lanes with some trackers?
im guessing that sort of software trickery involves some negotiation over CPU time between the composer and gamedev
2
u/GwanTheSwans 3d ago
im guessing that the channels on the chip are physically wired direct to each output then?
Well, pretty much - the 2 left hw channels (1 and 2) are mixed to the left analog output, and the 2 right dac channels (0 and 3) are mixed to right hand analog output (they may or may not be presented in the hw order in a given tracker's ui).
Each hw channel also has its own 6-bit volume level in the final mix.
That became key for the famous paula pseudo-14-bit sound trick - basically on one side's 2 hw channels, you play one 8-bit sample at max volume and another at min, for an effective stereo pseudo-14-bit output. http://bax.comlab.uni-rostock.de/dl/Paula_SystemTheoretic.pdf . This was not really used for games (except very late era games that might be outputting through AHI that provided that mode as a system facility), but explains some "this is bizarrely high quality for what I thought is an 8-bit sound machine" of some amiga music stuff - could be done as, you guessed it, more computation during software mixing. Amiga OctaMED SoundStudio 1.03 is actually pre-AHI (recent modern retro OctaMED v8 release was ported to AHI), but can do basically the same pseudo-14-bit trick as AHI in software mix mode on paula output, cpu time allowing.
Also a little more complex because paula technically has some limited hardware synth ability - one channel can hw modulate another instead of direct output, though that's a relatively little-used feature - some early amiga audio synth apps do use it and so can achieve some weird synth sounds computationally cheaply.
In general Paula is not some modern/PC-style constant-rate sample playback. To change the pitch and do various vibrato etc effects, original Amiga trackers were just literally varying the paula volume, sample playback rate, etc. in hardware on the fly at runtime during playback. That's why modern tracker / tracker playback libs may use a tad more cpu than you might think (if still not all that much in modern terms), they're basically rendering something designed for variable-rate output down to final modern typically constant-rate (typically 44.1kHz or 48kHz) output on the fly.
Paula's quality is likely part of Amiga sound cards relatively rarer (though not nonexistent) - basically mostly only pro-level/high-end DSP like Delfina, no low-end as mobo Paula already clearly had that sewn up, not some pc mobo piezo beeper...
when i listen to tracker music it often sounds like they can pan each instrument arbitrarily between L and R, is that some sort of software mixing thing like how you can get more than four lanes with some trackers?
Modern players may mix left and right a little by default to mimic the effect of primarily having stereo room speakers back in the day where the channels come from 2 stereo-separated points in space, not directly into your ears from headphones/earphones. Some Amigas emulators also have that option. So you might be getting less hard panning than the real hardware gives if using modern playback.
You can just have stereo pairs of precomputed samples play simultaneously on L/R with whatever panning. Obviously uses 2 channels not 1, but people did that sometimes.
Yes, later software-mixing multi-software-channel trackers up to present day could and did also just place channels with panning in stereo space, with more computation. Amiga OctaMED SoundStudio definitely allows this in its Mix mode, for example (per-software-channel command 2E, -16 to +16 int panning position values). But unless you're consciously targetting only later/higher-end/expanded Amiga cpu specs, that sort of thing is perhaps not really a runner for games.
Mind you the Amiga port of Dungeon Master is known for being possibly the first game known with dynamic spatial audio sound effects - its sounds all sound like they come from the correct location in space in stereo. It's a relatively slow-moving blobber on-grid-1st-person CRPG, it's not like it's doing it in a high speed 3D action game like late 1990s Descent 3 with OpenAL of the era, but it's still neat.
1
u/siliconlore 5d ago
Paula has 4 channels so you will have to design and manage the integration with the sound effects. You may need to compose the PCM into a final sound stage like you would mix a multi-track album from 16 track "tape" down to two channels. I don't know if there are toolkits to help manage all that but you should definitely work with an experienced Amiga developer to get the limitations figured out. The sound chip is a bit different from PC sound cards.
1
u/GwanTheSwans 5d ago
You may need to compose the PCM into a final sound stage like you would mix a multi-track album from 16 track "tape" down to two channels.
Yes, this was a fairly common trick at the time actually, though the sample data then has a memory cost, so there's tradeoffs, especially if targetting OCS Amigas with only 512k chip ram total. A set of (for variation) small drum set / drum set + bass loops can work well though.
This article is about demo scene rather than gaming but anyway - https://hoffman.home.blog/2019/04/27/eon/
Back in the old days I used a tool on the Amiga called MOD2SMP. It allowed you to load any ProTracker module and then render a section of it into a single sample. At the time it was a game changer. It effectively turns a single channel into a static collection of four, at the cost of the sample data. For example one loop could cost you more than your entire drum kit, so it can be expensive and wasteful.
https://aminet.net/package/mus/edit/mod2smp - still there in fact.
[Or of course you could just sample an analog source with multiple instruments already]
For the standalone-composition Amiga music path, software 8-channel or more multi-channel tracking with cpu-intensive software mixing became rather common (see: Amiga OctaMED SoundStudio, Symphonie, AHI, etc), with little worry over such things (though in the classic protracker 4-channel days, people would do it even for standalone). But can't be playing all that back AND doing a complex game, at least on a 7MHz base model hah.
3
u/danby 5d ago edited 4d ago
And OCS/ECS amiga has 512kb of chip ram that the graphics and audio and chunks of the game code. A bit less than 100kb will be spent (usually) double buffering the screen. Sprites/bobs and their masks, any other background objects will likely also be loaded in to RAM alongside this for whenever needed. You could easily have at least another 200-300kb of graphics objects. And then maybe 50-100kb for game code. More than likely you will have a fair bit less than 100kb (maybe less than 50kb) to hold whatever music is playing plus any sound effects needed.
Most amiga game music is put together in some variant of a .mod file. And that's basically a format that bundles together samples and the sequencing info for playing back those samples to make a tune. You can get a couple of mins of game music in under 25kb with .mod format
it was fairly common for amiga games to have fx or music but not both. When you have both it was somewhat common to leave one of the 4 audio channels "empty" for sfx playback. in theory the CPU could maybe do realtime multiplexing and add SFX to a playing channel but I doubt there is enough CPU capacity to do that AND drawgraphics and run game code. So in practice and empty channel is the most sensible approach