# Need to programatically muffle game sounds

So I work on a multiplayer game that is set in space. There are essentially two environments for players to be in: inside a sealed space station (where there is air and thus sounds) and outside the station in the vacuum of space (where there is no air and no sound to hear).

For a while now, we've had it so that you cannot hear any of our game's sound effects while floating in a space with no air, and while that might be realistic, it's not very fun when the game is completely silent sans background music.

I'd much rather find some way to dynamically distort the sounds on the fly before they are played so that they seem to be muffled or dampened. I have no sort of background in making sounds or doing much of anything with them and all my searches have amounted to nothing; mostly finding things about sound editing programs.

The project is made in a C based language for game programming that is really obscure called Dream Maker or Byond. I can't seem to find any built-in features that are able to solve this problem for me. Any help would be much appreciated.

• Thinking of an astronaut in space – not sure if that is the case – they should listen anything that happens in the suit. So... breathing. Also, they should be able to hear, sound effects of things they do, although those probably won't sound the same. And finally, is there radio communication? Well, probably not, however it is something that could be used to great effect. Yes, I know this does not answer the question. – Theraot Sep 21 '19 at 10:10
• Some audio libraries (like OpenAL with EFX) allow you to use filters to play with the frequency response of a sound. You can use a low pass filter that attenuates or drops frequencies above a certain value to get the muffled effect. Try 300hz for a start. – Romen Oct 21 '19 at 19:48

A simple approximation for muffled sound is reducing the volume based on frequency.

High frequency sound is dampened more than low frequency sound.

Imagine standing in the street near a discotheque.... you hear base thump, but not the higher frequencies.

So with an equalizer, do something like this:

  |    |    |    |    |    |    +6
|    |    |    |    |    |
|    |    |    |    |    |
|    |    |    |    |    |
|    |    |    |    |    |
[=]   |    |    |    |    |     0
|   [=]   |    |    |    |
|    |   [=]   |    |    |
|    |    |  [=]    |    |
|    |    |    |   [=]   |
|    |    |    |    |   [=]   -6

base                    treble


You need to do this filtering in the frequency domain, or maybe your sound library has a provision for this.

I think the simplest way to do this, at least as far as programming goes, is to have two sets of audio resources and switch between them. Not a great solution, I know.

I would argue for using OpenAL, or similar (DirectSound, for example). They already do some effects. There are also libraries for use them, making them easier to use or adding extra features.

As per Byond, the sound function takes a file name, and can do a few effects out of the box.

A simple effect you can do with what comes with it is to lower the frequency, lower the volume and add echo.

I found a couple Byond libraries that are either useful, or worth to study to figure out how to manipulate audio in Byond:

By the way, I am not familiar wit that syntax. You say this is C?

Baring that, to be able to apply effects in real time you will need to be in control of loading the audio buffer for playback. Any good old playback library will do. What matters is having the the opportunity to manipulate whatever you read from your resources before you send it to the audio buffer.

Assuming you have such playback library, what you are looking for is programmatic signal processing, programmatic audio signal processing to be more precise. I suggest to pick a library that already has them built in. Baring that, one that can do fast fourier transform and its inverse.

I think many people began by reading RIFF WAVE format (.wav) and working from there. However, given that that is an uncompressed format (which is great for ease of reading), you probably want to work with something else... for example Ogg files.

Try the library libsndfile, which sould allow you read multiple free audio formats (the linked page also has a list of a few similar libraries).

I found a couple documents that could help you implement some of those effects (assuming you are not using a library):