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 Audio emitter sound problem

Discussion in 'Programming' started by Holy Moly, Sep 2, 2017.

  1. Holy Moly

    Holy Moly Guest

    I have set 3d sounds to some bullets in my game, so the sound has falloff and changes it's speaker orientation depending on the listener (player) position. Those bullets make a sound as they travel. At this point, the 3d sound works perfectly.

    However, when a bullet is destroyed, I want it to a make a different sound with the same falloff and sound orientation properties. The problem is that if I don't free each bullet's emitter on destroy event, it will result on a memory leack; and freeing a bullet's emitter seems to not be allowing me to play the "bullet destroy sound effect". I had thought on freeing the bullet's emitters on room end, but if the bullet spawner makes too many bullets before room end, it will also result on a memory leack.

    Is there a way to don't stop an object's last emitted sound after that emitter was freed?
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,469
    Nope. Personally I have a custom script for these situations which just calls audio_play_sound_at and uses my global falloff settings so it will match up to the sounds of your emitters.

    Code:
    ///scr_audio_play_sound_at(asset,gain,x,y)
    gml_pragma(forceinline);
    var s=audio_play_sound_at(argument0,argument2,argument3,1,global.falloff_ref_dist,global.falloff_max_dist,global.falloff_factor,false,1);
    audio_sound_gain(s,argument1*global.sfx_volume_setting*global.sfx_internal_gain,0);
    return s;
    
     
  3. Smiechu

    Smiechu Member

    Joined:
    Jul 14, 2017
    Posts:
    626
    In destruction event you can "send" the ID of sound emmiter to your "obj_game" or whatever you have for governing the general things in your game...
    Game event would store the Id's in a ds_queue... Than you need to make some conditions for cleaning the queue...
    For example if queue count is 100 - destroy 20 ID from the front of the queue...
     

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