Using Emphasize Audio Channels boosts other SFX channels

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

Using Emphasize Audio Channels boosts other SFX channels

#1 Post by SinSisters »

I have several audio channels set up with sfx as the mixer, wanting to set the "sound" channel to 1.0, "ambiance" to 0.1, etc. etc. The first line in the start script is:

Code: Select all

$ renpy.music.set_volume(1.0,0,"sound")
$ renpy.music.set_volume(1.0,0,"music")
$ renpy.music.set_volume(1.0,1,"music1")
$ renpy.music.set_volume(0.1,0,"ambiance")
$ renpy.music.set_volume(0.05,0,"channel1")
$ renpy.music.set_volume(0.2,0,"channel2")
And my audio emphasize looks like:

Code: Select all

default preferences.emphasize_audio = True
define config.emphasize_audio_channels = ["sound"]
define config.emphasize_audio_volume = 0.5
Unfortunately, as soon as any sound channel is played, the other sfx channels get boosted and stay boosted unless I lower the volume again.

Code: Select all

play ambiance ocean
"This works fine."
play sound knock
"I have lost all use of my eardrums."
$ renpy.music.set_volume(0.1,0,"ambiance")
"Ah, that's better."
I tested this on a fresh game with just the ambiance channel & the emphasize audio code (the emphasize_audio_volume doesn't seem to affect this) and the same problem occurs. How can I get the other SFX to stop getting boosted?

User avatar
m_from_space
Miko-Class Veteran
Posts: 974
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Using Emphasize Audio Channels boosts other SFX channels

#2 Post by m_from_space »

I never used this feature, but the documentation states:

- Emphasizing audio refers to a list of channels - so I guess it's not about the mixer
- When one of those listed channels is played, all other non-listed channels are reduced to config.emphasize_audio_volume (in your case 0.5)
- When none of the listed channels is played (right after they finish playing I assume), all other channels will have their volume set to 1.0

So if your channel is 0.2 at the beginning and not part of this list, then it will get raised to 0.5 and then to 1.0, not lowered.

Do you really have so many audio files playing a the same time that this feature is useful in your case? Just wondering. And if you have a situation in your game, where other channels need to get reduced for a period of time, you could also write your own function for it.

User avatar
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

Re: Using Emphasize Audio Channels boosts other SFX channels

#3 Post by SinSisters »

Oh, perfect, thank you. That makes a lot more sense. I generally have music + ambiance and then a sound effect, and I like this feature because the sound effect becomes easy to hear without having to blast it out loudly over the music. It'd be nice if the emphasize function returned the volumes to their previous state, but I guess there's no get_volume equivalent. Should be pretty easy to write a function for it now that I understand the problem :)

EDIT:

Since I only need to reduce the music volume, I ended up just changing the audio.py from:

Code: Select all

        if vol is not None:
            for c in all_channels:
                if c in emphasize_channels:
                    continue
                c.set_secondary_volume(vol, renpy.config.emphasize_audio_time)
to

Code: Select all

        if vol is not None:
            for c in all_channels:
                if c.mixer == "music":
                    c.set_secondary_volume(vol, renpy.config.emphasize_audio_time)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]