Description
The Pitch
property of the BaseSoundComponent
class allows you to adjust the pitch of the sound being played. This property is a float
value that can be set within a specified range to modify the frequency of the sound, effectively making it sound higher or lower.
Usage
To use the Pitch
property, simply set it to a desired value between 0 and 2. A value of 1 represents the original pitch of the sound. Values less than 1 will lower the pitch, while values greater than 1 will raise it. The property is decorated with a RangeAttribute
to ensure the value stays within the valid range.
Example
// Example of setting the Pitch property
BaseSoundComponent soundComponent = new BaseSoundComponent();
soundComponent.Pitch = 1.5f; // Increases the pitch of the sound
// Ensure the pitch value is within the valid range
if (soundComponent.Pitch < 0 || soundComponent.Pitch > 2)
{
throw new ArgumentOutOfRangeException("Pitch must be between 0 and 2.");
}