Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:all-features:audio [2021/05/18 00:09]
silver-streak [Playing a sound or a music file]
gdevelop5:all-features:audio [2021/11/22 23:06] (current)
Line 12: Line 12:
 Choose the file to be played for the first parameter of both actions. Choose the file to be played for the first parameter of both actions.
  
-The difference between sound and music is that music files are usually larger and longer audio files. The supported audio file formats for GDevelop are Waveform Audio Format (wav), MPEG Layer 3 (mp3), Ogg Vorbis (ogg), and Advance Audio Coding (AAC)+The supported audio file formats for GDevelop are Waveform Audio Format (wav), MPEG Layer 3 (mp3), Ogg Vorbis (ogg), and Advance Audio Coding (AAC)
  
 <note>Ogg files can be containers for multiple types of audio, most commonly Vorbis and Opus. Ogg Vorbis files are much more broadly supported by different browsers and OSes, so it is recommended to use Ogg Vorbis encoding if using ogg files.</note> <note>Ogg files can be containers for multiple types of audio, most commonly Vorbis and Opus. Ogg Vorbis files are much more broadly supported by different browsers and OSes, so it is recommended to use Ogg Vorbis encoding if using ogg files.</note>
Line 27: Line 27:
 </note> </note>
  
 +## Choosing between Sound or Music Events
 +GDevelop has two different methods of playing audio files. These are listed in the engine as **Play a Sound** or **Play a Music file** events, along with related events to these two different methods.
  
 +In the majority of use cases, audio should be played using the **Play a Sound** events. This is a newer method of playing audio, and will lead to less issues with looping sound files. Think of these events as playing a sound //file// and //not// playing a //sound effect// to avoid confusion.
 +
 +The music events are an older method of playing sound files, and in most cases does not buffer the audio. Due to this, it can lead to a slight pause when looping a sound file. These events are mostly kept for backwards compatibility, and are not recommended for use when building a new game.
  
 ## Keep music and sounds playing between scenes ## Keep music and sounds playing between scenes
Line 50: Line 55:
 ## Performance considerations ## Performance considerations
  
-The first time music or sound is played, there can be a lag while the audio file is being prepared. If it's essential to avoid any lag, you can play the audio or music file at the beginning of the scene where it's used. Set the initial volume 0; this will force the game to load the sound or music. The audio will be cached in memory. It will quickly load when called using your action.+The sound events are for playing any sound files, not just sound effects files, and should be used for all audio needs //including music//, especially if you are going to use looping audio. The music events use a legacy method of playing audio, and remain available to allow for backwards compatibility with games built using them.  
 + 
 +The first time music or sound is played, there can be a lag while the audio file is being prepared if you do not preload the audio. If it's essential to avoid any lag, you can preload the audio files in the resources panel. Within the resource list, click on the sound file in question and choose the appropriate **Preload as Sound** or **Preload as Music** option depending on which events you are using.  
 + 
 +Another option is to play the audio or music file at the beginning of the scene where it's used. Set the initial volume 0; this will force the game to load the sound or music. The audio will be cached in memory. It will quickly load when called using your action.
  
 ## More about the state of a sound/music ## More about the state of a sound/music