XAudio2 voices can perform automatic sample rate conversions if their input sample rate is different from the input sample rate of their output voices.
如果XAudio2 voices的输入采样率和它们输出向的voices的输入采样率不一致的话,它们会自动进行采样率转换。
Sample rate conversions follow these rules:
采样率转换遵循以下规则:
Voice input sample rate is fixed.
Voices can only handle the input sample rate specified when they were created. For mastering voices and submix voices, the input sample rate is specified with the InputSampleRate argument to the IXAudio2::CreateMasteringVoice and IXAudio2::CreateSubmixVoice functions. For source voices, the input sample rate of the voice is specified by the pSourceFormat argument to the IXAudio2::CreateSourceVoice function.
voices只能处理在创建它们的时候指定给它们的输入采样率。对于mastering voices和submix voices,输入采样率是通过IXAudio2:CreateMasteringVoice和IXAudio2:CreateSubmixVoice函数中的InputSampleRate参数来指定的。对于source voices,voice的输入采样率是通过IXAudio2:CreateSourceVoice函数中的pSourceFormat参数来指定的。
All of a voice's output voices must have the same input sample rate.
Voices can convert from their input sample rate to any output sample rate, but all of the voice's output voices must have the same input sample rate. For example, a voice could output to any number of voices with an input sample rate of 22 kHz. However, if that same voice had several output voices, each of which had a different input sample rate, the audio graph would not be valid.
voices可以把它们的输入采样率转为任何输出采样率,但是一个voice的所有输出voices必须具有相同的输入采样率。例如,一个voice可以输出到任意多个具有22kHz输入采样率的voices。但是,如果同一个voice具有几个输出的voices,每个voice都有一个不同的输入采样率,那么音频图是无效的。
Sample rate conversion processing only occurs when necessary.
Converting audio data to a different sample rate incurs more processing overhead, which it is preferable to avoid. If a voice's input sample rate matches the input sample rate of its output voices, this conversion is not done and processing time is shortened.
将音频数据转为一个不同的采样率会引起上层做更多的处理,那么这种情况最好能避免。如果一个voice的输入采样率和它的输出voices的输入采样率相匹配,不会进行转换并且处理时间变短。
Output sample rate can vary over the life of a voice.
The output sample rate of a voice is not fixed. As long as all of its output voices have the same input sample rate, the audio graph will be valid. If a voice is changed to output to new voices with a different input sample rate, the voice will convert to the input sample rate of the new voices.
一个voice的输出采样率不是固定的。只要它的所有输出voices具有相同的输入采样率,那么音频图都是有效的。如果一个voice改变输出到采样率不同的new voices,那么它会改变为new voices的输入采样率。
There are some scenarios in which it is necessary to add a submix voice to perform sample rate conversion between voices. If a voice needs to output to voices with various input sample rates, only one of the voices can be a direct output of the original voice. Because all of a voice's output voices must have the same input sample rate, the other voices receive output indirectly. There must be a submix voice with the correct input sample rate that comes between the original voice and the intended output voice.For example, consider a source voice with an input sample rate of 22 kHz, which needs to output to a submix voice with an input sample rate of 11 kHz and a mastering voice with an input sample rate of 44.1 kHz. Because the two output voices have different input sample rates, you need to insert more submix voices between the original voice and its intended output voices. To maintain the fidelity of the source voice and avoid unnecessary expensive conversions to higher sample rates, you need to insert two submix voices with 22 khz sample input rates into the graph. One submix voice would output at 11 khz to the submix voice with the reverb effect, and the other submix voice would output to the mastering voice at 44.1 khz.
例如,假如一个source voice的输入采样率是22kHz,它需要输出到一个输入采样率是11kHz的submix voice和一个输入采样率是44.1kHz的mastering voice。因为两个输出voices具有不同的输入采样率,那么你就需要在原始voice和目的输出voices之间插入多个submix voices。为了保证source voice的不失真同时避免转为高采样率的不必要开销,你需要插入两个具有22kHz输入采样率的submix voices到音频图中。一个submix voice会以11kHz的采样率输出到submix voice并伴有混响,另一个submix voice会以44.1kHz输出到mastering voice。
All voices have the same sample input rate; no sample rate conversion is done in the audio graph.
所有voices具有相同的输入采样率;整个音频图中没有采样率转换发生。
All voices have the same sample input rate except the mastering voice; sample rate conversion is only performed on data going to the mastering voice.
除了mastering voice以外,所有voices都具有相同的输入采样率;采样率转换只发生在音频数据流向mastering voice的时候。
Voices have different sample input rates and require more submix voices to perform sample rate conversions; sample rate conversion is performed in multiple places in the audio graph.
voices具有不同的输入采样率,就需要更多的submix voices来进行采样率转换;采样率转换在音频图的多个地方发生。