Skip to main content

Play/Use Music, Sound Effects

Author: NingNing
Last update:2022-05-22


Renpy supports the play of music and sound effects
The files supported by Renpy are:

  • Opus
  • Ogg Vorbis
  • MP3
  • WAV

How to play music?

To play music you can use play
So your code could look like this:

  • play music "ost.ogg"
  • play music "open.mp3" If you want the music to have a short cutscene instead of the music running right out

You can use fadein
So your code could look like this:

  • play ending.mp3 fadein 1.0

How to play sound effects?

The same way as music, just change play music -> to play sound
Example:

  • play sound "writing.ogg"
  • play sound "bing.mp3"

How to stop play?

To stop playing music, sound effects, etc., you can use stop
So your code could look like this:

  • stop sound
  • stop music

If you want a short cutscene at the end of the music instead of the music just stopping
You can use fadeout
Your code could look like this:

  • stop music fadeout 1.0 or
  • stop sound fadeout 0.5

Infinite loop sound or music

You can choose to let the music or sound effects loop indefinitely

  • The code used here is loop You can also choose to let the music or sound effect stop once played
  • The code we use at this time is noloop
✨✨

If you dont specify:
Sound and Voice will only be played once
Music will loop

Why separate sound effects, music, and voice?

When using renpy, you may have this question about sound effects, what is the difference between music and sound? Why is it specially divided into sound effects, music, and voice?
The first point

  • Their defaults setting are different --> Sound and Voice will only play once / Music will play infinitely Second point
  • They are placed on different tracks
    • If you play a second piece of music before one is finished, the second piece of music will directly interrupt the first piece of music
    • If you play a second sound before the first sound is finished, the second sound will directly interrupt the first sound
    • But Music and sound effects can be played at the same time

Why can't my music, sound effects or voice play normally?

I also encounter this problem sometimes, you can check where your files are first
If you put your sound file in game/audio your code will look like this --> play sound(/music/voice) "audio/ filename.filetype"

Example:

  • play sound "audio/sund.ogg"
  • play music "audio/music.mp3"

If the problem still can't be solved, you can also check if your file is supported by renpy.
If not, you can use various website/software on the Internet to convert files.
There are quite a lot of things that can be written in this article, but I personally am not very familiar with playing voice (not the function I use very often), so this article is finish now~


This post is over now~ You can give me / my website a clap if this help you! My website --> https://spaceofningningen.blogspot.com/ Image Alt Thank you for your support~