Official development blog

Ambient Sound

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.


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):


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


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


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


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:


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.

The Complete Soundscape (2020)

Update: Years later, Cogmind has a complete ambient soundscape with both map-wide audio as well as localized audio from all machines and other relevant sources using the techniques described above. You can read more about the system here.

This entry was posted in Design and tagged , , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.


  1. Someone64
    Posted January 17, 2014 at 10:57 pm | Permalink

    Will there be walls with different thickness for sound dampening and a sort of turn using ability that allows you to sort of listen harder? Also, is directional sound implemented? If so, the problem is that not even surround sound systems have higher and lower speakers so there’s no way to tell if something is further north or south.

    • Kyzrati
      Posted January 18, 2014 at 6:24 am | Permalink

      As is, walls will most likely always block 100% of sound, or at least close to that. The dampening feature is mostly for doors, which are almost always thinner than cave walls.

      Your suggestion presents an interesting possibility; it would be fairly easy to implement a utility that allows you to hear through one or more layers of wall. It could be constantly active and not require a turn-consuming action (though doesn’t start taking effect until the turn after you activate it, so its energy cost is not free), the only problem being that while active you would have a harder time differentiating what’s going on where so it wouldn’t provide as much useful information as the idea might suggest since directional sound is not a possibility here.

      Technically you can do positional sound with a normal stereo headset through software. It’s called binaural stereo. However, it wouldn’t feel very natural to use something like that since you don’t have a specific facing and the entire game is shown from above.

      The purpose of sound in Cogmind is two-fold: 1) Enhance the atmosphere and 2) Give the player information about what’s happening in nearby areas that may not be within sight. The latter is mostly for getting hints about what might be behind a door or around an unexplored corner, be it robots blowing each other away or a certain type of machine. It will be a lot more interesting to send your allies up ahead to scout around if you can hear them being shot at and/or destroyed as a result.

      Short answer: No directional sound--distance and dampening are the only two factors that matter, and they’re used to determine volume only.

      • Someone64
        Posted January 18, 2014 at 8:42 am | Permalink

        Can’t seem to access this webpage through my Waterfox (yes, Waterfox’s the name) browser which I’ve been using for so long. Maybe it’s the latest Firefox update…? (they usually only update with each new version of FF. I tried emailing you about the problem but got sent back an email with a long error log)

        Anyway, let’s assume Cogmind has a mic that can only hear in mono by default. What about adding a special directional mic part in game that can be deactivated and activated. It both enhances hearing slightly and provides very minor visual feedback on sound sources. Maybe you could use that to determine the direction of a sound source. Maybe also make the part rare and hard to find.

        • Kyzrati
          Posted January 18, 2014 at 10:04 am | Permalink

          Thanks for the e-mail attempt. Not sure what would go wrong there, since I get e-mail at the gridsagegames Gmail address all the time. I just tested about 10 different non-mobile browsers and the site/blog seems to show up fine in all of them. Tested the latest version of Waterfox as well (with a Ctrl-F5 force-reload since I use FF myself), and it loads alright for me. Try a force-reload and/or clear your cache see if it’s some kind of caching/cookie issue?

          Your sound idea is similar to a suggestion today on Bay 12. See my reply there . While I may add some form of sound-related gameplay mechanics in the distant future (along with them might be a system whereby enemies are attracted to sound as well), but for now it’s just going to be used for atmosphere and the general distance and nature of nearby combat and machines.

          • Someone64
            Posted January 19, 2014 at 8:01 am | Permalink

            I was thinking more of a very vague hint as to where a sound is coming from. Just like sort of something that points you towards a sound but doesn’t actually show you the visualization shown above. I also think it would be the kind of energy consuming thing that would be activated sparingly.

            (I seem to be able to access the page through Waterfox but I posted this in Chrome… Not that the Chrome part is relevant to you :P. I haven’t tried emailing you again yet and I will only do so when I really need to, which I don’t. BTW, I have a Bay12 forums account which I don’t use that often.)

          • Kyzrati
            Posted January 19, 2014 at 9:37 am | Permalink

            I like that idea a lot. Better versions could be more accurate. And it could be nice to have that optional extra info. Quite easy to implement as well, so I’ll probably add this in, at least for playtesting. It will have to wait until I’ve implemented a new map overlay system so it can also work with ambient sounds. Spot sounds will be easy, but allowing this to also identify things like machines will be a bit more complicated.

Post a Comment

Your email is never published nor shared. Only the anti-spam entry is required. See here for the privacy policy.

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>