openAl sound

There's only need for one forum for now. Discuss development. No advertising or thinly veiled attempts at advertising. Create a single thread for your project and be prepared to show and tell.
Mckl
Posts: 20
Joined: Wed Mar 04, 2020 12:09 am

Re: openAl sound

Post by Mckl »

It turns out that vehicle list on moment of initialization of sound system is empty. Vehicles generated after Sound system is initialized. So I ve made it to wait for few seconds. Now it seems it's all there. Thank you could not have figured with out your help. Now I just need to do attunement. As I understand from your article #3 on openAl it should be done automatically. Or should I do something to adjust it?
User avatar
Deckhead
Site Admin
Posts: 128
Joined: Fri Feb 21, 2020 5:44 am
Location: Sydney, Australia
Contact:

Re: openAl sound

Post by Deckhead »

Attenuation happens automatically so long as you set the position and velocity as you're doing now.

In regards to waiting a few seconds... Are you multithreading your engine? It's not a good idea to wait a few seconds, what you should do is have some sort of flag or signal notify a system that it can start initialising whenever it's ready. On your computer "a few seconds" might work, but on my computer it might need to be "over 20 seconds" etc (different processor speeds, different background tasks).

Even better would be general sound system initialisation that happens once when the program starts. Then just have the sound system contain a method to initialise vehicle sources and pass in a list of vehicles. That way whatever inits vehicles can just call something like SoundSystem::InitVehicles(vehicle List).
Developer of The Last Boundary and webmaster of IndieGameDev.net
User avatar
Deckhead
Site Admin
Posts: 128
Joined: Fri Feb 21, 2020 5:44 am
Location: Sydney, Australia
Contact:

Re: openAl sound

Post by Deckhead »

BTW I'd love to see your game.
Developer of The Last Boundary and webmaster of IndieGameDev.net
Mckl
Posts: 20
Joined: Wed Mar 04, 2020 12:09 am

Re: openAl sound

Post by Mckl »

There is no multithreading. I just made frame counter and put it into update function so after around 100 frames when all vehicles are there counter stops and then all sources are generated exactly once using some bool variable. and then Update function starts working normally. like I have now all information vehicle positions and velocities. And I guess after we submit this project I can share GitHub link with you.
Mckl
Posts: 20
Joined: Wed Mar 04, 2020 12:09 am

Re: openAl sound

Post by Mckl »

I am wondering is there a way manually attune the distance model. When bot car in close vicinity accelerate it seems too silent or weak.
User avatar
Deckhead
Site Admin
Posts: 128
Joined: Fri Feb 21, 2020 5:44 am
Location: Sydney, Australia
Contact:

Re: openAl sound

Post by Deckhead »

Yes. You adjust the AL_MAX_DISTANCE and AL_REFERENCE_DISTANCE. The latest article here should help you https://indiegamedev.net/2020/04/12/the ... ng-sounds/
Developer of The Last Boundary and webmaster of IndieGameDev.net
Mckl
Posts: 20
Joined: Wed Mar 04, 2020 12:09 am

Re: openAl sound

Post by Mckl »

Oh so I can just during initialization or in update just put something like:
AL_MAX_Distance = 20;
AL_Reference_DIStance = 5 and this would adjust sound for me.
And what about ROLLOFF Factor?
User avatar
Deckhead
Site Admin
Posts: 128
Joined: Fri Feb 21, 2020 5:44 am
Location: Sydney, Australia
Contact:

Re: openAl sound

Post by Deckhead »

Don't worry about AL_ROLLOFF_FACTOR for now, that controls the rate of attenuation. The article shows you how the rolloff affects the curve.
Developer of The Last Boundary and webmaster of IndieGameDev.net
Post Reply