Menus and 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.
Message
Author
Lunethex
Regular
Posts: 61
Joined: Tue Feb 02, 2010 4:01 pm
Contact:

Menus and Music

#1 Post by Lunethex » Wed Apr 21, 2010 5:39 am

How do you get the main menu to play music? I set it up properly but it's not making any sound. Also, how do you get music to play for the option menu?

Also, I want a menu to contain certain scenes from the game. Is this possible? And how would I add music to that menu too?

User avatar
fluffycurry
Regular
Posts: 29
Joined: Sun Apr 18, 2010 9:43 am
Projects: IDOL WORLD(UI)
Location: Private Island
Contact:

Re: Menus and Music

#2 Post by fluffycurry » Wed Apr 21, 2010 6:26 am

Lunethex wrote: How do you get the main menu to play music? I set it up properly but it's not making any sound. Also, how do you get music to play for the option menu?
just change the

Code: Select all

config.main_menu_music = "musicfile.mp3"
in the option.rpy, make sure that it is in the game directory to have it playing.

and also...

Code: Select all

config.has_music = True
it must be true (for obvious reasons)
changing the music in the preference menu

Code: Select all

config.game_menu_music = None
just change none into a music file
Lunethex wrote: Also, I want a menu to contain certain scenes from the game. Is this possible? And how would I add music to that menu too?
you mean a CG gallery??, its here
you can add music by simply putting "play music"

Code: Select all

label cg_gallery:
stop music fadeout 1.5 #will fade and then stop at 1.5 sec
play music "musicfile.mp3"
###gallery code
i feel that you can use this somewhere O_O..but i dunno why

Code: Select all

$ _preferences.set_volume ('music', 0.0)
Last edited by fluffycurry on Wed Apr 21, 2010 7:55 pm, edited 1 time in total.
I SUCKED at English you see, so please forgive me for any grammatical errors. I'm trying to improve you know
BLOG BLOG BLOG BLOG

GONE UNTIL FURTHER NOTICE

Lunethex
Regular
Posts: 61
Joined: Tue Feb 02, 2010 4:01 pm
Contact:

Re: Menus and Music

#3 Post by Lunethex » Wed Apr 21, 2010 11:23 am

What part of "Set it up properly" wasn't correct?

I asked, how can I make it play properly? The in game music works but the menu music does not.

User avatar
fluffycurry
Regular
Posts: 29
Joined: Sun Apr 18, 2010 9:43 am
Projects: IDOL WORLD(UI)
Location: Private Island
Contact:

Re: Menus and Music

#4 Post by fluffycurry » Wed Apr 21, 2010 7:54 pm

Lunethex wrote:What part of "Set it up properly" wasn't correct?

I asked, how can I make it play properly? The in game music works but the menu music does not.

What do you mean @_@ by making it 'play properly'?
if you have set up the config.main_menu_music = "musicfile.mp3"
it should already play music in your main menu, even if your using imagemap or ui buttons

:>
its either the music your playing is not supported by renpy (see here)
or the directory of the music is off (maybe its inside a folder or something)


i tried it and it worked for me.
main menu music is playing :>
I SUCKED at English you see, so please forgive me for any grammatical errors. I'm trying to improve you know
BLOG BLOG BLOG BLOG

GONE UNTIL FURTHER NOTICE

Lunethex
Regular
Posts: 61
Joined: Tue Feb 02, 2010 4:01 pm
Contact:

Re: Menus and Music

#5 Post by Lunethex » Thu Apr 22, 2010 1:46 am

Does it help to say that I'm using the "Template" provided by Ren'py when you first download it?

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Menus and Music

#6 Post by Aleema » Thu Apr 22, 2010 1:51 am

Lunethex wrote:Does it help to say that I'm using the "Template" provided by Ren'py when you first download it?
Not really. If it doesn't work it's likely you've put the code in the wrong place, or your media file simply doesn't work with Ren'Py, like fluffycurry is trying to tell you. Make sure the audio is actually enabled for your game, too. And, double-triple-check that your file actually exists where you're telling Ren'Py it is. The engine keeps playing the game, even if it can't find the audio you define.

Lunethex
Regular
Posts: 61
Joined: Tue Feb 02, 2010 4:01 pm
Contact:

Re: Menus and Music

#7 Post by Lunethex » Thu Apr 22, 2010 2:23 am

Common sense, it's what you think I don't have.

Ok, I'll show you exactly what the thing looks like. I've literally tried everything, using the original Mp3, naming it winds.ogg, nothing works. I can play the music in the game, meaning everything is fine. Explain this to me.

Image

Code: Select all

## This file contains some of the options that can be changed to customize
## your Ren'Py game. It only contains the most common options... there
## is quite a bit more customization you can do.
##
## Lines beginning with two '#' marks are comments, and you shouldn't
## uncomment them. Lines beginning with a single '#' mark are
## commented-out code, and you may want to uncomment them when
## appropriate.

init -1 python hide:

    ## Should we enable the use of developer tools? This should be
    ## set to False before the game is released, so the user can't
    ## cheat using developer tools.

    config.developer = True

    ## These control the width and height of the screen.

    config.screen_width = 1024
    config.screen_height = 768

    ## This controls the title of the window, when Ren'Py is
    ## running in a window.

    #########################################
    # Layouts
    
    ## This enables the use of an in-game menu that is made out of
    ## buttons.

    layout.button_menu()

    #########################################
    # Themes
    
    ## We then want to call a theme function. themes.roundrect is
    ## a theme that features the use of rounded rectangles. It's
    ## the only theme we currently support.
    ##
    ## The theme function takes a number of parameters that can
    ## customize the color scheme.

    theme.roundrect(
        # Color scheme: Bloody Mary
                                    
        ## The color of an idle widget face.
        widget = "#000000",

        ## The color of a focused widget face.
        widget_hover = "#830000",

        ## The color of the text in a widget.
        widget_text = "#C2C2C2",

        ## The color of the text in a selected widget. (For
        ## example, the current value of a preference.)
        widget_selected = "#ffffff",

        ## The color of a disabled widget face. 
        disabled = "#400000",

        ## The color of disabled widget text.
        disabled_text = "#260000",

        ## The color of informational labels.
        label = "#ffffff",

        ## The color of a frame containing widgets.
        frame = "#400808",

        ## The background of the main menu. This can be a color
        ## beginning with '#', or an image filename. The latter
        ## should take up the full height and width of the screen.
        mm_root = "Idola City Entrance 1.jpg",

        ## The background of the game menu. This can be a color
        ## beginning with '#', or an image filename. The latter
        ## should take up the full height and width of the screen.
        gm_root = "#000000",

        ## If this is True, the in-game window is rounded. If False,
        ## the in-game window is square.
        rounded_window = False,

        ## And we're done with the theme. The theme will customize
        ## various styles, so if we want to change them, we should
        ## do so below.            
        )


    #########################################
    ## These settings let you customize the window containing the
    ## dialogue and narration, by replacing it with an image.

    ## The background of the window. In a Frame, the two numbers
    ## are the size of the left/right and top/bottom borders,
    ## respectively.

    # style.window.background = Frame("frame.png", 12, 12)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    # style.window.left_margin = 6
    # style.window.right_margin = 6
    # style.window.top_margin = 6
    # style.window.bottom_margin = 6

    ## Padding is space inside the window, where the background is
    ## drawn.

    # style.window.left_padding = 6
    # style.window.right_padding = 6
    # style.window.top_padding = 6
    # style.window.bottom_padding = 6

    ## This is the minimum height of the window, including the margins
    ## and padding.

    # style.window.yminimum = 250


    #########################################
    ## This lets you change the placement of the main menu.

    ## The way placement works is that we find an anchor point
    ## inside a displayable, and a position (pos) point on the
    ## screen. We then place the displayable so the two points are
    ## at the same place.

    ## An anchor/pos can be given as an integer or a floating point
    ## number. If an integer, the number is interpreted as a number
    ## of pixels from the upper-left corner. If a floating point,
    ## the number is interpreted as a fraction of the size of the
    ## displayable or screen.

    # style.mm_menu_frame.xpos = 0.5
    # style.mm_menu_frame.xanchor = 0.5
    # style.mm_menu_frame.ypos = 0.75
    # style.mm_menu_frame.yanchor = 0.5


    #########################################
    ## These let you customize the default font used for text in Ren'Py.

    ## The file containing the default font.

    # style.default.font = "DejaVuSans.ttf"

    ## The default size of text.

    # style.default.size = 22

    ## Note that these only change the size of some of the text. Other
    ## buttons have their own styles.


    #########################################
    ## These settings let you change some of the sounds that are used by
    ## Ren'Py.

    ## Set this to False if the game does not have any sound effects.

    config.has_sound = True

    ## Set this to False if the game does not have any music.

    [b]config.has_music = True[/b]

    ## Set this to False if the game does not have voicing.

    config.has_voice = False

    ## Sounds that are used when button and imagemaps are clicked.

    # style.button.activate_sound = "click.wav"
    # style.imagemap.activate_sound = "click.wav"

    ## Sounds that are used when entering and exiting the game menu.

    # config.enter_sound = "click.wav"
    # config.exit_sound = "click.wav"

    ## A sample sound that can be played to check the sound volume.

    # config.sample_sound = "click.wav"

    ## Music that is played while the user is at the main menu.
    
    [b]# config.main_menu_music = "winds.ogg"[/b]


    #########################################
    ## Help.

    ## This lets you configure the help option on the Ren'Py menus.
    ## It may be:
    ## - A label in the script, in which case that label is called to
    ##   show help to the user.
    ## - A file name relative to the base directory, which is opened in a
    ##   web browser.
    ## - None, to disable help.   
    config.help = "README.html"


    #########################################
    ## Transitions.

    ## Used when entering the game menu from the game.
    config.enter_transition = None

    ## Used when exiting the game menu to the game.
    config.exit_transition = None

    ## Used between screens of the game menu.
    config.intra_transition = None

    ## Used when entering the game menu from the main menu.
    config.main_game_transition = None

    ## Used when returning to the main menu from the game.
    config.game_main_transition = None

    ## Used when entering the main menu from the splashscreen.
    config.end_splash_transition = None

    ## Used when entering the main menu after the game has ended.
    config.end_game_transition = None

    ## Used when a game is loaded.
    config.after_load_transition = None

    ## Used when the window is shown.
    config.window_show_transition = None

    ## Used when the window is hidden.
    config.window_hide_transition = None


    #########################################
    ## This is the name of the directory where the game's data is
    ## stored. (It needs to be set early, before any other init code
    ## is run, so the persisten information can be found by the init code.)
python early:
    config.save_directory = "template-1220804310"

init -1 python hide:
    #########################################
    ## Default values of Preferences.

    ## Note: These options are only evaluated the first time a
    ## game is run. To have them run a second time, delete
    ## game/saves/persistent

    ## Should we start in fullscreen mode?

    config.default_fullscreen = False

    ## The default text speed in characters per second. 0 is infinite.

    config.default_text_cps = 0

    #########################################
    ## More customizations can go here.
Last edited by Lunethex on Mon May 17, 2010 4:51 pm, edited 1 time in total.

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Menus and Music

#8 Post by Jake » Thu Apr 22, 2010 2:45 am

Lunethex wrote:

Code: Select all

    # config.main_menu_music = "winds.ogg"
Here's your problem - the line is actually commented out. Remove the '#' from the beginning, and it should work.

I guess it's commented out by default because the file it points to doesn't exist by default, but since Ren'Py doesn't actually throw any error when you try to play music that doesn't exist it's not entirely necessary...

(Basically, if you prefix your line with a '#' character, Ren'Py will completely ignore it from the '#' onwards. It's usually used as a way to write comments about your code without affecting the code itself, but sometimes - like in options.rpy - it's used to hide lines of code that you don't want to be run.)
Server error: user 'Jake' not found

Lunethex
Regular
Posts: 61
Joined: Tue Feb 02, 2010 4:01 pm
Contact:

Re: Menus and Music

#9 Post by Lunethex » Thu Apr 22, 2010 2:55 am

Yes, it actually does work now. Thanks again, Jake.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Menus and Music

#10 Post by Aleema » Thu Apr 22, 2010 12:14 pm

Lunethex wrote:Common sense, it's what you think I don't have.
No ... noo ... of course you have -- *checks what was the problem* Oh, haha! Don't you feel silly?

User avatar
fluffycurry
Regular
Posts: 29
Joined: Sun Apr 18, 2010 9:43 am
Projects: IDOL WORLD(UI)
Location: Private Island
Contact:

Re: Menus and Music

#11 Post by fluffycurry » Thu Apr 22, 2010 10:54 pm

Lunethex wrote:Common sense, it's what you think I don't have.
i never thought of you that way *sniff* *sniff* :(
I SUCKED at English you see, so please forgive me for any grammatical errors. I'm trying to improve you know
BLOG BLOG BLOG BLOG

GONE UNTIL FURTHER NOTICE

User avatar
tohtamish
Regular
Posts: 64
Joined: Thu Apr 29, 2010 4:56 am
Contact:

Re: Menus and Music

#12 Post by tohtamish » Tue May 04, 2010 9:32 pm

how can I set sound level?
Tried:
$ _preferences.set_volume ('sound', 0.3)

- doesnt work.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Menus and Music

#13 Post by Aleema » Wed May 05, 2010 6:42 am

tohtamish wrote:how can I set sound level?
Tried:
$ _preferences.set_volume ('sound', 0.3)

- doesnt work.
You want:

Code: Select all

$ renpy.music.set_volume(0.1, 2.0, channel="music")
Where "0.1" is the percentage of volume (0.1 = 10%, so very low), the "2" means how long, in seconds, you want the shift to take place (0 for immediate change, or just don't write one at all), and the channel is self-explanatory.

User avatar
tohtamish
Regular
Posts: 64
Joined: Thu Apr 29, 2010 4:56 am
Contact:

Re: Menus and Music

#14 Post by tohtamish » Wed May 05, 2010 1:46 pm

I need to define sound level, not music...

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Menus and Music

#15 Post by Aleema » Wed May 05, 2010 1:56 pm

I guess "channel" wasn't so self-explanatory after all.
That code will work with whatever channel you give it. "sound" is a channel.

Alternatively, the same code exists for renpy.sound.set_volume.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]