🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

OpenAL play sound

Started by
8 comments, last by FGFS 8 years, 12 months ago

Hi

any ideas for a simple solution to play a second sound 5 seconds after the first?

first sound play only once

second sound start looping after 5 seconds

Many thanks

Advertisement

What have you tried? http://mattgemmell.com/what-have-you-tried/

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

What have you tried? http://mattgemmell.com/what-have-you-tried/

This.

What have you tried?

I normally wouldn't add an extra reply simply to reiterate an earlier post, but given you (FGFS) saw fit to report the above post as spam rather than responding to it I'm taking a different course of action.

Did you actually read the link? It explains why you should expect to be able to answer the question "what have you tried" and why it is (usually) bad to simply ask for a solution rather than asking for help with the problem.

This is a discussion forum, intended to provide you with help and advice, not just a place to be handed solutions. Asking what you have tried can be an important first step in making sure any advice we offer is actually relevant - for all we know we might otherwise offer a solution that is incompatible with your existing project for some reason. Trying for yourself is also a great learning opportunity, and we generally aim to help people to learn for themselves.


...so ...what have you tried?

(Also, you didn't tell us your target operating systems, which may be relevant for this question.)

- Jason Astle-Adams

Giving such links is nothing but a waste of time, sorry. Is he trying to sell me stuff? I didn't even bother to read that spam.

I still have no idea on how to play a sound only once.

and I ran into another problem on how to set source direction:

alSourcef (Sources[1], AL_DIRECTION, 0, 1, 0.0 );

I get "too many arguments but I cannot find any doc about that.

Any examples I've found are too simple to not use any of the above.

Is he trying to sell me stuff? I didn't even bother to read that spam.

No, it's not trying to sell you anything, and you're wasting our time by expecting us to provide you with an answer without putting in any effort -- if you bother to read it you'll find some really good advice that it seems like you really need.

...and if you tell us what you've already tried, we'll see if we can help you out.

You have already tried to solve your problem haven't you? You're not just hoping for us to solve your problem for you without any effort are you?

Did you try searching for resources? I just typed "openal play sound" into Google and the first page is filled with promising look links [1, 2, 3, etc.] -- have you tried any of those and are having problems we can help with?

- Jason Astle-Adams

I've tried something alike but I gave up and look for source direction like I've said before:

if (hdgL[0] >=0.0){
alListenerfv(AL_ORIENTATION, ListenerOriVorne);
}else{
alListenerfv(AL_ORIENTATION, ListenerOri);
}


Any examples I've found are too simple to not use any of the above.

and I ran into another problem on how to set source direction:
alSourcef (Sources[1], AL_DIRECTION, 0, 1, 0.0 );

I get "too many arguments but I cannot find any doc about that.

I searched for "openal documentation". The first link was to the OpenAL Specification, which although very detailed may not be all that approachable, so I moved on.

The second result was to the Creative OpenAL Programmer's Reference, which explains the function in question on page 16. Just as your error message says, you appear to have too many arguments; the function only expects three arguments and your code snippet has five. Are you perhaps wanting to use the alSource3f function (found on page 17) instead, which does take five arguments?

If you're looking for additional documentation, the third result of my research was the OpenAL Programmers Guide, which also appears to be quite detailed.


I still have no idea on how to play a sound only once.

What have you tried?

You also still haven't told us what your target operating system(s) are...

//EDIT:

This was edited in to your post after I posted this reply, so going back to retroactively respond to it...


I've tried something alike but I gave up and look for source direction like I've said before:

...that's just the thing -- you didn't say that before, and it's important information for us to try to help you.

- Jason Astle-Adams

Thanks. I was looking for the openal programmers guide. Lost that some years ago. Still haven't found out how to play a sound only once. alSourcei (Sources[5], AL_LOOPING, AL_FALSE ); has no effect.

Also I don't understand direction vector:

ALfloat SourcesDir[NUM_SOURCES] = { 0.0, 0.0, 1.0 };

also has no effect. From behind sounds are ok, but from the front left/right need to be swapped. I gave up on listener hence I try such with sources.

Thanks

PS: I target desktops (linux/osx/win)

Are you checking for errors with alGetError?

If you're working based on any examples it's quite likely that they probably omit error checking so that it doesn't clutter up the example and confuse you further, but you should be checking for errors after any call that can potentially fail. You'll find some documentation for this on page 14 of the OpenAL Programmer's Guide (linked above).

Have you used vectors in graphics, or covered them in maths at school? Do you not understand the concept of using a vector for direction, or just the specifics of how it's applied to openal?


PS: I target desktops (linux/osx/win)

Are you using any other libraries for windowing, input, etc.? This is important for properly answering your question about playing a second sound after a delay, as you will either need to use a timing function provided by another library or by the underlying operating systems.


I was looking for the openal programmers guide.

Looking where and how? Even understanding that Google gives personalised results and you might be seeing different results than I am, when I search for "openal programmers guide" five of the results on the first page are it. When I instead search for "openal documentation" it appears twice in the results as the second and sixth result. If I instead search for "openal tutorial" it only appears once on the first page of results, but it's still there. Results with Bing and DuckDuckGo are very similar, as I would assume those from any competent search engine to be.

I find it hard to believe that you wouldn't have found it very quickly if you were actually looking for it. It doesn't help anyone to pretend you had previously been trying if you weren't actually putting in the effort, but now that you've actually started answering our questions rather than just complaining about the "what have you tried" link we can start to work through your problem. :)

- Jason Astle-Adams

Never mind, I've stumbled across:

http://www.opentk.com/node/211

and got it all fine now with that listener formula. Exactly what I needed. wub.png

This topic is closed to new replies.

Advertisement