[SOLVED] [ZS] Why do my minigun sounds sound ugly?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

[SOLVED] [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

My Chaingun with a "press altfire to spin the barrels to shoot faster" thing. Naturally, you'd expect the barrels to make some sounds. Mainly, a "start spinning sound", a "spinning" sound, and a "stop spinning" sound. The problem is my sound sounds terrible.
Spoiler: My Minigun
Last edited by yum13241 on Fri May 12, 2023 2:44 am, edited 1 time in total.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZS] Why do my minigun sounds sound ugly?

Post by Jarewill »

There isn't much we can do without access to your files and especially your sounds.
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

Open both spoilers. Then, you'll find them.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZS] Why do my minigun sounds sound ugly?

Post by Jarewill »

Please don't hide the file inside spoilers like that or put it at the very beginning of them, not at the end.

Regardless, changing the WindUp state to this seemed to have improved it:

Code: Select all

	WindUp:
		PKCG A 1 
		{
			A_StartSound("weapons/minigun_start", CHAN_WEAPON);
			A_MWSReady(WRF_NOFIRE); 
		} //1-frame buffer
		PKCG AAABBBCCCDDD 1
		{
			invoker.minigun = true;
			If(!IsActorPlayingSound(CHAN_WEAPON))
			{ //CHANF_NOSTOP included in CHANF_LOOPING only prevents stopping a sound if the sound is the same, otherwise it will replace it no matter what, so I used the above check in its place.
				A_StartSound("weapons/minigun_spin", CHAN_WEAPON, CHANF_LOOPING);
			}
			A_MWSReady();
			if(player.cmd.buttons & BT_ALTATTACK && !(player.oldbuttons & BT_ALTATTACK))
			{
				invoker.minigun = false;
				return ResolveState("MinigunDeactivate");
			}
			return ResolveState(null);
		}
		Goto WindUp+1; //Skip the first frame
		//The loop keyword here was breaking the above keyword, making the first state be executed regardless
There is still a cut between the start and spin sounds, but the only way to fix that will be to either make a dedicated StartSpinning state or cutting the sound file a bit in Audacity or similar program.

As for the stop sound not playing, the filename for it is actually called MingunStop.ogg and not MinigunStop.wav.
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

Please don't hide the file inside spoilers like that or put it at the very beginning of them, not at the end.
That was purely unintentional.
As for the stop sound not playing, the filename for it is actually called MingunStop.ogg and not MinigunStop.wav.
D'oh! I fixed that in SNDINFO (on my end obv), but I still can't hear the stop and start sounds. Either they aren't playing or I need to get my hearing checked.
Spoiler: new weapon code
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZS] Why do my minigun sounds sound ugly?

Post by Jarewill »

That's odd, it works fine on my end.
Try using the playsound console command to see if it works:
playsound weapons/minigun_start
playsound weapons/minigun_stop
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

playsound weapons/minigun_start works, but A_StartSound doesn't play it.
playsound weapons/minigun_stop doesn't work, neither does A_StartSound play it.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZS] Why do my minigun sounds sound ugly?

Post by Jarewill »

The only thing that comes to my mind is an issue with SNDINFO, so could you post your updated SNDINFO here?
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

SNDINFO:
weapons/usp "sounds/Weapons/Enforcer/usp.ogg"

weapons/chngun "sounds/Weapons/Enforcer/ENFCFIRE"

weapons/grenadebounce "sounds/Weapons/Grenades/grenadebounce.wav"
weapons/grenadedeploy "sounds/Weapons/Grenades/grenadedeploy.wav"
weapons/grenadeexplode "sounds/Weapons/Grenades/grenadeexplode.wav"

weapons/railshot "sounds/Weapons/Railgun/dsrail.ogg"
weapons/railpwron "sounds/Weapons/Railgun/railon.ogg"
weapons/railpwron2 "sounds/Weapons/Railgun/railchrge.ogg"

misc/flashlight "sounds/Misc./dsclick.ogg" // taken from Zagemod.

weapons/shotfire "sounds/Weapons/shotgun/shotfire.ogg"

weapons/minigun_start "sounds/Weapons/Minigun/MinigunStart.wav"
weapons/minigun_spin "sounds/Weapons/Minigun/MinigunSpin.wav"
weapons/minigun_stop "sounds/Weapons/Minigun/MinigunStop.ogg"
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZS] Why do my minigun sounds sound ugly?

Post by Jarewill »

The stop sound not working is due to a typo.
As I mentioned, the sound file is actually MingunStop.ogg, without the second i.
It's useful to copy-paste the sound names into SNDINFO to avoid such issues.

As for the start sound not working, frankly I have no idea.
Copying your updated code and running it myself still makes the sound play.

Edit: Try this.
Maybe I did another change I simply forgot that was essential in making this work.
But if this doesn't work, then I'm out of ideas.
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

As I mentioned, the sound file is actually MingunStop.ogg, without the second i.
I didn't see that :) I only saw the wrong extension lol.

EDIT: Your edited version makes the stop sound play, but I fixed that in my version by changing the sound file name.

The start sound never plays in either case.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by Player701 »

As for why the start sound is not playing, see here for details. I assume the issue was closed as "not a bug", as the current behavior hasn't changed since then.

upd: This might be a potential engine bug, as I can see IsActorPlayingSound is already used. It can be worked around by adding the sound name in there, e.g. if (!IsActorPlayingSound(CHAN_WEAPON, "weapons/minigun_start") { A_StartSound(...); }.

Investigating further now.

upd2: This has already been fixed in development builds, for GZDoom 4.10 and below please use the above workaround.
yum13241
Posts: 875
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support
Contact:

Re: [ZS] Why do my minigun sounds sound ugly?

Post by yum13241 »

Thanks, your solution worked!
Spoiler: MWSWeapon
Spoiler: Working Minigun
There's an annoying cut in the sounds, but I guess I'll have to live with it since I'm trash at sound editing lol.
Post Reply

Return to “Scripting”