1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

audio_group_set_gain error

Discussion in 'Programming' started by Fredrik, Sep 20, 2019.

  1. Fredrik

    Fredrik Member

    Joined:
    Jun 21, 2016
    Posts:
    183
    Hey!
    I'm trying to set the gain for the default audio group by using

    audio_group_set_gain(audiogroup_default, 0, 5000);

    However when I start the game I get an error code, saying that the variable is not set :C
     
  2. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    868
    I've just tried that exact code and it works fine. Can you post the actual error message? You haven't changed the name of the default audio group have you (through Tools>Audio Groups)?
     
  3. Fredrik

    Fredrik Member

    Joined:
    Jun 21, 2016
    Posts:
    183
    I'm making end credits in a project, and before the credits roll all volume will fade out, which I've done with audio_master_gain, but I wanted to switch it to audio_group_set_gain, so I could turn down the volume only on the default group, and then keep the volume for another group that has the credits theme (and a few other themes). but I get an error.

    So when the game is set to end, I have a variable "global.endgame = 1;"
    So if that one is set to 1, it will start to fade the audio group out like audio_group_set_gain(audiogroup_default,0,5000);

    So when the game ends and the varaible is set to 1, I get this error:

    ############################################################################################
    FATAL ERROR in
    action number 5
    of Step Event0
    for object quit:

    Variable quit.audiogroup_default(100922, -2147483648) not set before reading it.
    at gml_Object_quit_StepNormalEvent_5 (line 12) - audio_group_set_gain(audiogroup_default,0,5000);
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_quit_StepNormalEvent_5 (line 12)


    Maybe it has to be set in game start / create event? as the gain here is set in a step event.
     
    Last edited: Sep 23, 2019
  4. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    422
    if you are using that global as a flag to call game_end make sure you are changing the audio_group before you execute game end it may be getting caught in the game ending clean up and giving an error.
     
  5. Fredrik

    Fredrik Member

    Joined:
    Jun 21, 2016
    Posts:
    183
    The global variable is starting a custom eng game credits screen that I've made. screen fades to black, and all music fades out before rolling credits. It doesnt call end_game at all :/

    I was thinking that I might have to set the audio_group_gain, before setting the global var I'm using
     
    Last edited: Sep 23, 2019
  6. Fredrik

    Fredrik Member

    Joined:
    Jun 21, 2016
    Posts:
    183
    I also want to mention that I tried to put audio_group_set_gain(audiogroup_default,0,5000);
    in a create event to see if I got the same error, and I did :/
     

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