Is there a way to make sound fade in/out when closer to the source of it or further

Is there a way to make sound fade in/out when closer to the source of it or further