Lived 3D

Technical Art Ramblings

  • BLOG
  • Privacy Policy

SeaBomb – Make Some Noise (3D sound effects)

Make Some Noise Header.

I've spent my whole life training myself to ignore audio in games. Don't get me wrong, I realize it's an important and enriching part of the experience. However, when you are a young teenage boy, staying up late at night to play Diablo II for the umpteenth time, you get used to sneaking around with the volume at zero. “Why not use headphones?” you might ask. Well, when your trying not to get caught, you need all your senses to detect your parents creeping down the hall, about to execute a no knock raid! I'm an adult now (wife/editors note: debatable), and sadly that training has carried through. My computer space is in a shared study area with my wife's desk nearby. So once again, zero volume on my side, and I guess the headphones stayed off out of sheer force of habit.

This persistent training has led to me having no appreciation for sound effects or music in games. In fact, the first game I ever wrote came entirely without any sound, and I was totally OK with that. So I guess that makes this post kind of a big deal for me. Part of this whole exercise is making a complete game, so I can appreciate every single facet of game development. This game can't ship without sound, and because of that, I've had to force myself to put the damn headphones on, and start to marvel in the glory of video game audio!

Sound FX and 3D Audio

There wasn't much tricky work to tackle here, just a whole lot of grunt work. I quickly settled into learning Audacity, and creating two placeholder sound effects (I say placeholder, because basically so far I suck at this, and I'm hoping I'll get better by the end of the project :P).

I then got down to all the grunt work:

  • Built the asset factory for verifying the correct WAV format, and building the game file.
  • Added a SoundManager system for taking care of XAudio2.
    • Added PlaySound(AssetID soundEffect)
    • Added PlaySound(AssetID soundEffect, Vector3 position, float minAttenuation, float maxAttenuation);
    • Added a component for a listener, and attached it to my ship, constrained to looking in the direction of the camera.
    • Added a component for ambient 3D sounds, with a few options:
      • Loop
      • Play Once on Enable
      • Play On Enable
      • MinAttenuation
      • MaxAttenuation

It took a bit of time after work each day, but within a couple of weeks I had 3D sounds playing. I haven't really gone into any specific details on implementation because the SharpDX example projects more than cover everything needed. Just take a look at the “PlaySound” project for an example on XAudio2, and the “BipBounceApp” for an example on 3D audio:

  • PlaySound.csproj
  • BipBounceApp.csproj

One nice surprise, was the 3D audio makes it much easier to track down a stray base, as you can hear where the shooting is coming from! Who would have thought? Sound FX adding meaningful impact to game play. Guess I've been really missing out for all those years.

No video for this post, my Audacity skills are currently so bad that I wouldn't subject you all to that!