GameMaker: Studio

GameMaker: Studio

View Stats:
Hijong park Mar 11, 2019 @ 7:46am
Problem with old / new sound engine
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:



sound_stop(sound_gunsound); sound_play(sound_gunsound);



The purpose of it is to prohibit 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:



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.

Although It basically works, 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 ?
Last edited by Hijong park; Mar 11, 2019 @ 7:46am
< >
Showing 1-4 of 4 comments
Zappy Mar 11, 2019 @ 7:57am 
As far as I'm aware, sound-(/audio-)playing functions return the played sound "instance" (no, not object-related "instances"), which you can then stuff into sound-(/audio-)stopping functions.

You may want to try storing the sound-playing function's returned value in a variable, then stopping the sound of that variable rather than the sound resource. It's possible that the issue you're having relates to stopping the sound resource rather than just the latest instance of it.

(By doing this, you will also allow multiple object instances to have their own "copy" of the sound playing, rather than having each instance stop each other's gunshot sound. This may also be an important change when using distance falloff and such with sounds from multiple object instances.)
Last edited by Zappy; Mar 11, 2019 @ 7:58am
Hijong park Mar 12, 2019 @ 6:07am 
Originally posted by Zappy:
As far as I'm aware, sound-(/audio-)playing functions return the played sound "instance" (no, not object-related "instances"), which you can then stuff into sound-(/audio-)stopping functions.

You may want to try storing the sound-playing function's returned value in a variable, then stopping the sound of that variable rather than the sound resource. It's possible that the issue you're having relates to stopping the sound resource rather than just the latest instance of it.

(By doing this, you will also allow multiple object instances to have their own "copy" of the sound playing, rather than having each instance stop each other's gunshot sound. This may also be an important change when using distance falloff and such with sounds from multiple object instances.)

audio_stop_sound(snd) snd = audio_play_sound(sound_gunsound,0,false)

I tried this, but it has no difference.
Last edited by Hijong park; Mar 12, 2019 @ 6:07am
Zappy Mar 12, 2019 @ 6:23am 
Originally posted by Hijong park:
audio_stop_sound(snd) snd = audio_play_sound(sound_gunsound,0,false)
I tried this, but it has no difference.
What happens if you do something like ... instead?
audio_sound_gain(snd,0,50); //Make the previous gunshot sound fade out in 0.05 seconds snd=audio_play_sound(sound_gunsound,0,false); //Then play a new gunshot sound (while the previous one will still be audible for 0.05 seconds)
(Feel free to play around with the "50" number. It probably shouldn't be more than 200 (0.2 seconds), but any less than that is up to your own opinion, I think.)
Hijong park Mar 12, 2019 @ 6:37am 
Originally posted by Zappy:
Originally posted by Hijong park:
audio_stop_sound(snd) snd = audio_play_sound(sound_gunsound,0,false)
I tried this, but it has no difference.
What happens if you do something like ... instead?
audio_sound_gain(snd,0,50); //Make the previous gunshot sound fade out in 0.05 seconds snd=audio_play_sound(sound_gunsound,0,false); //Then play a new gunshot sound (while the previous one will still be audible for 0.05 seconds)
(Feel free to play around with the "50" number. It probably shouldn't be more than 200 (0.2 seconds), but any less than that is up to your own opinion, I think.)

It works ! so, the solution was muting the sound, instead of stopping it. Thank you.
< >
Showing 1-4 of 4 comments
Per page: 1530 50

Date Posted: Mar 11, 2019 @ 7:46am
Posts: 4