DirectShow vs. DirectAudio help

gardon 101 Dec 18, 2007 at 21:21

What’s the difference? Basically I want sound effects (footsteps, weapon noises) and music (songs) in my game. Is there a difference between Direct Audio and DirectShow? I’ve only started learning audio programming today, so I don’t know where to begin.


3 Replies

Please log in or register to post a reply.

Nils_Pipenbrinck 101 Dec 18, 2007 at 21:51

In a nutshell:

Directsound lets you playback sounds.. And music if you take care about decoding of compressed sounds and filling the buffers with audio data. It will also let you place sound-sources in 3D space and let you define a listener (that can move around as well)… Oh - and you can put some nice effects on the sounds as well..

DirectShow will also do sound, but foremost it will let you playback video and audio files. It will take care how to decode things, how to split all those various kinds of audio and video containers, will download missing codecs from the internet, will open windows for video playback and all such stuff. Unless you take control over what it does you should - as a game programmer - always expect the worst. Want some other kind to overtake ownership of your window or open popup-windows onto your application? DirectShow *will* be your friend..

Got the difference? DirectSound is for Sound Playback, you provide the data, DirectShow does the playback. You have control. It’s a low level Sound API (and a friendly one to work with).

DirectShow otoh is made to playback audio and video streams from any sources. It’s as highlevel as it could be, and in doubt it will ask the user, not the programmer, what to do..

For your application you should:

1st: Get DirectSound getting to work.. Playback some sounds and apply some basic affects.. The DirectX examples will show you how to do this.

2nd: Download the ogg-vorbis libraries and let your application stream and playback .ogg files in the background. You could do the same thing with DirectShow (will only take .mp3 files unless you install 3rd party codecs), but it’s much easier to just leave DirectShow out.

If you’re interested in DirectShow go ahead. I’ve done quite a bit of stuff with it, and it’s a powerfull framework to plug your things in. It just takes a few lines of code to get a video or a compressed audio stream from the net playing, but all this has a cost: you don’t have much control how things work anymore unless you dig very deep into DirectShow.


gardon 101 Dec 18, 2007 at 22:07

Thanks. It seems like Direct Show will be left out then. I’m just looking to add sound effects and have music in the background, as well as take advantage of the 3D space sound effect capabilities.

Putting sound effects in 3D space sounds awesome!

TheNut 179 Dec 18, 2007 at 22:53

“Putting sound effects in 3D space sounds awesome!”

It is, especially if you have a crazy 5.1 setup like I do ;) Boom boom boom ;)

DirectSound 3D buffers will also let you play with velocity, doppler, rolloff, and min/max distance effects. Since it’s lower level than DirectShow, you can play with the audio input and add in your own filters. Another plus to working with DirectSound is that you will better understand audio development and how digital audio works (which is really kind of cool stuff).