I forget the exact formula I used, but I did something like:
volume = -(distance(object.x,object.y,player.x,player.y) * somefactor)
If somefactor is higher, the sound will fade out 'faster'.
This is the exact formula I use as well. However note that the distance is in pixels so if somefactor == 1 then the sound will fade out very quickly. A good value of somefactor is 0.01
For readability I write it as a divide...
volume = -(distance(object.x,object.y,player.x,player.y) / somefactor)
With somefactor = 100