Archived

This topic is now archived and is closed to further replies.

enygmyx

question regarding OpenAL

Recommended Posts

hi all, First of all i really think that there should be a seperate forum for asking sound realted questions ..... but anyways .....i have a question regarding OpenAL that i would like to ask you. all of the entities in my game engine have some sounds associated with them. these sounds are identified by the source ID that OpenAL returns when it loads a sound. now in many cases it might be that two or more entities request OpenAL to load the same sound file. currently my sound manager(based on OpenAL) will load the same file twice and return seperate source ID''s to the entities. now what i want to do is that the sound manager should load the sound only once and return the same source ID to all the entities requesting for the same sound file (no big deal). but the problem with this is that when an entity requests the sound manager(OpenAL) to play a sound that was already being played by another entity, the sound already being played starts playing from the start. i wanted to know if we could configure OpenAL to solve this. meaning that if there is a request to play a sound that was already being played OpenAL would play the the same sound in a seperate thread or something. saving us from loading the same sound multiple times. hope that i have stated my problem clearly, thanks in advance, enygmyx.

Share this post


Link to post
Share on other sites
Firstly, the Sound is stored in buffers. You should be returning buffer ID''s instead of Source IDs. Sources define the position/velocity/etc.. of the sound which is stored in a buffer.

I have used OpenAL only for playing back sounds and never went to the extent of managing sounds or finding out how to play them from a particular timeframe. Im sure it can be done, perhaps someone else might be able to help.

Share this post


Link to post
Share on other sites
quote:
Original post by enygmyx
hi all,
First of all i really think that there should be a seperate forum for asking sound realted questions


Such as the Music and Sound forum, perchance?



[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
You should be able to make two or more sources to share the same buffer. You''ll still need multiple sources but you''ll only need to load the sound to one buffer.

Untested code:

alSourcei(source1, AL_BUFFER, myBuffer);
alSourcei(source2, AL_BUFFER, myBuffer);
// give the sources some different attributes
alSourcef(source1, AL_PITCH, 1.0);
alSourcef(source2, AL_PITCH, 0.2);

Share this post


Link to post
Share on other sites
hi ppl,
sorry for the late reply but i was caught up in work.....
thanks GamerSg and drunk for the tips .... your tips were very helpful in solving my problem ...
anyways i still wonder if there is some through which openal would do this management on its end (hehe .... being a little lazy and greedy .... )
thanks for the help folks,
enygmyx.
P.S. Kylotan, i would have posted my question in the sound and music forum but it is categorized in "The Creative Side" and the description says "The artistic side of creating game music and sound effects." which gives a feel that the forum is not really meant for programming related questions.

Share this post


Link to post
Share on other sites
I see your point, but there aren''t enough sound-specific problems to warrant a separate sound programming forum. 90% of the questions are people having trouble installing or using OpenAL anyway. Either this forum or the sound one will do.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites