XAudio2音量和音调控制
Posted GreenArrowMan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了XAudio2音量和音调控制相关的知识,希望对你有一定的参考价值。
This topic describes XAudio2 volume and pitch control.
Volume 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 XAudioAmplitudeRatioToDecibels.
音量电平表示为浮点振幅乘数因子,位于-XAUDIO2_MAX_VOLUME_LEVEL(-2的24次方)和XAUDIO2_MAX_VOLUME_LEVEL(2的24次方)之间,最大增益是144.5dB.音量为1.0表示没有衰减或者增益;0表示静音;负音量来表示反转音量的相位。
You can apply a volume level to the audio at several points as it flows through the XAudio2 graph:
音频在XAudio2数据流图中流动时你可以在几个地方施加音量电平:
- All voice types apply an 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 chain. In source voices, the overall volume level is applied after the voice‘s built-in filter and effect chain.
- 所有类型的voice施加一个整体音量电平到输入,使用IXAudio2Voice::SetVolume方法来控制。在submix和mastering voices中,整体音量电平应用在voice的内置过滤器和效果链之前。在source voices中,整体音量电平应用在voice的内置过滤器和效果链之后。
- Voices apply a per-channel volume level to their output, which they control using theIXAudio2Voice::SetChannelVolumes method. The per-channel volume level is applied just after the voice‘s final sample rate conversion, and before it is sent to other voices.
- voices应用一个单通道音量电平到输出,使用IXAudio2Voice::SetChannelVolumes来控制。单通道音量电平应用在voice的最终采样率转换之后,并且在输送到其他voices之前。
- Every connection between one voice and another has a table of levels used to send audio from each source channel to each target channel, which is controlled using the IXAudio2Voice::SetOutputMatrix method.
- voice和其他voice之间的每个连接都有一张电平表,用来发送音频数据从一个源通道到每一个目的通道,使用IXAudio2Voice::SetOutputMatrix来控制。
Pitch Control
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 theIXAudio2SourceVoice::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.
音调表示为输入率和输出率的比值,在1/1,024和1,024/1之间,包括两端(闭区间)。一个1/1,024的比例降低10个八度音节的音高,而一个1,024/1的比例提升了10个八度音节的音高。你只能用IXAudio2SourceVoice::SetFrequencyRatio方法来应用音调调节到source voices,并且只有当他们不是使用XAUDIO2_VOICE_NOPITCH标志来创建的才可以。默认的频率比是1/1,:表示的是,没有音调变化。在XAudio2.h头文件中提供了两个内联函数来进行频率比和半音程之间的相互转换:XAudio2FrequencyRatioToSemitones 和 XAudio2SemitonesToFrequencyRatio。
以上是关于XAudio2音量和音调控制的主要内容,如果未能解决你的问题,请参考以下文章