Home » Community » Forums » » 3D Sound with DirectX Audio
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 3D Sound with DirectX Audio
Post Reply 
Thank you so much! My DirectAudio init/shutdown is now working flawlessly.

Your article used a load from file method to get the sound data. But I need to get the data from a stream, since I have a file containing more than one sound/texture/mesh.

Could you point me out to more information about loading a sound file from a stream using DirectAudio8, and especially about what that "IStream" object mentioned in the SDK, is?

Thank you!

EDIT - And I just remembered : the titile reads :
"3D Sound with DirectX Audio
by by Toby Murray"



ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more

[edited by - ToohrVyk on February 14, 2003 12:43:02 PM]

 User Rating: 1976   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

"Each 3D sound has its own listener, as the listener is associated with the 3D Audiopath."

This is not correct, or rather, its misleading. The IDirectSound3DListener8 is an interface of the primary buffer. There is ever only one primary buffer per direct music application. You can retrieve the listener interface from any audiopath by specifying DMUS_PATH_PRIMARY_BUFFER in the dwStage param but they ultimately returns the same listener.


- Hun Yen Kwoon


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I most say that this tutorial is an example haw a tutorial shod be. Nice work

From a Swedish student


 User Rating: 1015    Report this Post to a Moderator | Link

Hi.

I have a explosion sound comming out of explosion. In case I have only one explosion, I can use your code. But if there are several explosions at once, each on its position, how to use it?
I dont want to load each explosion.wav from file over and over again.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

ibolcina:
I didn't wrote this article or the sample code, but i reckon i could offer some help here.

Change the code to load ur explosion.wav as a DMusic segment. So u have only 1 DM segment with the explosion.wav data. Next, download this segment to different DM 3D audiopaths as required. If u have 8 bombs exploding, then u would wan 8 different 3D audiopaths controlling the explosion sound at different 3D positions. But u only ever load explosion.wav once in that single DM segment of urs, and u use that same DM segment to d/l data into the 3D audiopaths.

I did not look at the sample code of this articles, but from the question u r asking, i believe the abstraction of the DirectMusic interfaces isn't done properly in the code.

- Hun Yen Kwoon

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I have done as you suggested. I even "cloned" loaded segments and played them in separate audio paths. Everything works until sound listener changes position. Then sounds become somehow strange and unnatural. What am I doing wrong?
And, does anybody knows any good sound library, something like:

sound.load("a.wav","b.wav");

sound.play("a.wav",position,listener_position,listener_orientation)

sound.play
("b.wav",position,listener_position,listener_orientation)

sound.play("c.wav",position,listener_position,listener_orientation)

sound.end();

This is basically all I need from library, I dont want to handle all this audio stuff.



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I'm having some issues with your class or code, it may be my error, though it worked fine before I put in the new code, so I thought I might see if people here coud identify the error.
I copied the relevant code directly from the tutorial program and into the relative areas. I know get these errors:

syntax error : missing ';' before identifier 'Audio'
'CDXAudio' : missing storage-class or type specifiers
unexpected end of file found

all the errors would point me to this line:

CDXAudio Audio;

anyone know why?

 User Rating: 1015    Report this Post to a Moderator | Link

Hi all,
thanks for the comments on the article.
I haven't looked at this stuff for a long time, that article was written around the beginning of April last year (I was farily shocked to see it as a featured article 10 months after I submitted it to gamedev.net - haven't visited this site for a few months now ).
Anyway my big thanks to flipstar for correcting me. The DirectMusic Interface abstraction could/should have been done better, and that part of the article is misleading. (Mainly becuase I didn't understand the stuff fully when I wrote the article ...) The method suggested is probably the way to go. Those example classes are very basic, and are fairly dodgy in terms of performance - they were just there to give an idea of how I used this stuff in a small game.

As far as anonymous goes, look for a missing semicolon at the end of the CDXAudio class. (thats just a guess, post more code if still problems).

Thanks all,
Toby


Gobsmacked - by Toby Murray

 User Rating: 1010   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by ibolcina
I have done as you suggested. I even "cloned" loaded segments and played them in separate audio paths.


No, u dun need to cloned it. Just download from the one segment u have!

quote:
Everything works until sound listener changes position. Then sounds become somehow strange and unnatural. What am I doing wrong?


Can't really imagine the strangeness here... Is it muffled? Soft? If that is so, it may be due to the attenuation settings. 3D positional sound have a falloff range which needs to be set. Your setting may some how be attenuating the sound sources too rapidly.

If the strangeness refers to errors in 3D perception of the sound, say it was from left but becomes right... Then many things can cause this. U will need to look at the abstraction of the interfaces of the classes provided by tobymurray. Make absolutely sure that u create unique 3D audiopath8 for EACH 3D sound source. You cannot shared 3D audiopath between sound sources that varies in terms of 3D position. Do also check how the relation between the listener and 3D sound source are set. It may be head-relative which is only good for bee-buzzing around ur listener...

This article is a good starter for ppl trying to get a leg and arm into DirectAudio, but i would recommend more in-depth consultation with the DirectX docs and the DirectAudio newsgroup at MSDN online.

- Hun Yen Kwoon

[edited by - flipstar on February 27, 2003 2:19:56 PM]

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Each sound has it's own Listener??? I don't think so...

It seems to me that directly manipulating the sound buffers is the best approach for 3D sound management.. not DMusic facilities. I like DMusic for the easy sound loader, but thats about it... PResently I have my own method for manually readinf the soudn data (using the 'ol mmio functions), which does not seem elegant..

Any comments?

I really like this tutorial, but found a few critical problems with it... What If I wanted 2 sounds; if you think I will be manipulating 2 separate listeners, that would be incorrect, as someone posted in the earlier thread...


 User Rating: 1059   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

The linker says it can't find a reference to GUID_NULL. I'm not using VC++ but Dev-C++, so this could be the problem. How can I declare the GUID_NULL, or which library should I link?

Tnx!

 User Rating: 1015    Report this Post to a Moderator | Link

The tutorial is well done....good job.

I had a question regarding management of audiopaths and sounds. As it stands, I've implemented my own sound class which has a vector of segments (one for each sound used in the game) and a vector of 3d audiopaths (one for each sound as well). However, I realized, having one audiopath per sound may not be enough, espcially if you want one sound played in two different locations. What's the best approach to managing resources in order to make it that every sound I want to play at a time is in the correct place?

One idea I have is potentially just creating a new audiopath everytime a new sound wants to play. However, I would need to store or potentially clean these audiopaths up.

Thank you for any help you can offer.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

If anyone is interested in knowing why the example provided here:
http://www.gamedev.net/reference/articles/article1881.asp
refuses to play any sound file after you load it, play it, and restart your program, it's because you need to create separate objects for 3d and regular sound. The following objects need to be created separately:
A non 3d pSegment, pPerformance, and pLoader.
Don't forget to create separate Play and Stop wrapper functions for each segment or else you'll be pulling hair wondering why it won't work (at least I was).

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: