Change Pitch
What it does: Sets the pitch of the given sound to random value between the given min -and max values and returns an AudioError (see Possible Errors), showing wheter and how chaging the pitch failed.
- DOES_NOT_EXIST
- MISSING_WRAPPER
- MISSING_SOURCE
- MISSING_CLIP
How to call it:
SoundNameis thenamewe have given the sound we want to playMinPitchis the minimum amount of pitch the sound can be set toMaxPitchis the maximum amount of pitch the sound can be set toChildis theChildTypethat we want to call this method on
string soundName = "SoundName";
float minPitch = 0.9f;
float maxPitch = 1.1f;
ChildType child = ChildType.PARENT;
AudioError err = am.ChangePitch(soundName, minPitch, maxPitch, child);
if (err != AudioError.OK) {
Debug.Log("Changing pitch for the sound called: " + soundName + " failed with error id: " + err);
}
else {
Debug.Log("Changing pitch for the sound called: " + soundName + " with the given minimum pitch being: " + minPitch.ToString("0.00") + " and the given maximum pitch being: " + maxPitch.ToString("0.00") + " succesfull");
}
Alternatively you can call the methods with less paramters as some of them have default arguments.
string soundName = "SoundName";
float minPitch = 0.9f;
float maxPitch = 1.1f;
AudioError err = am.ChangePitch(soundName, minPitch, maxPitch);
if (err != AudioError.OK) {
Debug.Log("Changing pitch for the sound called: " + soundName + " failed with error id: " + err);
}
else {
Debug.Log("Changing pitch for the sound called: " + soundName + " with the given minimum pitch being: " + minPitch.ToString("0.00") + " and the given maximum pitch being: " + maxPitch.ToString("0.00") + " succesfull");
}
When to use it: When you want to change the pitch to a random value so that a sound that is played often (footsteps, ui-hover, etc.) isn’t as repetitive.