ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm still a newb when it comes to OpenAL, but here are a couple of things I noticed off the top of my head:
I don't see a call to alutInit anywhere. Maybe that is in another portion of code you didn't include, though.
I don't think you need to put the alSourcePlay into an infinite loop like that. You are just going to start playing it again and again and again...
Other than that, it looks pretty similar to some of the test code I did when first trying to get OpenAL to play, though it's arranged a bit differently.
I don't remember to be honest. I wrote my OpenAL code to play wav files awhile ago and haven't had to do much with it since. I think I just used the OpenAL docs, though.
can anyone post some openAL code that would allow me to just play a sound. I couldn't even edit out the little switch in the tutorial that I found online. This is quite confusing. . .
Here's some sample code I threw together as an example. I'm not at home right now so I can't test to make sure it actually works, but it compiles with:
Interesting. I wonder if you have a different version of OpenAL than I do with the parameter of the fv version of functions not delcared const... You can try a few things.
1. Do a const_cast to get rid of the "constness" of the vector. Not usually the best thing to do, but in this case those functions SHOULDN'T be modifying the contents.
e.g.
alListenerfv(AL_POSITION, &vecListenerPosition[0]);
becomes:
alListenerfv(AL_POSITION, const_cast<ALfloat*>(&vecListenerPosition[0]));
2. Just do a C-style cast to ALfloat*
e.g.
alListenerfv(AL_POSITION, &vecListenerPosition[0]);
becomes:
alListenerfv(AL_POSITION, (ALfloat*)&vecListenerPosition[0]);
3. Switch to the 3f version
e.g.
alListenerfv(AL_POSITION, &vecListenerPosition[0]);
becomes:
alListener3f(AL_POSITION, vecListenerPosition[0], vecListenerPosition[1], vecListenerPosition[2]);
4. Just change my functions to take in ALfloat pointers and pass them directly to the function.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.