SoundPitch vs. Pitch

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

SoundPitch vs. Pitch

Post by Barbie »

The sound pitch value of 64, taken from default value of Actor.uc, did not work as I expected if used in Actor.PlaySound(Sound, Slot, Volume, bNoOverride, Radius, Pitch). Further tries have shown that PlaySounds parameter Pitch is a ratio with the normal of 1. Grater values (eg 1.5) speeds up the sound, lower values (eg 0.5) slows down the sound.
Because the default value of SoundPitch is 64, there must be some code that does Pitch = SoundPitch / 64, but I didn't find such in the UCScript of stock objects tree, so I guess it's in native code.

Before I immortalize my finding in UnrealWiki (it's again down atm) I would like to get some confirmation or falsification here.

Just for your reminder below you'll find the shortened stock code of Actor.uc. Also note the difference of variable types of SoundPitch and Pitch.
Spoiler

Code: Select all

//=============================================================================
// Actor: The base class of all actors.
// This is a built-in Unreal class and it shouldn't be modified.
//=============================================================================
class Actor extends Object abstract native nativereplication;

[...]

// Ambient sound.
var(Sound) byte         SoundRadius;	 // Radius of ambient sound.
var(Sound) byte         SoundVolume;	 // Volume of amient sound.
var(Sound) byte         SoundPitch;	     // Sound pitch shift, 64.0=none.

[...]

// Play a sound effect.
native(264) final function PlaySound
(
	sound				Sound,
	optional ESoundSlot Slot,
	optional float		Volume,
	optional bool		bNoOverride,
	optional float		Radius,
	optional float		Pitch
);

[...]

defaultproperties {
	SoundRadius=32
	SoundVolume=128
	SoundPitch=64
[...]
}
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: SoundPitch vs. Pitch

Post by JackGriffin »

This is probably the same thing as rotational. Some coder assigned arbitrary values instead of common sense ones. You could ask Smirf or Wormbo, those two would know a for-sure answer. The rest of us are educational-guessing just like you.
So long, and thanks for all the fish
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: SoundPitch vs. Pitch

Post by Wormbo »

Seriously I have no idea why the types are so inconsistent. PlaySound parameters are definitely not at the same scale as those byte properties, as you may already see from the default value TransientSoundVolume=1.000000, which is the default value for PlaySound if you omit the volume. When omitting the pitch parameter, it defaults to 1.0, while the SoundPitch property is scaled by 64, i.e. 64 = normal pitch, 128 = one octave up, 32 = one octave down. UT2004 seems to limit the SoundPitch to that one octave up/down range for actor ambient sounds. Not sure about other sounds, though.
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: SoundPitch vs. Pitch

Post by Barbie »

Meanwhile I've found PlaySound Description on oldunreal.com that confirms my guess on Pitch; Volume is also a ratio with the normal of 1. Now I have to find out if at least Radius is the same scale as SoundRadius.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: SoundPitch vs. Pitch

Post by JackGriffin »

Just be cautious when you reference the absolutes in Unreal versus U227 versus UT. Smirf is continually making very profound changes in how things are done and in many cases it changes the reference data points.
So long, and thanks for all the fish
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: SoundPitch vs. Pitch

Post by Barbie »

Barbie wrote:Now I have to find out if at least Radius is the same scale as SoundRadius.
I've been thrown back to this and found that the following applies:

Code: Select all

// this is the definition like in Actor.uc for Ambient sound:
var(MySound) sound MySound;
var(MySound) byte MySoundVolume;
var(MySound) byte MySoundRadius;
var(MySound) byte MySoundPitch;
var(MySlot) ESoundSlot MySoundSlot;
var(MySlot) bool bMySoundNoOverride;

...
// to play *MySound* with Actor.PlaySound() adjust as follows:
PlaySound(MySound, MySoundSlot, MySoundVolume / 128, bMySoundNoOverride, MySoundRadius * 25, MySoundPitch / 64);
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
rjmno1
Masterful
Posts: 716
Joined: Fri Aug 12, 2011 9:38 pm
Personal rank: masterfull
Location: https://sites.google.com/view/unrealtou ... oject/home
Contact:

Re: SoundPitch vs. Pitch

Post by rjmno1 »

JackGriffin wrote:This is probably the same thing as rotational. Some coder assigned arbitrary values instead of common sense ones. You could ask Smirf or Wormbo, those two would know a for-sure answer. The rest of us are educational-guessing just like you.
Indeed the soundpitch is in this case the sound radius, moving just like a cirkel.
You can also pitch only on the left side or on the right side.
You can also pitch using both channel (left and right), to make a more bigger soundpitch.
I did in the past a small experience for myself ,and you can realy did hear the pitch making cirkels.
Was a little fun for todo, i didn't knew you can make a pitch in ut also.
Where i was working on was a mp3 file converted to wav for bether sound quality.
i canot remember wich program i did use back in those day,s.

much greetz :rjmno1
unreal tournament 99
®
Image
Image
ImageImage
https://sites.google.com/view/unrealtou ... oject/home mine home ut99 website.
https://richardmoust105.blogspot.com/20 ... ef-in.html dutch blog page about ut99 settings.
Post Reply