Question about PitchShift and how to get it for only a small subset of sounds

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
User avatar
Enjay
 
 
Posts: 27053
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Question about PitchShift and how to get it for only a small subset of sounds

Post by Enjay »

I'm unsure how this is supposed to work. Do sounds only get pitched randomly if snd_pitched is set to true? I was hoping that the answer would be no - that snd_pitched being false would set the default for the game but any sounds with a pitchrange value in SNDINFO would respect that instead of the overall game setting. However, that doesn't seem to be what happens. I basically want no pitch shifting in game except for a handful of sounds where it would be useful.

I tried enabling snd_pitched and then doing what I thought would disable sndpitching for most sounds (putting $pitchshiftrange 0 near the top of SNDINFO), but I'm getting some oddities.

I tried setting one sound to have a $pitchshift value of 7 in SNDINFO and, sure enough, its pitch varied wildly in game (too much in fact :lol: ).
With snd_pitched = false, there was no sound pitching.
I then set it to have a Pitchshift value of 0 and this too worked as expected - no pitch shifting, regardless of how snd_pitched was set in the ini.

I then (with snd_pitched set to true) tried $pitchshiftrange which, according to the Wiki, sets the pitch shifting for every sound definition that follows. And it works, some of the time, I think. However, even when I placed $pitchshiftrange 0 directly above the test sound, it was still pitch shifting, even though doing similar for other sound ranges elsewhere in the ini seemed to prevent them pitch shifting. So, I'm not sure where the interference is coming in, but I have simplified things down as much as I can and I still can't figure it out.

Ultimately, this is all kind of a side point to what I am trying to do. I have several sounds that get repeated in short succession (footsteps). I have a few different footstep sounds for each category of floor type but, even with that, it becomes obvious when the same sound is randomly picked a few times in a row. So, I thought pitchshifting might be able to help. However, it is only the footstep sounds that I want to pitchshift, and no others. I'd rather not have to go through my entire SNDINFO file and explicitly prevent every sound from pitchshifting except these ones.

So, is there a way to do it? I'm (mostly) using the built-in ZScript footstep capability.

Edit: I have solved my footsteps problem. I'm using a slightly modified version of the footsteps code anyway (to remove footsteps forcing a splash on terrains with defined splashes). So I just added in a tiny amount of randomness to the pitch parameter of the A_StartSound command in the footsteps code. It means that I have no control over which footsteps randomly pitch, (not without additional code) but I have set the value to be very small and it seems to suit most, maybe even all, footsteps just fine. More importantly, only the footsteps alter pitch randomly and nothing else does.

However, if anyone is able to shed any light on how all the pitchrange and snd_pitched stuff is supposed to interact, I'd still like to know. Thanks. :)
User avatar
Chris
Posts: 2971
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Question about PitchShift and how to get it for only a small subset of sounds

Post by Chris »

Don't know if this may be the issue or not, but by the looks of it, $pitchshiftrange <value> sets the current pitch shift range to be inherited by future sound definitions. However, sounds already defined are untouched, and it is possible to set the pitch shift range of a sound explicitly using $pitchshift <sound> <value>, overriding or replacing the inherited $pitchshiftrange value. The effects of $pitchshiftrange and $pitchshift are controlled by snd_pitched. There is also $pitchset <sound> <value> [maxvalue], with maxvalue being an optional parameter defining a randomized pitch range (the pitch ending up between value...maxvalue). The effect of $pitchset with a non-0 <value> both overrides $pitchshiftrange and $pitchshift, and occurs regardless of snd_pitched.
User avatar
Enjay
 
 
Posts: 27053
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Question about PitchShift and how to get it for only a small subset of sounds

Post by Enjay »

Thanks. Armed with that information, I'll have to take a closer look at my SNDINFO files. I think there will be instances where $pitchshiftrange is used, and then some subsequent sounds have an $pitchshift value, and then back to others that have $pitchshiftrange and so on. So, there are probably a few instances where things like that are mixed through each other and I it could be getting a bit conflicty in there. Pretty sure I have not used $pitchset anywaher. So, at least that won't be part of what's going on.
Thanks again. :)
Post Reply

Return to “Scripting”