Post news RSS Ambient Sound

The implementation and usefulness of ambient sound in roguelikes.

Posted by on

Sound plays an important role in Cogmind, perhaps setting it apart from a majority of ASCII roguelikes. While sound will likely have little or no direct influence on the gameplay mechanics themselves, it still adds an important dimension to the experience since immersion is the primary focus of the game's design. (Remember, you are the Cogmind!)

There are of course sound effects related to major actions like shooting, as well as other spot sounds like projectile impacts, explosions, terrain destruction, door operation etc., but those don't do as much for the atmosphere as ambient sound.

Each map will feature some amount of global ambiance that reflects your location, be it the factory levels or somewhere deep in the caves. In addition to that we now have a complete system for sourced ambient sounds. These are the sounds that originate from specific props in the environment, like machines. Since we aren't doing videos yet, the only way you can check out the sound is by looking at it =p

Cogmind Ambient Sounds
In debug mode looking at the sound emitted by randomly placed test machines all playing one of two test ambient sounds.

Brighter orange represents a higher volume. You'll see that line of sight is not necessary to hear an object--sound properly turns corners. Each piece of terrain also has its own sound dampening properties, so in this example thick earth walls are blocking all sound while doors muffle sound by 50%, allowing the remainder to continue to propagate.

Similarly, action-related sounds (projectiles, explosions, etc.) all have distance-based volume as the sound takes the least muffled route to the player.

Sourced ambient sound propagation is not static, either, changing as the environment around it changes. This is absolutely essential since the environment is completely destructible and dynamic, not to mention simply opening a door will increase the perceived volume of whatever was behind it.

Cogmind Dynamic Ambient Sounds
Ambient sound changing as a door is opened or wall destroyed.

Destroying a source itself will of course eliminate that sound completely.

The examples above only show how one particular sound travels as its volume drops (a plateau for distance 0-2, then drops off along an inverse curve up to a range of 8 spaces), while in practice different sounds will have different maximum ranges and types of falloff, depending on what's appropriate for the given sound.

Technical

Much of the sound system was copied over from X@COM, but some alterations were necessary due to the different game mechanics.

In X@COM, ambient sounds are heard differently by each member of the squad depending on their location, thus as you cycle through your units you hear whatever the selected unit does. This and the fact that maps were small meant that the best solution was to precalculate all sounds heard across the entire map, and update that only as necessary when ambient sound sources were added or removed.

In Cogmind this method no longer works because 1) maps are going to be much larger and 2) terrain can dampen sound (this effect does not exist in X@COM), which would require too many recalculations every time a door changes state or terrain is created or destroyed. So ambient sound in Cogmind is actually calculated on the fly, where every possibly sound-affecting change to the environment triggers an adjustment to whatever sounds you can hear.

Rather than the usual Dijkstra method used to find all areas within audible distance of a sound (as in the debugging images seen above), each nearby sound source pathfinds to the player via A* (w/heuristics) to determine its volume (or perhaps it can't be heard at all). This is fairly fast, thus one advantage of having a single actor is we can now properly implement sound dampening!

Falloff Models

There are four different types of falloff supported for sound effects (graphs are drawn approximations, not rendered by actual graphing software):

cogmind_sound_falloff_linear
Linear. Good for sounds heard over a large area, to make it easier for the listener to gauge distance from the source.

cogmind_sound_falloff_log
Logarithmic. Good for continuous complex environmental sounds like wind through trees.

cogmind_sound_falloff_reverselog
Reverse Log. Loud sounds like the core of an explosion or gunfire.

cogmind_sound_falloff_inverse
Inverse. For sounds heard clearly up close, but at any distance beyond that only give a hint that they're nearby. Works well for terminals and machines with softer sounds.

I tend to use linear falloff for most non-looping event sounds so the volume holds more meaningful information for the player in terms of relative distance, and rely on log and inverse falloff as necessary for looping ambient samples to make them sound realistic as you approach/leave them. Believe it or not, it's not only 3D games in which there's a noticeable distinction--it even matters when exploring a grid-based 2D world!

Two other important parameters set for each sound are the min and max radius. Max radius is obvious--beyond that the sound is not heard at all; min radius defines the area within which the sound is heard at full volume, i.e. before falloff starts to take effect. When graphed this creates a plateau near the source:

cogmind_sound_falloff_log_plateau
Logarithmic falloff w/min radius plateau.

The sample sound seen in the debug shots further above uses a min radius of 2, hence the bright areas surrounding the sources.

Comments
d2theRizzle
d2theRizzle

this is pure genius! this game is going to be one of the most epic roguelikes ever!!!

Reply Good karma Bad karma+3 votes
Kyzrati Author
Kyzrati

Thanks, hopefully it finds its place among the other epic roguelikes pretty quickly, so that I can afford to push on and make an even more epic one after this ;)

Reply Good karma+2 votes
jakejakejake55
jakejakejake55

man im druling over all this. I cant wait it is a game i was looking for! hey maybe if this is succesfull you could do like a Helicopter rouge like where you could tune it to your liking from the engine type to the hull! but we all know that is way out there. So keep this up! i will download this as soon as its released!

Reply Good karma Bad karma+1 vote
Kyzrati Author
Kyzrati

So many possibilities in the "build something with components" type games! I was considering at one point taking the same concept and applying it to planes--even tried to prototype it, but I was trying to convert the current engine to real time for that and couldn't get it working smoothly. Only worked on it for a couple days.

It's tough to do an air combat roguelike in true turn-based fashion. There is however a turn-based RL that models it fairly well, called Kerosene Thunder, but it's still in early development.

Reply Good karma+1 vote
jakejakejake55
jakejakejake55

Cool is there a link anywhere for KT?

Reply Good karma Bad karma+1 vote
Kyzrati Author
Kyzrati

Google search is your friend. There's a TIGS thread: Forums.tigsource.com

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.