Ren'Py Separating Video Audio from Music Volume

ChaoticNeutral

Newbie
Game Developer
Aug 2, 2018
36
85
I've been trying to make audio from a video file independent of the game background music.
If I lower the music in preferences both are lowered. I want to be able to lower each of them individually.


In this original one the video and audio work fine, however I cannot lower the volume of the background music without lowering the volume of the video audio
image ls1 = Movie(size = (1280,720), play="video/LaylaScene2/ls1.webm")

I tried changing the channel like this
image layla v1 = Movie(size = (1280,720),channel='sound', play="video/LaylaScene1/layla v1.webm")

The sound's are separated however the video no longer is visible.


I want to be able to adjust the video audio independently of the music volume.


Anyone have any idea how to fix this?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,569
2,196
The way RenPy works is that it registers a series of by default using .

The default channels are:
  • music
  • sound
  • voice
  • movie
There is also another channel called audio that does extra stuff that most people don't worry about.

Each channel has it's own options, like whether it supports looping or whether it supports buffering, etc. The defaults for each are different - for example music loops by default, but sound doesn't.

The isn't mentioned explicitly by the sound documentation, but if you go searching in the RenPy code... you can find this...

Python:
        if not renpy.music.channel_defined("movie"):
            renpy.music.register_channel("movie", "music", False, stop_on_mute=False, movie=True)

The default sound channel option for movies is ,movie=False - which is why movies don't work with the other sound channels.

Each sound channel is linked to a mixer. Each mixer had a volume slider on the preferences/options game screen.
The mixers are sfx, music and voice.

You could try registering another channel like "movie2" with the "voice" or "sfx" mixers instead of "music".
Alternatively, you could can probably just register the "movie" channel yourself using different options (since the internal code checks to see if one already exists).

I'm pretty sure you could also register/create a separate mixer with its own volume controls and link that to your movie channel too. But I haven't seen a clear example of how that's done.

Edit:
As far as I can tell, mixer names are just aliases for sound channels 0 thru 7... where 0=sfx, 2=voice, 7=music.
I've seen init: code that includes:
renpy.music.alias_channel(1, "ambient")

Combined with an extra line in the options screen for:
bar value MixerValue('ambient')

Your guess is as good as mine as to whether this works as easily as it seems to.

Also... if I'm reading the code right, channels 3 thru 7 loop by default. Wow, I'm so far out on a limb here.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,290
15,146
I'm pretty sure you could also register/create a separate mixer with its own volume controls and link that to your movie channel too. But I haven't seen a clear example of how that's done.
You don't need to go this far, is the answer here.

To have the sound of his video playing on the channel named "sound" in the preference screen, but "sfx" internally, he just need this :
Code:
init python:
    config.movie_mixer = "sfx"

image ls1 =  Movie(size = (1280,720), play="video/LaylaScene2/ls1.webm")
And replacing "sfx" by "voice" will make it play on the "voice" channel.