Lead in and loop for main menu music?

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
Binno
Newbie
Posts: 6
Joined: Sun Jun 21, 2015 3:21 pm
Contact:

Lead in and loop for main menu music?

#1 Post by Binno »

Searched all over, yadda yadda, couldn't find any answers that worked.

Right now I'm using

Code: Select all

config.main_menu_music = ["Lead.mp3", "Loop.mp3"]
And it works as a queue, but I can't figure out how to get the loop part to play as a loop without going back to lead after it's finished. I've tried hamfisting it but I can't get it to work with the regular statements for sound and music. Maybe I'm even less clever than I thought. Instead of looping the past point I've tried just having 10+ Loop.mp3s queued after Lead.mp3 but this is really tacky and I still have the next problem to deal with in that situation;
There's a millisecond cut of silence inbetween Lead and Loop. I know this isn't a part of the audio because I've tested it beforehand, it does this inbetween every other track too. Is there anyway to get rid of this? It sounds terrible and despite being really quick it's very noticeable. I'd try overlapping it a tiny fraction but if I knew how to get those statements to work too I probably wouldn't need to be asking this.

Please help if you can.

User avatar
Daedalus
Newbie
Posts: 14
Joined: Fri Jul 31, 2015 12:09 am
Contact:

Re: Lead in and loop for main menu music?

#2 Post by Daedalus »

Do you really need to make it two separate files? Just have one file that's like 4-5 minutes long and play that from the beginning. Nobody is going to stay in the menu for that long anyway.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Lead in and loop for main menu music?

#3 Post by nyaatrap »

Code: Select all

label before_main_menu:
    play music "lead.ogg" noloop
    queue music "loop.ogg" loop
you can't use mp3. There's no way to loop mp3 file smoothly anyway.

Binno
Newbie
Posts: 6
Joined: Sun Jun 21, 2015 3:21 pm
Contact:

Re: Lead in and loop for main menu music?

#4 Post by Binno »

nyaatrap wrote:

Code: Select all

label before_main_menu:
    play music "lead.ogg" noloop
    queue music "loop.ogg" loop
you can't use mp3. There's no way to loop mp3 file smoothly anyway.
Thanks.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Lead in and loop for main menu music?

#5 Post by Donmai »

I was curious because I've never used the 'before_main_menu' label before. Tried this code and it actually played the music pieces correctly, but it also started the game before showing the main_menu.
Adding a 'return' apparently solved the problem. Is this the right thing to do?
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Lead in and loop for main menu music?

#6 Post by nyaatrap »

Unlike python functions, ren'py label continues to the next label. Thus all labels should be ended with return or jump. I just forgot it to write it.
label before_main_menu was important for adding animating background on the main menu before 6.18 because of screen performance issue.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Lead in and loop for main menu music?

#7 Post by Donmai »

Thanks for the code and the explanation. I use a lot of musical loops, so this is still very useful for my main menus.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

paper
Newbie
Posts: 5
Joined: Thu Aug 06, 2015 9:18 pm
Projects: Augury Court
Location: not Canada
Contact:

Re: Lead in and loop for main menu music?

#8 Post by paper »

Hi! So. New here. Also new to coding. I'm also wanting to include bgm to the main menu, like OP. However, I'm not able to get my music to play.
I have made a bgm subfolder in the game directory.
I have attempted to play my file through the options page, via config.main_menu_music = "gypsy_shoegazer.mp3" (and have removed the # in accordance with keeping code in line).
I have also gone to the script page and tried to use the aforementioned label before_main_menu
. . . And neither have successfully worked. I will return to my main menu just fine, but no music will play. I'm not quite sure how to fix this? A detailed description of what to do would be most appreciated. <3

paper

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Lead in and loop for main menu music?

#9 Post by trooper6 »

if you file is in a folder called "bgm" that is in the game folder, then you need to indicate that in the file name, like so: "bgm/gypsy_shoegazer.mp3"
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

paper
Newbie
Posts: 5
Joined: Thu Aug 06, 2015 9:18 pm
Projects: Augury Court
Location: not Canada
Contact:

Re: Lead in and loop for main menu music?

#10 Post by paper »

Hi there!
I rewrote it to bgm/gypsy_shoegazer.mp3; however, my game still remained silent in the opening page. So, I went to my mp3 file to make sure the name was right and it told me the name was Gypsy Shoegazer.mp3
I rewrote it to be bgm/Gypsy Shoegazer.mp3 just to see if it would work, but as guessed, it told me it couldn't find it. So I changed it back and it led me to the main menu. . . but still no sound. And my file plays just fine outside of ren'py so I'm not sure what to try next.

paper

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Lead in and loop for main menu music?

#11 Post by Donmai »

Check that you haven't muted your music channel by accident (look on your preferences screen).
If you downloaded the music file without renaming it, then use

Code: Select all

config.main_menu_music = "bgm/Gypsy Shoegazer.mp3"
and run your game. The Kevin MacLeod song should start playing before you can say "supercalifragilisticexpialidocious".
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

paper
Newbie
Posts: 5
Joined: Thu Aug 06, 2015 9:18 pm
Projects: Augury Court
Location: not Canada
Contact:

Re: Lead in and loop for main menu music?

#12 Post by paper »

Thanks, Donmai. I checked on the prefs menu and the music volume is all the way up. I copied your code into my script and. . . it still isn't playing. But it didn't tell me it couldn't find the song, so that's a step in the right direction at least. Do you have anything else for me to try?

paper

edit:: I tried a different song and refreshed. Then it told me it couldn't find shoegazer? So I refreshed again, saving ALL open scripts, not just the one I was working on. And my new song suddenly worked. . . So I went through all the scripts trying to find out what was wrong, though I couldn't see anything else pertaining to sound.
Moral of the story: save everything?

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Lead in and loop for main menu music?

#13 Post by Donmai »

paper wrote:Moral of the story: save everything?
Yes, always :) .
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

paper
Newbie
Posts: 5
Joined: Thu Aug 06, 2015 9:18 pm
Projects: Augury Court
Location: not Canada
Contact:

Re: Lead in and loop for main menu music?

#14 Post by paper »

It's me again. . . I feel as though I've taken over this thread but I still have a relevant question.
It occurred to me that my main menu music plays over the entire game. I tried to insert music into the actual gameplay but lo, the main menu music has taken over!!
So what I'm asking is. . . how do I make it stop?!
Has anyone else ever had this happen? How should I fix it?

edit::
I should probably search more thoroughly before asking questions.

Code: Select all

label start:
    stop music
    play music "bgm/Sunset at Glengorm.mp3" fadeout 1.0 fadein 1.0
    # continue game

Post Reply

Who is online

Users browsing this forum: Google [Bot], Rhapsy