audio.main_theme - where / how to customize?

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
dvemail
Regular
Posts: 35
Joined: Sat May 28, 2016 1:50 pm
Projects: Working on Patronus
IRC Nick: dvemail
Deviantart: ObdurateDemand
Github: dvemail
Contact:

audio.main_theme - where / how to customize?

#1 Post 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?

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

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

#2 Post 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.

User avatar
dvemail
Regular
Posts: 35
Joined: Sat May 28, 2016 1:50 pm
Projects: Working on Patronus
IRC Nick: dvemail
Deviantart: ObdurateDemand
Github: dvemail
Contact:

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

#3 Post 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

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

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

#4 Post 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.

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

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

#5 Post 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.
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
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

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

#6 Post 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.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
dvemail
Regular
Posts: 35
Joined: Sat May 28, 2016 1:50 pm
Projects: Working on Patronus
IRC Nick: dvemail
Deviantart: ObdurateDemand
Github: dvemail
Contact:

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

#7 Post 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

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

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

#8 Post 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.
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
dvemail
Regular
Posts: 35
Joined: Sat May 28, 2016 1:50 pm
Projects: Working on Patronus
IRC Nick: dvemail
Deviantart: ObdurateDemand
Github: dvemail
Contact:

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

#9 Post 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?

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

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

#10 Post 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.

User avatar
dvemail
Regular
Posts: 35
Joined: Sat May 28, 2016 1:50 pm
Projects: Working on Patronus
IRC Nick: dvemail
Deviantart: ObdurateDemand
Github: dvemail
Contact:

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

#11 Post by dvemail »

yes, that works.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

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

#12 Post 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.

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

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

#13 Post 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.
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

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

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

#14 Post 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?

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]