How the Check Works
The CheckAudioClipping
is designed to identify audio files in your project that may have samples above a certain clipping threshold. Clipping occurs when audio samples exceed the maximum limit, resulting in distorted sound when played.
The check operates at both the GameObject and AudioClip levels:
- GameObject Level: When invoked on a GameObject, it examines all
AudioSource
components attached to the GameObject. For eachAudioSource
, it checks the associated audio clip for clipping. - AudioClip Level: When invoked on an
AudioClip
, it analyzes the audio clip’s samples directly, checking for any samples above the defined clipping threshold.
The check performs the following steps:
- Sample Analysis: It retrieves the audio clip’s samples and iterates through them. For each sample, it checks if its absolute value exceeds the specified clipping threshold.
- Issue Reporting: If the check identifies samples that may cause clipping, it logs an issue with a description indicating the problem and references either the GameObject or AudioClip.
When to Use This Check
- Audio Quality Assurance: To ensure that audio assets in your project do not contain samples that may cause clipping when played.
- Prevent Distorted Audio: Prevent audio distortion and maintain high-quality sound by identifying and addressing potential clipping issues.
How to Use the Check
- Configuration: You can customize the clipping threshold by adjusting the
m_ClippingThreshold
attribute. This value represents the maximum allowed absolute sample value before clipping is detected. - Perform Check: Perform the Check via the Verification Window
Methods
PerformCheck(GameObject gameObject)
: Initiates the verification process for a specific GameObject. It checks allAudioSource
components attached to the GameObject for audio clipping issues.PerformCheck(AudioClip audioClip)
: Initiates the verification process for a specific AudioClip. It analyzes the audio clip’s samples directly for clipping issues.
Attributes
longDescription
: Provides a description of what this check does, explaining its purpose in identifying potential audio clipping issues within your project.