Reference Manual: (offline | online) Quickstart: (offline | online)

Audio

Ren'Py supports playing music and sound effects in the background, using any of the following audio file formats:

Ren'Py supports eight channels of audio. By default, the first three channels (0-2) are dedicated to sound effects, while the rest are intended for music. When the voice extra is used to provide a voice support interface, channel 2 is reserved for playing the voice audio files, instead of general sound effects. The 'Music Volume', 'Sound Volume', and potentially the 'Voice Volume' settings of the in-game preferences menu are used to set individual volumes for each group of channels.

Sounds can also be set to play when buttons, menu choices, or imagemaps enter their hovered or activated states. See Sound Properties.

Statements

The usual way to play music and sound in Ren'Py is using the three music/sound statements:

The advantage of using these statements is that your program will be checked for missing sound and music files when lint is run. The functions below exist to allow access to allow music and sound to be controlled from python, and to expose advanced (rarely-used) features.

Music Functions

The music subsystem, unlike the general sound effect functions, keeps track of what should be playing at any particular spot in the script. This means that the correct music will play after loading a saved game, or after using rollback or returning from the game menu. This is also useful for sound effects such as wind or background noise loops that are intended to play over multiple script lines.

The music functions, like the sound effect functions, implements a queue system, allowing multiple music files to be playing, or to be in line to be played, at any given time.

Two configuration variables, config.main_menu_music and config.game_menu_music allow for the given music files to be played as the main and game menu music, respectively.

Function: renpy.music.play( filenames, channel=7, loop=True, fadeout=None, synchro_start=False, fadein=0, tight=False, if_changed=False)

This stops the music currently playing on the numbered channel, dequeues any queued music, and begins playing the specified file or files.

filenames may be a single file, or a list of files.

loop - If True, the tracks will loop while they are the last thing in the queue.

fadeout - If None, the fadeout time is taken from config.fade_music , otherwise it is a time in seconds to fade out for.

synchro_start - If True, all the channels that have had play called on them with synchro_start set to True will be started at the same time, in a sample accurate manner. This can be used to, for instance, have a piece of music separated into separate percussion, melody, and background chord audio files, and play them simultaneously.

fadein - The number of seconds to fade the music in for, on the first loop only.

tight - If True, then fadeouts will span into the next-queued sound.

if_changed - If True, and the music file is currently playing, then it will not be stopped/faded out and faded back in again, but instead will be kept playing. (This will always queue up an additional loop of the music.)

Sound Effect Functions

The sound effect functions, unlike the music functions, are intended for short audio files providing emphasis for a particular script interaction. This is because they do not persist through game loads, rollback, or menu changes, and thus will only be played at the point in the script where the actual play command is called.

Function: renpy.play( filename, channel=0, fadeout=0, fadein=0, tight=False)

This is an alias for renpy.sound.play

Plays the named file once on the given channel. This will cause any playing sound effect to be stopped (after the given fadeout number of seconds, if necessary), and the new sound to be played in its place. The sound is faded in for the given number of seconds.

The filename may be that of a file in an archive.

If tight is True, then a fadeout of this sound will continue into the next-queued sound.

Reference Manual: (offline | online) Quickstart: (offline | online)