openAl sound
Re: openAl sound
Hey it's me again. Now we want to make sounds from other cars(non players one) in our game. I am thinking to load each car with acceleration breaking and collision source sound like the one I made for players car and change and for each car volume based on distance from player car like the further the car the lesser the sound. Is it a good way or there is better way to do this?
- Deckhead
- Site Admin
- Posts: 128
- Joined: Fri Feb 21, 2020 5:44 am
- Location: Sydney, Australia
- Contact:
Re: openAl sound
It's fine for simple things, like a 2D game. You can basically say something like:Mckl wrote: ↑Tue Apr 07, 2020 4:47 am Hey it's me again. Now we want to make sounds from other cars(non players one) in our game. I am thinking to load each car with acceleration breaking and collision source sound like the one I made for players car and change and for each car volume based on distance from player car like the further the car the lesser the sound. Is it a good way or there is better way to do this?
- After 200 units, you can't hear a car. So this is how far away a car fades into silence. In this case, "units" could be pixels.
- Calculate a distance vector between the player pos and the car you're playing a sound for.
- Lerp the volume of the car based on how far away it is
- Every frame, update the gain of the source based on your above lerping, so you'll need to calculate it every frame
Developer of The Last Boundary and webmaster of IndieGameDev.net
Re: openAl sound
I think what if we put source into class definition of the vehicle So each vehicle has it's source, make 3 buffers for acceleration breaking and collisions. Then in sound system go through list of vehicles and check if it's breaking accelerating and colliding it's position and velocity. and update each source accordingly.
Re: openAl sound
And by the way what is AL_PITCH is?
- Deckhead
- Site Admin
- Posts: 128
- Joined: Fri Feb 21, 2020 5:44 am
- Location: Sydney, Australia
- Contact:
Re: openAl sound
Changes the pitch of the original sound. Helpful for car engines, as you sort of rev the engine, you can modify the pitch to simulate faster revs.
Developer of The Last Boundary and webmaster of IndieGameDev.net
Re: openAl sound
So what do you think is it good way of doing that to make 3d sound? Or is the way to make 3d sound for bunch of cars just using one source?
- Deckhead
- Site Admin
- Posts: 128
- Joined: Fri Feb 21, 2020 5:44 am
- Location: Sydney, Australia
- Contact:
Re: openAl sound
Well, for 3D sound, you can look into the positioning parts for the source. So each car is it's own source, and the source is positioned at different places.
That's really the best way to handle it. I will eventually write the next article to cover positioning.
That's really the best way to handle it. I will eventually write the next article to cover positioning.
Developer of The Last Boundary and webmaster of IndieGameDev.net
- Deckhead
- Site Admin
- Posts: 128
- Joined: Fri Feb 21, 2020 5:44 am
- Location: Sydney, Australia
- Contact:
Re: openAl sound
Next article is here https://indiegamedev.net/2020/04/12/the ... ng-sounds/
Developer of The Last Boundary and webmaster of IndieGameDev.net
Re: openAl sound
I know I am a little bit ahead on your articles. I am wondering what I should look for when I am making audio sources move?
- Deckhead
- Site Admin
- Posts: 128
- Joined: Fri Feb 21, 2020 5:44 am
- Location: Sydney, Australia
- Contact:
Re: openAl sound
There's a velocity vector for sources just like the position vector. If you set the position and velocity every frame to match the objects position and velocity, it will give you good results.
Developer of The Last Boundary and webmaster of IndieGameDev.net