I'm having a lot of difficulty trying to set up my audio to meet my needs. I have various audio sources in my environment, a school with various rooms. Sometimes there are multiple audio sources in the same room. The game I am creating is all about representing sound visually so there is a corresponding guiTexture for each audioSource that is displayed once the player is within a specified range.
Now I know that realistically sound never just 'goes away', but I do need to artificially constrain the sound to certain locations. The problem i'm having is trying to find the right rolloff factor to balance the sounds. For example, in the bathroom there is a shower running. With a roll off factor of 0.5 the sound drops off quite quickly and when I leave the bathroom the sound is still perceptible, but quiet enough. In the lounge, at the opposite end of the corridor, I have a stereo playing. This room is a little larger and yet, with a rolloff factor of 1.0, the music is still quite audible when I reach the bathroom. I have to crank it up to a figure like 10 to make it nearly fade out, but i'm thinking this is ridiculous since it should be a number between 0 and 1? I'm assuming this is partly to do with the different volumes of the original sounds, but trying to find the right settings is getting me very confused.
These are just two of several location based sounds that I need to adjust to create the right atmosphere. Since i'm toggling the visibility of the guiTexture with a custom radius, i've experimented with setting the AudioSource volume to 0 outside this range, but it's unbelievably sudden. I couldn't find a good marriage with the rolloff factor with this approach. I'm also checking that there are no colliders between the player character and the sound source to toggle the guiTexture, for example, if the player shuts a door between them and the sound. But this doesn't work so well for audio sources since the single raycast shuts off the sound abruptly as soon as it's not in clear sight. I may remove that check anyway since I wasn't able to selectively avoid it for something like, for example, footsteps, which I want to show regardless of whether there is a wall in the way.
I can accept some overlap of sounds - to leave the shower running, for example, is quite realistic - but other sounds need to be heard distinctly, such as the music in the corridor (a hip hop beat) and the music in the lounge (a gentle piano), which are designed to create different moods.
I've set all the sounds to Force Mono (since some were Stereo to begin with), and enabled 3D sounds. I had to turn off the Doppler Effect since the piano music was distorted whenever I turned away from the sound otherwise. I don't think I need it anyway since I have no fast moving objects, assuming I understand correctly what the Doppler Effect is.
I'll be honest, I know next to nothing about audio (Sadly I gave up the guitar lessons years ago!), so if someone could shed some light on this i'd be grateful. I've done some basic trimming of audio in Audacity, but I wouldn't know where to begin with waveforms and whatnot, so if there's something I need to be doing to the sound before I bring it in, please treat me gently;-)
Thank you very much for your time.
asked Apr 07 '10 at 10:29 PM
So after much tweaking I gave up trying to get the effect I wanted. I've now turned off 3D sounds and i'm using the code I had for fading out the guiTexture with distance to alter the volume of the Audio Source. Probably not the best way to do it, but the roll off is a lot smoother than my experiments with 3D sounds, and it's directly linked to the range so I just have to change one variable to control both the sound and the guiTexture that goes with it.
answered Apr 08 '10 at 01:56 AM
It seems to me that there shouldn't be any doppler effect when your character turns.... if your AudioListener is connected to the right object. If you have it connected to the camera, move it to the character. Doppler effect shouldn't come in to effect unless things are moving pretty quickly, swinging the camera around can do that.
answered Apr 14 '10 at 10:27 AM