Skip to content

Sound Playback in GMC

All sounds in GMC are managed through Godot, but MPF can be used to trigger playback actions through the sound_player config settings.

All sound files (including resource files) must be placed in either a /sounds folder in the project root, or in /modes/(mode_name)/sounds folder in any mode. Subfolders within these folders are allowed as well.

Sound Resources: Files, Native, and Custom Types

GMC supports playback of sounds from a variety of different resource types interchangably. This allows you to quickly and conveniently play back back sounds from file reference, while also allowing custom sound behavior and advanced sound features by referencing a Godot resource file.

Direct File Playback

If you just want to play a sound, you can reference that sound by its file name (without extension) in the sound_player.

For example, if you have files in your project called frenzy_background_music.ogg and small_explosion_one.wav you could trigger those sounds with the following config:

                bus: music
                fade_in: 500ms
                fade_out: 1s
        drop_targets_complete: small_explosion_one

MPFSound Resource

GMC includes a custom class called MPFSound that provides properties that can be saved to a resource file. When this resource is played, the playback properties are read from the file and don't need to be passed as part of the sound_player config.

This is a convenient way to keep the same settings for a sound file without having to specify it every time it's called in sound_player.

More details on can be found on the MPFSound Reference Doc.

Other Godot Resources

Any Godot class that derives from AudioStream can also be used as a sound resource as long as its in one of the sounds folders.

AudioStreamRandomizer can be used to create a sound pool with randomized playback of any number of sounds, and/or randomized pitch and volume for quick variations on a base set of sounds to reduce repetition.

AudioStreamPolyphonic can be used to stack multiple playbacks of the same sound in a single stream rather than instantiating a separate sound playback instance for each one.

AudioStreamSynchronized (coming in Godot 4.3) can be used to layer and synchronize multiple sound files for seamless playback mixing.

AudioStreamPlaylist (coming in Godot 4.3) can be used to create playlists of sound files that can be played back, shuffled, cross-faded, and looped.

Something missing or wrong? You can fix it!

This website is edited by people like you! Is something wrong or missing? Is something out of date, or can you explain it better?

Please help us! You can fix it yourself and be an official "open source" contributor!

It's easy! See our Beginner's guide to editing the docs.

Page navigation via the keyboard: < >

You can navigate this site via the keyboard. There are two modes:

General navigation, when search is not focused:

  • F , S , / : open search dialog
  • P , , : go to previous page
  • N , . : go to next page

While using the search function:

  • Down , Up : select next / previous result
  • Esc , Tab : close search
  • Enter : go to highlighted page in the results