Jump to content
  • Advertisement
Sign in to follow this  

[MDX] Playing different wav to multiple audio channels

This topic is 4576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, is it possible to play different wave files to different audio channels with DirectSound? (E.g foot.wav to Left channel and step.wav Right channel) Anyway for the sake of knowing other ways to do this without the use of directX, please include any methods that can implement it. Googled but can't find anything relating to my problem :(..... thanks

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
yes.its possible with directsound.
in fact i did.

Share this post

Link to post
Share on other sites
Hi, if possible do u mind give a brief discription of how to do it? I am kinda lost with the DirectSound api.
Well i did it using the buffer.pan and play the 2 wave files using the same device but each pan to extreme left and extreme right. I have met my objective but are t here anyway to do this like i can just set it to be channel 1 or channel 2 so i dont have to programatically pan it

[Edited by - hyper88 on April 5, 2006 8:16:16 PM]

Share this post

Link to post
Share on other sites
i post the message as Anonymouse.... i dont know why..hmmmm
i am the guy who post the first reply.
ok ne way.

make tow DirectSoundBuffer for each channel u wish.
the buffer make with WAVEFORMATEXTENSIBLE structure;
(this is difference of normal initialization)

////////loading wav///////////////

dwChannelMask can be SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or ....channel flag u wish.(see mmreg.h)

#define SPEAKER_BACK_LEFT 0x10
#define SPEAKER_SIDE_LEFT 0x200
#define SPEAKER_SIDE_RIGHT 0x400
#define SPEAKER_TOP_CENTER 0x800
#define SPEAKER_TOP_BACK_LEFT 0x8000
#define SPEAKER_TOP_BACK_RIGHT 0x20000

///////creating DirectSOundBuffer/////////////
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwBufferBytes = dwWavSize;
dsbd.guid3DAlgorithm = DS3DALG_DEFAULT;
dsbd.lpwfxFormat = (WAVEFORMATEX*)&pcmWFEXBL;

if( FAILED( g_pDSound->CreateSoundBuffer( &dsbd, &pBuffer, NULL ) ) )
return E_FAIL;

it doubltful u can understand with this poor document.
sorry im japanese.

Share this post

Link to post
Share on other sites
Create two sound buffers, pan them left and right, and start them. That's the easiest way.

The hard way of doing it involves creating a stereo buffer, then loading the wav samples, and interleaving them yourself into a stereo sample. Might be easier to do that in a sound editor tool such as Audacity, than in code, though.

Share this post

Link to post
Share on other sites
I see thanks guys for the help. Anyway if i am to do this for Mp3, i have to use directShow? and i think it will be a completely different thing since there is no waveformatextensible. It is tough to find anything on directShow managed, looks like quite a few interfaces are not exposed.

Share this post

Link to post
Share on other sites
Original post by hyper88
Anyway if i am to do this for Mp3, i have to use directShow?
Yes - DirectSound only supports PCM Wave format data.

Although, I would question the decision to use MP3 for a simple sound effect. Chances are the overhead involved in playing (streaming, decoding etc..) an MP3 for such a short clip is going to negate any storage advantage.

The general consensus I've picked up over the years is that compressed audio such as MP3 is better for "extended audio" - dialog, background music etc.. whereas regular WAV files are better for short sound effects such as footsteps.


Share this post

Link to post
Share on other sites
jollyjeffers : Thanks for the advice......

Are there any good books on DirectX for beginners but not too easy till it feeds u with all the How to create a header file in vc++? Dev.net books on DirectX seems abit outdated....i mean the published year.

Are those kind of DirectX bible type of books good? Sorry i should have done a search on the forum (i will) but since the thread is already open...might as well get some comments on it too.

Share this post

Link to post
Share on other sites
>Although, I would question the decision to use MP3
smart questuion.and i would say same question.
compressed sounds only have (a bit)advantage(b4 load) of disk space .

Share this post

Link to post
Share on other sites
now i have 4 audio output...2 channels each.. and i have set it if to play the 1st wave it will be buffer.pan = -10000 and 2nd wave to buffer.pan = 10000 and repeat up for 8 buffers. If now i would to play all of them (i.e sound1.play, sound2.play) will the playback be in sync...at least to the human ears? Or are there any methods where we can sync such multiple playback.

I have tested it on my basic sound card with 1 output and 2 channels...it sounded in sync...but when i tried to test the professional soundcard connected to an announcer which accepts multiple audio input and i tried to run the playback...the equaliser UI display dont looked in sync to me..slight differences but i could not test the sound now yet as it is still missing a few settings for it to produce sound.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!