Solved Song Volume fades out by distance

Question that is answered or resolved.

PS_VITA

Active member
Hey guys,

How can I come up with a script that would make the volume of a song fade out by increments as the player gets further away from a certain location.

what resources are available to me?
I'm also hoping that this is just for the song in a particular stage and not actually mess with the global audio.

Any hints would be greatly appreciated.
 
Last edited:
Solution
Hey guys,

How can I come up with a script that would make the volume of a song fade out by increments as the player gets further away from a certain location.

what resources are available to me?
I'm also hoping that this is just for the song in a particular stage and not actually mess with the global audio.

Any hints would be greatly appreciated.
@PS_VITA

I didn't use it before but there's a script function that does it.

1679007848553.png

Edit: Did some tests and this function does not changes the volume permanently, you will need to repeat the code all the time to maintain the desired volume. I suggest using the updated.c because other events can fail sometimes causing some sound pop-ups. And even in the updated.c you...
Hey guys,

How can I come up with a script that would make the volume of a song fade out by increments as the player gets further away from a certain location.

what resources are available to me?
I'm also hoping that this is just for the song in a particular stage and not actually mess with the global audio.

Any hints would be greatly appreciated.
@PS_VITA

I didn't use it before but there's a script function that does it.

1679007848553.png

Edit: Did some tests and this function does not changes the volume permanently, you will need to repeat the code all the time to maintain the desired volume. I suggest using the updated.c because other events can fail sometimes causing some sound pop-ups. And even in the updated.c you will need to repeat the function a few times to reduce the pop-ups.

C:
if(openborvariant("in_level")){
    float xPos = openborvariant("xpos");

    setmusicvolume(xPos, xPos);
    setmusicvolume(xPos, xPos);
    setmusicvolume(xPos, xPos);
    setmusicvolume(xPos, xPos);
}

 
Last edited:
Solution
I already have a library code that fades left and right for stereo. It isn't hard at all to do. You just need to be specific about the effect you want.

One warning, if you do any kind of volume control, you'll want to use 16-bit depth for the sound files. If you don't, trying to play with dynamic volume changes can introduce an annoying pop to the sound.

DC
 
@PS_VITA

I didn't use it before but there's a script function that does it.

View attachment 3421

Edit: Did some tests and this function does not changes the volume permanently, you will need to repeat the code all the time to maintain the desired volume. I suggest using the updated.c because other events can fail sometimes causing some sound pop-ups. And even in the updated.c you will need to repeat the function a few times to reduce the pop-ups.

C:
if(openborvariant("in_level")){
    float xPos = openborvariant("xpos");

    setmusicvolume(xPos, xPos);
    setmusicvolume(xPos, xPos);
    setmusicvolume(xPos, xPos);
    setmusicvolume(xPos, xPos);
}

This is so awesome guys, it's pretty much what I believe I need. The idea isn't as intricate as what I watched in the video but it's definitely better than what I had imagined.
Thank you.
 
Back
Top Bottom