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 Problems with Old / New sound engine

Discussion in 'Programming' started by hijong park, Mar 11, 2019.

  1. hijong park

    hijong park Member

    Joined:
    Dec 29, 2016
    Posts:
    131
    I'm trying to implement 3D sound that changes the sound's volume based on the distance between the player and the object that makes the sound. I need audio_listener_position() and audio_play_sound_at() to make it, Which only work with the new sound engine.

    But If i use the new sound engine, A strange problem happens to the automatic weapon sounds. When I make automatic weapon that rapidly fires the bullets, I make the gun sound to stop before playing it again like this:



    Code:
    sound_stop(sound_gunsound); sound_play(sound_gunsound);


    The purpose of it is to block overlapping the weapon's sound. When I keep firing an automatic weapon, especially an extremely fast one, The sounds overlap each other and it can sound really awful. This method solves that problem, and many other games I have played including Doom used similar method as well.

    but 'sound_' codes only work in the old sould engine, so I have to use this instead for the new sound engine:



    Code:
    audio_stop_sound(sound_gunsound); audio_play_sound(sound_gunsound,0,0);


    But for some reason, consequently stopping the sound before playing another one doesn't work well in the new sound engine.

    It basically works, but the sound stops and plays irregularly and doesn't sound as good as the old engine.


    So If I use the old sound engine I can't use 3D sounds, and If I use the new one the automatic weapons sound strange.


    Are there any ways to make the automatic weapon's sound good in the new sound engine, or implement 3D sounds with the old engine ?
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,468
    I've never done this stop/start method of sounds so I'm just guessing here at something you may want to try. Try storing the ID when you play a sound...

    snd_id=audio_play_sound(etc).

    And then when you stop the sound, stop snd_id instead of sound_gunsound
     
  3. hijong park

    hijong park Member

    Joined:
    Dec 29, 2016
    Posts:
    131
    audio_stop_sound(snd) snd = audio_play_sound(sound_gunsound,0,false)

    I tried this, But It has no difference.
     
  4. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,698
    Instead of repeating the sound mechanically, let the sound repeat on its own with looping enabled and use flags to control the starting call.

    Assume that the Boolean expression for whether it is shooting is firing. Then use a was-is flag to stop the sound on the true-false transition and enable the looping sound on the false-true transition.

    Create:
    Code:
    was_firing = false;
    sinst_gunsound = -1;
    Step:
    Code:
    if (was_firing ^^ firing) {
      if (was_firing) {
        audio_stop_sound(sinst_gunsound);
      } else {
        sinst_gunsound = audio_play_sound(sound_gunsound, 0, true);
      }
      was_firing = !was_firing;
    }
    
     

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