Skip to content

Instantly share code, notes, and snippets.

@PoppyWorks
Last active August 14, 2018 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PoppyWorks/6597aa9877b70bae9dd8af29c1bdcfb9 to your computer and use it in GitHub Desktop.
Save PoppyWorks/6597aa9877b70bae9dd8af29c1bdcfb9 to your computer and use it in GitHub Desktop.
GML Script. This sets up all listeners available on a target platform. In the case of PS4, you can use this to play audio on a DS4 speaker. Run before running anything using audio_play_sound_on();. In addition, this fixes GMS games being too quiet or low volume on consoles. Best run in a Create event.
///setup_audio();
var lc = audio_get_listener_count();
var masks;
masks[0] = 0;
masks[1] = 0;
masks[2] = 0;
masks[3] = 0;
alert("Number of Audio Listeners: " + string(lc),0)
for (var i = 0; i < lc; i++)
{
var inf = audio_get_listener_info(i);
if (string_pos("controller", inf[? "name"]) == 1
and string_pos("speaker", inf[? "name"]) > 0)
{
var pad_index = real(string_ord_at(inf[? "name"], 11) - ord('1'));
masks[pad_index] = inf[? "mask"];
}
}
for (var i = 0; i < 4; i++)
{
emit[i] = audio_emitter_create()
audio_emitter_set_listener_mask(emit[i], masks[i])
}
///BOOST VOLUME FOR CONSOLE
///When gamemaker exports to console, it's really quiet!
///The way to fix this is here, with audio_master_gain();
///The docs say that it goes from 0 to 1, when in fact, it goes beyond 1! wow!!
if os_type == os_ps4 || os_type == os_xboxone || os_type == os_psvita
{
audio_master_gain(3);
}
@PoppyWorks
Copy link
Author

Recently discovered that audio_master_gain(); fixes the issue of games being too quiet on consoles, so this was added to the bottom of our script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment