Fading in/out music channel

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
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Fading in/out music channel

#1 Post by kostek00 »

I'm wondering if there is possibility to fadein/fadeout channel itself.

What I want to achieve is that I will have 2 separate channels for music. Both channels will play song but second one will play it muted until right moment. First will play normal song, second one will play the same song but with horror like accents. For that I thought about using:

Code: Select all

$ renpy.music.register_channel(music2, mixer=None, loop=None, stop_on_mute=False, tight=False, file_prefix='', file_suffix='', buffer_queue=True, movie=False, framedrop=True)
$ renpy.music.set_volume(1.0, channel='music2')
But is there a way to make volume for this song rise slowly like with for example "play music "xxx.ogg" fadein 1.0"?

My only idea for now is to use it like that but it's a bit wonky way to achieve this:

Code: Select all

    $ renpy.music.set_volume(0.0, channel='music2')
    pause 0.1
    $ renpy.music.set_volume(0.2, channel='music2')
    pause 0.1
    $ renpy.music.set_volume(0.4, channel='music2')
    pause 0.1
    $ renpy.music.set_volume(0.6, channel='music2')
    pause 0.1
    $ renpy.music.set_volume(0.8, channel='music2')
    pause 0.1
    $ renpy.music.set_volume(1.0, channel='music2')

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Fading in/out music channel

#2 Post by Imperf3kt »

You might be able to use the 'audio' channel as it supports multiple audio files at once. Stopping the file will be troublesome though.

The documentation has no link, but this is what it says about it:

In addition to the normal channel, there is one special channel, audio. The audio channel supports playing back multiple audio files at one time, but does not support queueing sound or stopping playback.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Fading in/out music channel

#3 Post by kostek00 »

Looks almost good but not quite. I will have to have one song playing at volume 0 and I didn't saw command allowing playing song at specified volume.

Muzozavr
Regular
Posts: 40
Joined: Tue Oct 09, 2012 7:50 pm
Contact:

Re: Fading in/out music channel

#4 Post by Muzozavr »

Yes, unfortunately, the point is not just to play multiple audio files at once.

What kostek00 wants to happen (I know it because I'm in the same team and happen to be one of the composers... I actually came up with the idea) is a decently smooth crossfade between two tracks. So you have two tracks of identical length (one with horror accents) that start at the same time, end at the same time and loop at the same time. They both play at once, however, track 2 is set at zero volume, so the player doesn't hear it.

At a certain point in the script, track 1 should fade out and track 2 should fade in. This should happen at roughly the same time to create the illusion that track 1 smoothly "morphed" into its evil horror twin in track 2. The track shouldn't restart, either -- the idea is that it doesn't matter what part of the music you're hearing when "that" moment in the script happens... wherever the music is, you still get the crossfade and the emotional impact of "wait, this is wrong, this is wrong!"

This would be an extremely expressive way to do things, but, apparently, Renpy doesn't make this easy. :/

Post Reply

Who is online

Users browsing this forum: Google [Bot]