GMS 2 audio_play_in_sync_group() doesn't return unique ID



I'm currently using audio sync groups for multi intensity music in my game. The idea is to have 3 pieces of music play in the sync group, and then cross fade between them as the intensity of the game increases.

From the GameMaker Studio 2 help file on audio_play_in_sync_group():
The function returns a unique ID value for the sound that has been added (distinct to the sound index) which can then be used as usual in all the other audio functions.
The example code provided in the help file:
sg = audio_create_sync_group(true);
snd[0] = audio_play_in_sync_group(sg, sound1);
snd[1] = audio_play_in_sync_group(sg, sound2);
snd[2] = audio_play_in_sync_group(sg, sound3);
snd[3] = audio_play_in_sync_group(sg, sound4);
audio_sound_gain(snd[1], 0, 0);
audio_sound_gain(snd[2], 0, 0);
audio_sound_gain(snd[3], 0, 0);
Now as I understand GML, using audio_sound_gain(snd[1], 0, 0) would only change the gain of the instance of sound2 created with audio_play_in_sync_group(sg, sound2). However if you used audio_sound_gain(sound2,0,0) you would change the gain of ALL audio instances that were created from sound2.

However, if you look at the values returned from the above code you get:
snd[0] = 0
snd[1] = 1
snd[2] = 2
snd[3] = 3
You get 0,1,2 & 3 regardless of what order you put in sound1,2,3 & 4. Also it doesn't matter if you have a project filled with audio files, the output is always 0,1,2 & 3 which are just the first 4 audio files you loaded into the IDE.

I have reported this as a bug to the helpdesk, but was told that this was apparently not a fault or a bug, which I'm finding hard to accept. I was told that audio_play_in_sync_group() merely returns the order that the sounds were added to the audio sync group, which is a trivial thing to return and not useful at all.

I mention this because audio_play_sound() does return a unique ID for the instance of the sound being played, whose gain you can then be adjusted without adjusting the gain of all other instance created from that sound index.

Example project illustrating the problem I'm having:

Any advice or guidance is very much appreciated.


So in short, audio_play_in_sync_group() not returning a unique ID makes it impossible to adjust the gain of sounds in an audio group
without adjusting the gain of all other sounds played using the same sound index.
I just tested your project, and its just as you said, audio_play_in_sync_group() is returning 0, 1, 2, 3 each sound is added.

This is similar behaviour to how data structures behave, but in the case of data structures, each type of ds is mapped independently to those indexes.

So can confirm it is then not possible to use that id returned (0,1,2, 3...etc) because when you use those indexes in normal audio_sound_gain() they get treated as object_indexes, as per the resource tree, and not unique instance indexes for the sounds added.

So either the documentation is incorrect, because it says it does return a unique index for that instance of the sound, or there is a bug / not useful behaviour in the return value from the audio_play_in_sync_group().

I would persist with the helpdesk route for now, or perhaps @Nocturne can can take a look at the docs to see if that is the correct workings of the function.