$PitchSet for SNDINFO

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8055
Joined: Sun Jan 28, 2007 3:55 pm

$PitchSet for SNDINFO

Post by Major Cooke »

Pull Request

Sets the specific pitch for the direct logical sound. This only works for actual sound definitions.

One thing I found myself in need of recently is the ability to replace sounds, but they have different pitch elements which means A_StartSound will also need to be changed on the mod's side in order to reflect the update. AKA I'd have to replace the actor if I wanted to modify the sound's played pitch. And I'd rather not set up an elaborate system in ZScript as well that would act as a randomizer when this can suffice perfectly.

PitchSet overrides PitchShiftRange if the value > 0.0, and overridden by A_StartSound if the pitch parameter is > 0.0.

Example:

Code: Select all

Explo1	dsbarexp
Explo2	dsbarexp
Explo3	dsbarexp
Explo4	dsbarexp

$pitchset Explo1 1.25
$pitchset Explo2 1.5
$pitchset Explo3 0.75
$pitchset Explo4 0.5

$random Explo { Explo1 Explo2 Explo3 Explo4 }
When you enter 'playsound explo' in console, it'll randomize between the four different pitch-set explosion sounds and play them at their defined pitch settings.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 47968
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: $PitchSet for SNDINFO

Post by Graf Zahl »

Normally I would have asked for a small demo but this looked simple enough to merge it as-is.
Yes, definitely a useful addition.
User avatar
Major Cooke
Posts: 8055
Joined: Sun Jan 28, 2007 3:55 pm

Re: $PitchSet for SNDINFO

Post by Major Cooke »

Awesome!

I had originally planned on a $pitchsetrange so people could reduce the amount of definitions if they wanted but I wasn't sure how good that would've worked out since it would involve a randomizer with a float, and I'm not quite certain how to deal with that on the C++ side.
User avatar
Matt
Posts: 9664
Joined: Sun Jan 04, 2004 5:37 pm
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: $PitchSet for SNDINFO

Post by Matt »

If someone loaded something like the OP example, but also another SNDINFO after that that replaced Explo4 with another sound but didn't specify the pitch, that new sound will play at its original pitch, right?
User avatar
Major Cooke
Posts: 8055
Joined: Sun Jan 28, 2007 3:55 pm

Re: $PitchSet for SNDINFO

Post by Major Cooke »

It follows the same rules as volume/pitch shift/limits.

If they reset when the sound is redefined, then so will PitchSet. If they don't, then it won't.

And I'd rather not change it from how it currently is because too many mods are reliant on their behavior.

$alias for certain will not adhere to anything but the original definition because that's all it is - a renaming, so it will use the original definitions volume/limits/pitch no matter what.

Return to “Closed Feature Suggestions”