Page 4 of 4
Re: openAl sound
Posted: Thu Apr 16, 2020 6:56 am
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?
Re: openAl sound
Posted: Thu Apr 16, 2020 8:19 am
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)
.
Re: openAl sound
Posted: Thu Apr 16, 2020 8:20 am
by Deckhead
BTW I'd love to see your game.
Re: openAl sound
Posted: Thu Apr 16, 2020 9:41 am
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.
Re: openAl sound
Posted: Sun Apr 19, 2020 9:57 pm
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.
Re: openAl sound
Posted: Mon Apr 20, 2020 1:20 am
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/
Re: openAl sound
Posted: Mon Apr 20, 2020 4:22 am
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?
Re: openAl sound
Posted: Mon Apr 20, 2020 10:03 am
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.