Training
Module
Activate spatial audio for your HoloLens 2 application - Training
Activate spatial audio for your HoloLens 2 application
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This topic describes XAudio2 volume and pitch control.
Volume levels are expressed as floating-point amplitude multipliers between -XAUDIO2_MAX_VOLUME_LEVEL and XAUDIO2_MAX_VOLUME_LEVEL (-224 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. Two inline functions are provided in XAudio2.h to convert between volume units: XAudio2DecibelsToAmplitudeRatio and XAudio2AmplitudeRatioToDecibels.
You can apply a volume level to the audio at several points as it flows through the XAudio2 graph:
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 the XAudio2 Default Channel Mapping overview for details.
Note
XAudio2 automatically adjusts volume levels based on the user's speaker settings to maintain a consistent volume level across configurations. If the user's settings don't match their physical configuration the volume will either be too loud or too soft compared to a system with accurate settings. For example, a system configured for 5.1 surround sound speakers that only has two speakers connected will sound too soft. XAudio2 is unable to detect whether the user speaker settings correctly match their physical setup.
Pitches are 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 10 octaves, while a ratio of 1,024/1 raises it by 10 octaves. You can only use the IXAudio2SourceVoice::SetFrequencyRatio method to apply pitch adjustments to source voices, and only if they were not created with the XAUDIO2_VOICE_NOPITCH flag. The default frequency ratio is 1/1: that is, no pitch change. Two inline functions are provided in XAudio2.h to convert between frequency ratios and semitones: XAudio2FrequencyRatioToSemitones and XAudio2SemitonesToFrequencyRatio.
Training
Module
Activate spatial audio for your HoloLens 2 application - Training
Activate spatial audio for your HoloLens 2 application