This topic describes XAudio2 volume and pitch control.
Volume Control
volume levels is expressed as floating-point amplitude multipliers between-xaudio2_max_volume_ Level and Xaudio2_max_volume_level ( -2 24 To 224), with a maximum gain of 144.5 DB. A volume of 1.0 means there is no attenuation or gain; 0 means silence; and negative levels can be used to invert the audio ' s phase. Both inline functions is provided in XAudio2.h to convert between volume units: Xaudio2decibels Toamplituderatio and Xaudioamplituderatiotodecibels
The volume level is expressed as a floating-point amplitude multiplier factor, between-xaudio2_max_volume_level (-2 of 24) and Xaudio2_max_volume_level (2 of 24). The maximum gain is 144.5dB. A volume of 1.0 indicates no attenuation or gain, 0 is mute, and a negative volume indicates the phase of the reversal volume.
You can apply a volume level to the audio at several points as it flows through the XAudio2 graph:
You can apply volume levels in several places when the audio is flowing in the XAudio2 streaming diagram:
- All voice types apply a overall volume level to their input, which they control using the ixaudio2voice::setvolumemethod. In Submix and mastering voices, the overall volume level is applied just before the voice ' s built-in filter and effect cha In. In source voices, the overall volume level was applied after the Voice ' s built-in filter and effect chain.
- All types of voice apply a whole volume level to the input, using the Ixaudio2voice::setvolume method to control. In the Submix and mastering voices, the overall volume level is applied before the voice's built-in filter and effect chain. In source voices, the overall volume level is applied after the voice's built-in filter and effect chain.
- Voices apply a Per-channel volume level to their output, which they control using theixaudio2voice::setchannelvolumes< /c3> method. The Per-channel volume level was applied just after the Voice's final sample rate conversion, and before it was sent to Othe R voices.
- The voices applies a single-channel volume level to the output, using Ixaudio2voice::setchannelvolumes to control. The single-channel volume level is applied after the final sample rate conversion of the voice and before being transported to other voices.
- Every connection between one voice and another have a table of levels used to send audio from each source channel to each T Arget Channel, which is controlled using the Ixaudio2voice::setoutputmatrix method.
- Each connection between voice and other voice has a level meter that is used to send audio data from one source channel to each destination channel, using Ixaudio2voice::setoutputmatrix to control.
All overall volumes and channel volumes default to 1.0 initially. All send-level matrices default to appropriate values that preserve signal power and channel positioning as accurately as Possible. See theXAudio2 Default Channel Mappingoverview for details.all overall volume and channel volume defaults to 1.0 at initialization time. All conveying volume matrices implicitly consider the appropriate values to maintain the signal strength and channel positioning as accurately as possible. Please refer to XAudio2 Default Channel mapping for details.
NoteXAudio2 automatically adjusts volume levels based on the user's speaker settings to maintain a consistent volume level ACR OSS configurations. If the user's settings don ' t match their physical configuration the volume would either be too loud or too soft compared to A system with accurate settings. For example, the a system configured for 5.1 surround the sound speakers this only have a speakers connected would sound too soft. XAudio2 is unable to detect whether the user speaker settings correctly match their physical setup.The XAudio2 adjusts the volume level automatically based on the user's speaker settings to maintain consistent volume throughout the configuration. If the user's settings and physical configuration do not match, then the volume and system accurate configuration is either too loud or too soft. For example, the system is configured with a 5.1 surround sound speaker, but only two speakers are connected, and it sounds soft. XAudio2 cannot detect whether the user's speaker settings can correctly match their physical settings. Pitch Control
Pitch is expressed as input rate/output rate ratios between 1/1,024 and 1,024/1, inclusive. A ratio of 1/1,024 lowers pitch by ten octaves, while a ratio for 1,024/1 raises it by octaves. You can only use the ixaudio2sourcevoice::setfrequencyratio method to apply pitch Adjustments to source voices, and only if they were no created with the Xaudio2_voice_nopitch flag. The default frequency ratio is 1/1: That's, no pitch change. Both inline functions is provided in XAudio2.h to convert between frequency ratios and semitones: xaudio2freq Uencyratiotosemitones and xaudio2semitonestofrequencyratio .
The pitch is expressed as the ratio of the input rate to the output rate, between 1/1,024 and 1,024/1, including both ends (closed interval). A 1/1,024 ratio reduces the pitch of 10 eight-degree syllables, while a 1,024/1 ratio increases the pitch of 10 eight-degree syllables. You can only use the Ixaudio2sourcevoice::setfrequencyratio method to apply tonal adjustments to source voices, and only if they are not using the xaudio2_voice_nopitch flag to can be created. The default frequency ratio is 1/1, which indicates that there is no tonal change. Two inline functions are provided in the XAudio2.h header file to convert each other between the frequency ratio and the chromatic path: Xaudio2frequencyratiotosemitones and Xaudio2semitonestofrequencyratio.
XAudio2 volume and tone control