Why is audio pitch clamped between 0.4 and 2.0?

Hello,

In Engine\Source\Runtime\Engine\Public\Audio.h, the following are defined:

#define MIN_PITCH						0.4f
#define MAX_PITCH						2.0f

On windows, this is used to clamp the value passed into IXAudio2SourceVoice::SetFrequencyRatio. However, according to the documentation of that function (msdn), valid values are between 1/1,024 and 1,024/1, inclusive. Why are these particular min and max values hardcoded into the engine? Could they please at least be configurable via ini file?

Thanks,

Any chance of getting an answer to this?

I would like to know too…
If we change it and recompile?
Anyone tried that?

I do not know the reason the pitch is clamped in the ranges that it is. I suspect it was a decision made back in UDK days and likely before the audio engine used XAudio2. There’s nothing preventing you from changing the clamped values to something else. I can add it to my backlog of features to add support for setting global parameters like that in the audio project settings. Along with max voice counts, we can add min and max values to volume scaling, global headroom, etc.

Note that for game audio there are some potential downsides to unlimited (or extreme) pitch scaling. Destructive audio compression (e.g. ogg-vorbis) can sound very bad with extreme pitch shifting as frequencies that are normally not easily heard can be discarded, then with pitching, those artifacts can become audible. Also, for sounds which are real-time decompressed, extreme pitching up can cause buffer underruns due the fact that queued buffers are skipped so fast that it requires newly decoded buffers faster than the async decoder can feed to the voice.

Thanks for the answer, Minus_Kelvin! It would be much appreciated if you could add that to your backlog as you suggested.

The only thing preventing me from making these changes myself is that after our experience on a previous AAA project, my team has a very strict No Engine Changes policy in effect :slight_smile:

Thanks,

I changed the value to 0.01 and 4
Works great.
Need to recompile the engine, but all good!

can we somehow track this issue?)

I’m not certain exactly how the SetPitchMultiplier and SetGlobalPitchModulation blueprint nodes relate to IXAudio2SourceVoice::SetFrequencyRatio, but, when using those 2 blueprint nodes there is no hard limit to the pitch multiplier. However, they only give good results between 0.4 and 2.0 (e.g. a pitch multiplier input of 0.4 results in a pitch that is actually 0.4 times lower, but a pitch multiplier input of 0.001 only results in a pitch that is actually 0.38 times lower).

You just can’t.
The ONLY way to do this (I have been doing it since my previous post here +2 years ago) is to build your own engine from sources.

When you are at the VS part:
-look for the “file” audio.h
-look for Pitch.
-change the value: From 0.4 to 0.001
ZERO will crash the build.

Build your engine.
Voila.
You just wasted an hour and a half just to change a value. Welcome to my club!

No no, by a build I mean an Engine build, not your game/app build!
A build of UE4:
https://github.com/EpicGames/UnrealEngine

I see. I didn’t try it in a build, just in the editor.

Since 4.22 Pitch settings can be set in Project preference:

In the Audio section.
“Global Min/Max pitch scale”

Problem solved, no need to build the engine anymore to change those values!

2 Likes