1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 No function for audio groups?

Discussion in 'Programming' started by PHL, Jul 13, 2017.

  1. PHL

    PHL Member

    Joined:
    Feb 16, 2017
    Posts:
    11
    No function for audio groups?

    I need a way to check if a particular sound ( e.g. scream_sound) belongs to a particular audio group ( e.g. Voices), using code. I know that you put sounds into audio groups using the resource section, but do I always need to go there if I want to check which sounds belong where? A function would help much.

    I secondly need a way to check if any sound of a particular audio group is playing. I need not specify the sound's index; I should just know whether any sound of that audio group is playing. I need this so that I can say: if any sound of Group 1 is playing, stop all sounds of Group 2.

    Now that GameMaker:Studio 1 lacks these functions, what reckon ye that I can do?

    For the first one: I have no idea.

    For the second:
    Use arrays? I could make an array representing a group, and input sounds as its positions. E.g. voices_group[0]= scream_sound;
    voices_group [1]= (another sound); etc.
    And if I want to check if any sound is playing, I run a for-loop from 0 to (number of sounds-1).

    I'm confused and need help. Or maybe there's no way?
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,469
    There's no built-in way, but you know that. Personally, I feel you shouldn't need that kind of function as it kind of defeats the purpose of audiogroups. When your player starts a new level or enters an area you should probably load up all the audiogroups that are needed for that area and unload the rest, as well as any other loading/unloading of other stuff you need/don't need. That would be the "standard" practice anyway.

    Apart from that, you would have to make your own way to track that, either by building a list or array as you mentioned or you could also use a naming convention...

    // example
    snd_01_something

    ... whereas 01 is the name of the audiogroup / level / etc. Then at the start of the game you could automatically build your lists by using audio_get_name and string_pos or something similar.

    I guess you COULD write a script that plays a sound, checks to see if it's playing and if not, load the audiogroup for it (using your array/list ) and retry, but that's going to be messy and probably will cause hiccups in the audio and dropped frames.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice