Sign in to follow this  
Sharshour

Renamed: 3D Sound Programming

Recommended Posts

Hallow every body.... I want to ask about the 3Dsound programing in the game ... can i use just one sound and play it every time with new direction and position..?! in my engine i load the all sounds for every entities the game but there are alot of them are loaded much more... thanks... [Edit: Give your threads a name. It helps people decide if they can or should bother helping you. - Oluseyi] [Edited by - Oluseyi on December 4, 2004 11:51:56 AM]

Share this post


Link to post
Share on other sites
I guess that he's asking if he can share the same sound buffer with some entities.

@OP
You can, you do something like:

class Entity
{
public:
void SetSound( CSound *pSound ) { m_pSound = pSound; }
... // Your other mothods
private:
CSound* m_pSound;
};

class CSound
{
public:
LoadSound( char* pszFileName );
PlayAtPos( float x, float y, float z );
... // Other methods
};

BTW, I think you are coding in c++, are you?...

Share this post


Link to post
Share on other sites
of course I am a C++ programmer,
I am very sory because of my bad english lang but i wish I can express
my problem.
The game that I reffer to is the FPS(First Person Shooter) game.
The problem is that i load separate sounds for every entity so i load much more (somewhat) on the memory.

Share this post


Link to post
Share on other sites
Thank you Mr.Kamikaze15 but... I think there are some problems....!
before, I though about this method but when two entity play the same sound (which is load for more than entity)at the same time then i must change the position of the m_pSound which is a pointer and so the changes will applied to the pSound, and so the two sound will not play at thier position in good way.Is it true......?!

Share this post


Link to post
Share on other sites
The best way todo it imo is to have sounds buffers and sound sources (like OpenAL does).
You load all your sounds into buffers on start up (important, only ONE copy of the sound is loaded into each buffer), then when an entity needs to play a sound it requests a source from whatever sound system you are using, the buffer is attached to that source and the buffer is played via that source.

You can have more than one source playing the same buffer as each one will hold its own data as to where its gotten to in the replay of the buffer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this