Legacy GM Problems with Old / New sound engine

hijong park

Member
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 ?
 

obscene

Member
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
 

hijong park

Member
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
audio_stop_sound(snd) snd = audio_play_sound(sound_gunsound,0,false)

I tried this, But It has no difference.
 

FrostyCat

Redemption Seeker
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;
}
 
Top