Panning sound in dx8 audio/music

Started by
7 comments, last by ByteMe95 21 years, 11 months ago
Ok, I got basic sound playing abilities going now in DX. I''m using dxmusic (I think), the one wit hte performance/loader objects I use PlaySegmentEx to play segments. My Q: How do you get the sound to pan left/right at specified values?? ByteMe95::~ByteMe95() My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
Advertisement
look at tutorial 2 in the sdk, it explains how to create an audiopath object and retrieve various interfaces from it which allow you to pan / position the sound.

i also wrote a tutorial on the topic which you can read if you like at the site in my signature.

HTH
Toby

Gobsmacked - by Toby Murray
Hey, that''s a good tutorial but looks like its more useful for 3d sounds.
I''m making a 2d game so I dont really have positions. All I really want is the ability to Pan left/right
is there an easier way just to pan?

ByteMe95::~ByteMe95()
My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
i suggest looking over the tutorials and interface options. also look into using directsound for actual sound fx, dmusic is meant more for music.

also, if you are not totally sure on the api you are using. this means you probably did some cut and paste coding. read through the tutorials you took the code from and try to understand what is going on. if possible though i would switch to dsound, its MUCH easier to do what you want since its designed for playing sound fx, and there will be more information availible because of the whole right tool for the job thing dsound got going for it.
a person, what makes you think I did some cut and paste work?
I wrote my entire sound playing code on my own based on the dx docs.
And if you read through the dx8+ docs you might notice that THEY even write that it is better to use dxMUSIC for ALL sound, including soundfx, from now on and that dxsound is becoming obsolete.

ByteMe95::~ByteMe95()
My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
excuse me, sorry about that. the sentence fragment "I''m using dxmusic (I think), " threw me off. i stand corrected about directmusic being the api of choice in dx8 (have not done much with sound in dx8 yet). i have alwaysed use dsound and not have much in the way of problems. thank you for pointing me to dmusic (i would have never even looked at it because of dsound not causing much problems and thoght that dmusic was meant for music like in the older versions).

dsound though is not obsolete, just getting depreciated. after skimming how to use dmusic, it seems dsound is still better suited for smaller apps that have dynamic audio needs like fractal music or playing custom audio formats. a niche, and not game oriented, but it really dont matter eaither since you can always access previous versions of dx. quite handy for those ppl who dont always go to the greatest and dont keep up on all the new tech, like me, heh.
ok correct, my tutorial is for 3d sound, however you can still use the same basic idea to do stereo sound.

instead of creating a 3d audio path, create a stero audiopath instead with a stero buffer.
then alter the parameters of the stero buffer to get the sound to pan.
use IDirectSoundBuffer8::SetPan()

when creating the audiopath use
DMUS_APTH_DYNAMIC_STEREO insteade of DMUS_APATH_DYNAMIC_3D
then to get the buffer from the audiopath use
IID_IDirectSoundBuffer8 to get an IDirectSoundBuffer8, which you can then call SetPan() on.

use my tute as a guide and make the above changes and I *think* it should work ok (I haven''t actually tried it myself but I reckon it should work)

good luck
Toby


Gobsmacked - by Toby Murray
I have to use soundbuffers for this?
I cant just do this directly through DirectMusic?

I really dont get the relation between segments and soundbuffers, if someone could explain that would be great

ByteMe95::~ByteMe95()
My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
ok it goes something like this (from my understanding anyway)

you have a segment which is your sound you want to play..
you can call playsegment on the performance interface to play the segment (which is what I''m assuming you''re doing now (right?))

each segment is played through what is called an audiopath (this is all in the tute btw). to change the way the sound is played (panning, frequency etc. ) you need to make changes to the audiopath through which it is played.

to do this, you have to create an audiopath for every one of your segments.
from the audiopath you can extract different objects. One of these is a sound buffer. You can extract the sound buffer and make changes to that (panning, frequency etc.) this will affect the audiopath.
You can then play the sound through the audiopath (which you have altered) and the sound itself will be played with the altered settings (pannning etc.)

how you do this is in the tutorial so I won''t go into all the detail here.
look at what i posted above and look at the tutorial.


Gobsmacked - by Toby Murray

This topic is closed to new replies.

Advertisement