GameMaker Studio 2 has a complete audio engine that is based on the *.ogg, *.mp3 and *.wav sound formats. Sounds of these types added to the IDE can then be used in your game using the basic audio functions shown below. For things more complex than basic sound effects or playing a single piece of music you can refer to the advanced audio functions which let you modify how a sound is played. There are also a selection of more specialised functions dedicated to streaming audio, positioning audio - to give 3D sound - and grouping audio.

IMPORTANT! When using audio on the HTML5 target, you should be aware that not all browsers support Web Audio and so may not play any sound for your project when run. You can get a general idea of Web Audio support from the following link: Can I Use Web Audio?.

The following functions are for dealing with audio in the most straightforward and simple way possible, avoiding the use of emitters and permitting the user to generate sounds and play music easily as these sounds are always generated at the listener position (see the section linked below for more details on the listener) and so are generally not affected by any changes to the listener:


The following functions are designed to give more control over how the audio engine works, and how the sounds played through it will be "heard" by the listener. As such it is recommended that you have a good working knowledge of how the rest of the GameMaker Studio 2 audio engine works before using any of the following functions:


Further advanced functionality, like setting listeners, recording audio, or synchronising multiple audio tracks over time can all be found from the sub-sections listed below:


Web Audio

When creating games for the HTML5 target platform, the audio engine requires Web Audio support, and this in turn means that sometimes your audio won't play when or how you expect it. This is because the Web Audio context may not be running or may stop running when your game is being played. What causes this varies greatly between browsers, and even between different versions of the same browser, and so detecting when the web audio context status changes is very important, e.g.: to detect when the context changes and pause/start looping audio like background music.

To help with this issue, GameMaker Studio 2 has two separate ways to detect the change in Web Audio context status, either using the following function:


You may also use the Asynchronous System Event, which will be triggered whenever the Web Audio status changes. In this event you will get the built in async_load DS map populated with the key "event_type" which in turn will hold the string "audio_system_status" if it is an audio event. When this key exists, there will also be a further "status" key which will be either "available" or "unavailable". Note that this event will be triggered on all platforms, but on everything except HTML5 it will only be triggered once on Game Start when the audio engine is first initialised. For more information please see the section: