Page 1 of 1

audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 3:07 pm
by dvemail
I've searched old threads and read the docs, but I'm not clear about how to control the main theme. It seems to play automagically, and I want to control looping, fade-in, etc. - Where and how is that done?

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 3:20 pm
by SuperbowserX
For looping, if it is on the sound channel (if you say "play sound theme" for instance where theme is the variable name for the song), then it will not loop at all. If you play it on the music channel (with say "play music theme") then it will automatically loop.

To override these default settings, just say "play sound theme loop" or "play music theme noloop".

For fadein, do something like: "play music theme fadein 1.0 fadeout 1.0"

If you could provide a more specific example of what you are trying to do I could help you more.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 3:23 pm
by dvemail
Thanks for your reply. The theme seems to play automatically without any lines of code in the scripts telling it to play, so I don't know where to change it.
All I want to do is a 1.5 sec fade out, loop, 1.5 sec fade in

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 3:55 pm
by SuperbowserX
It plays automatically? That is strange. Can we see your script?

Anyway, if you want to do that, do this:

Code: Select all

play music theme fadein 1.5 fadeout 1.5
In this line of code, theme refers to the variable name you assigned to your theme song file. If you didn't give it a filename then you can just replace theme with "path" where path is the location of the theme song file.

Also, if you play it on the music channel, then unlike the sound channel it will loop automatically so you do not need to specify a looping instruction.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 4:43 pm
by Imperf3kt
Main menu music always plays automatically by design.

Don't use the sound channel for main menu music, use the music channel so players can sample the volume when editing it in preferences.

To fade main menu audio in, use an audio editor such as Audacity. Alternatively, you could add a button to control the music. The documentation for 'music room' should be sufficient.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 5:40 pm
by gas
You're using the config.main_menu_music (or something like) in the config.rpy, dont'cha?
It's old and limited as me on a feet.
Don't set it, and instead add the lines suggested by SuperbowserX just right after

screen main_menu():

in screens.rpy.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 7:14 pm
by dvemail
gas wrote:You're using the config.main_menu_music (or something like) in the config.rpy, dont'cha?
It's old and limited as me on a feet.
Don't set it, and instead add the lines suggested by SuperbowserX just right after

screen main_menu():

in screens.rpy.
Tried that - play doesn't seem to be valid in screens

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 7:47 pm
by Imperf3kt
Play is a function. You need to invoke it somehow, such as in a script or with a button as an action.
I don't see how it would work in a screen.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 7:56 pm
by dvemail
So if I understand you correctly, I could define a function somewhere that would be like a theme_music_on() and theme_music_off() and I could invoke them in the screens?

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 7:58 pm
by SuperbowserX
Scratch what I said earlier. This, going by how it is in the current documentation, seems to be up to date.

https://www.renpy.org/doc/html/config.h ... menu_music

Do this at the top of a script file:

Code: Select all

init python -2:
    config.main_menu_music = theme
This should automatically loop. Try this, and if it works then from there we can figure out how to do fadein.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 8:21 pm
by dvemail
yes, that works.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 8:24 pm
by SuperbowserX
I don't know how you can give it a fadein/fadeout loop in Ren'py.

But, you can edit the audio file in Audacity or some other audio editing program to give it a fade in or fade out effect (so that the fadein/fadeout is inherent in the audio file and not the playing of it by Ren'py).

Also, once you get to label start, you need to put a "stop music fadeout 1.0" line because the main menu theme will continue playing after the main menu until you stop it or play something else.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 8:34 pm
by Imperf3kt
and we've gone full circle, right bac k to
Imperf3kt wrote:Main menu music always plays automatically by design

To fade main menu audio in, use an audio editor such as Audacity.

Re: audio.main_theme - where / how to customize?

Posted: Wed Feb 22, 2017 8:49 pm
by philat
Probably simpler to just edit the music files. Technically, you can probably also use on show / on hide with Play() and Stop() (https://www.renpy.org/doc/html/screen_actions.html#Play / viewtopic.php?f=8&t=33613 ) to get the same effect, but is it really worth the hassle?