Audio Volume Change On Screens

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
User avatar
TheSweetestNightmare
Regular
Posts: 43
Joined: Sat May 04, 2013 6:34 pm
Completed: None
Projects: The Catalyst(Failed Attempt), Heart of the Ocean
Location: U.S.A.
Contact:

Audio Volume Change On Screens

#1 Post by TheSweetestNightmare »

I've gotten myself into a conundrum. My game consists of multiple point-and-click screens that display the town in which the characters live. Some of the screens display an outdoor background but some display an indoor background. I finally got around to editing a rain sound effect to play on the days when it's raining, but the sound effect is still playing just as loud when the player goes to an "indoors" screen. For example, the rain ambiance track plays at a certain volume during a scene and continues playing on a point-and-click screen of a beach, but then continues to play at the same loud volume when the player clicks to go inside the lighthouse. I would like to add some condition to the "lighthouse" screen to make the audio sound much quieter. Is this possible?

Long story short; Is there a way to add a condition to a screen that changes the volume of an audio track, or do I have to find another way around this problem?
Image
Image
-Sincerely, Faith

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Audio Volume Change On Screens

#2 Post by namastaii »

You could probably just create a true or false variable and every time you enter the lighthouse it sets it to true and before the end of the scene or whatever it sets it to false and whenever it is true then the music volume equals this etc. Though maybe someone knows a better solution. You could also just start the audio over with a new volume each time you're in a new place at the beginning. Can't you just set the volume at the beginning on the scene? With a line of code

User avatar
TheSweetestNightmare
Regular
Posts: 43
Joined: Sat May 04, 2013 6:34 pm
Completed: None
Projects: The Catalyst(Failed Attempt), Heart of the Ocean
Location: U.S.A.
Contact:

Re: Audio Volume Change On Screens

#3 Post by TheSweetestNightmare »

namastaii wrote: Fri Jul 13, 2018 6:35 am You could probably just create a true or false variable and every time you enter the lighthouse it sets it to true and before the end of the scene or whatever it sets it to false and whenever it is true then the music volume equals this etc. Though maybe someone knows a better solution. You could also just start the audio over with a new volume each time you're in a new place at the beginning. Can't you just set the volume at the beginning on the scene? With a line of code
Hmmm... You have a point. I was thinking it might be possible if changing between screens activates certain labels but I'm already using a similar trick to set the screen positions before showing them. (This way the player enters on the correct side of the screen depending on where they are coming from. I'm using viewports to try and add some immersion.) Maybe I just need to rethink these screen positioning labels and add True/False statements to them. It probably wouldn't be that difficult. Thanks for your input!!
Image
Image
-Sincerely, Faith

User avatar
TheSweetestNightmare
Regular
Posts: 43
Joined: Sat May 04, 2013 6:34 pm
Completed: None
Projects: The Catalyst(Failed Attempt), Heart of the Ocean
Location: U.S.A.
Contact:

Re: Audio Volume Change On Screens

#4 Post by TheSweetestNightmare »

I changed the labels up. It didn't take much effort at all. This is what I used to use. When a person clicks to show the next screen, it would also take them to one of these labels;
label position_left:
$ x_position = 0.0
$ y_position = 1.0
$ ui.interact()
label position_right:
$ x_position = 1.0
$ y_position = 1.0
$ ui.interact()
label position_center:
$ x_position = 0.5
$ y_position = 1.0
$ ui.interact()
Now the labels will also change the true/false statement as well;
label position_left_out:
$ x_position = 0.0
$ y_position = 1.0
$ muffle_ambience = False
$ ui.interact()
label position_right_out:
$ x_position = 1.0
$ y_position = 1.0
$ muffle_ambience = False
$ ui.interact()
label position_center_out:
$ x_position = 0.5
$ y_position = 1.0
$ muffle_ambience = False
$ ui.interact()
label position_left_in:
$ x_position = 0.0
$ y_position = 1.0
$ muffle_ambience = True
$ ui.interact()
label position_right_in:
$ x_position = 1.0
$ y_position = 1.0
$ muffle_ambience = True
$ ui.interact()
label position_center_in:
$ x_position = 0.5
$ y_position = 1.0
$ muffle_ambience = True
$ ui.interact()
Now I just need to connect these statements to some kind of condition for the "ambiance" audio track and the problem is solved. Time to do some research...
Image
Image
-Sincerely, Faith

User avatar
TheSweetestNightmare
Regular
Posts: 43
Joined: Sat May 04, 2013 6:34 pm
Completed: None
Projects: The Catalyst(Failed Attempt), Heart of the Ocean
Location: U.S.A.
Contact:

Re: Audio Volume Change On Screens

#5 Post by TheSweetestNightmare »

I did research, but still kept getting stuck. After focusing on other things and letting it ruminate in the back of my mind, I finally figured out that I didn't need a True/False statement or a numerical variable(another thing I tried). All I needed to use was:
label position_left_out:
$ x_position = 0.0
$ y_position = 1.0
$ renpy.music.set_volume(1.0, delay=0, channel='ambiance')
$ ui.interact()
label position_left_in:
$ x_position = 0.0
$ y_position = 1.0
$ renpy.music.set_volume(0.25, delay=0, channel='ambiance')
$ ui.interact()
[/c]
All that was needed was a simple line of python and it merges well with the position shift labels. I tested it out not really expecting it to work, and lo-and-behold! It did exactly what I was needing it to do! This should also work in the middle of a scene. I figured I'd post the solution here just in case anyone has the same problem.

If anyone does want to do something similar, here's an explanation. The "out" labels are for screens that take place outside and the "in" labels are for screens that take place inside while the x_position and y_position are linked to the xinitial and yinitial of every screen, like so:
viewport:
area 0,0,800,600
draggable True
child_size 2800, 800
yinitial y_position
xinitial x_position
if TIME == "Day":
add "BG_day.png"
if TIME == "Night":
add "BG_night.png"
imagebutton idle "Arrow Up Idle.png" hover "Arrow Up Hover.png" action [Hide("current_room"), Show("next_room"), ui.jumps("position_left_in")] xalign 0.11 yalign 0.75
If you link the buttons to the correct labels, the player will begin on a specific spot on the viewport depending on where they entered the "room" from. This will make traveling around point-and-click styled screens a bit more realistic- and bonus- if you define an "ambiance" audio track for nature sounds and such, it will muffle the sound effects when the player clicks to go indoors.

...And just like that, the point-and-click aspect of my game is so much more immersive! :D
Image
Image
-Sincerely, Faith

Post Reply

Who is online

Users browsing this forum: No registered users