Anybody have any tips on how to go about making sound fx fade as the object generating them move off screen?
I'm creating a platformer with various moving objects that I want to clang bang and woosh but how to make the sound fade as they get further away from the player? Currently it would just be a cacophony of noise.
My solution so far would be to make a list of those objects and there related sound effect and measure there distance from the player per frame and change the volume on each accordingly. Not a major deal but seems like a big hack.
Any hints would be a big help
Thanks
Comments
One single list will have the advantage of using only one enterframe check, but you also need to keep the list updated.
I believe it's easier to make the check inside the objects class, because they're already going to be placed and removed, and they already "know" their position.
The only side effect on this approach would be if you have too many objects together on screen: too many contemporary checks risk affecting performance, but how much is "many" all depends on your code
From my experience stick to WAV files if they need to be played instantly, and use mp3 just for a bg music that doesn't need to be in sync with the game.
This is my first solo project so not had to deal with sound before but it seems like an essential ingredient to be able to have sounds that are placed in the world (not even sure how to phrase that) rather than everything sounding as if it's right next to you.
https://github.com/zaniar/gideros_audio/blob/master/audio.lua
I don'\t know if this bit of the api had been added yet though, @hgy29 will be able to help you more with that.
The extra mixer can also control the panning control for each of the voices - so you should be able to have your object move in from one side of the screen and move off the other and the audio follow it. There would be a max of 64 object that would be able to do this on screen at any one time.
Like I said though, this might have not been added yet.
https://deluxepixel.com