XAudio2音频特效

来源:互联网 发布:淘宝活动日期 编辑:程序博客网 时间:2024/04/28 04:34

An audio effect is an object that takes incoming audio data, and performs some operation on the data before passing it on. You can use an effect to perform a variety of tasks, including adding reverb to an audio stream and monitoring peak volume levels.

一个音频特效是这样一个对象,它获取输入的音频数据,在将数据继续传下去之前会在数据上做一些操作。一个音效可以用来执行各种不同的任务,包括向音频流添加混响以及监视音量的峰值。

Effect Chains

Any XAudio2 voice can host a chain of audio effects. You can use an array of XAUDIO2_EFFECT_DESCRIPTOR structures to specify effect chains. Each descriptor contains a pointer to an effect object provided by the client. These objects must implement the Audio Processing Object (APO) interfaces. See the XAPO Overview for more information about the APO model.

任何XAudio2 voice都可以持有一个音频效果链。你可以使用XAUDIO2_EFFECT_DESCRIPTOR数组来指定效果链。每个描述因子都包含了由客户端提供的指向音效对象的指针。这些对象必须实现APO接口。参见XAPO Overview以获取关于APO模型的更多信息。

Effect chains can be modified by the client dynamically (while the XAudio2 engine is running), effects can be enabled or disabled individually, and effect parameters can be changed—all without any interruption of the audio. Whenever any aspect of the effect graph changes, XAudio2 optimizes the graph again to avoid unnecessary processing. See IXAudio2Voice::SetEffectChain,IXAudio2Voice::EnableEffect, and IXAudio2Voice::SetEffectParameters.

效果链可以动态地被客户端修改(当XAudio2引擎在运行的时候),特效可以独立地启用和禁用,并且特效参数可以改变--这一切都不会对音频有任何影响。无论什么时候,特效图的任何部分发生改变,XAudio2会再次优化特效图来避免不必要的处理。参考:IXAudio2Voice::SetEffectChain,IXAudio2Voice::EnableEffect和IXAudio2Voice::SetEffectParameters.

After an effect is attached to an XAudio2 voice, XAudio2 takes control of the effect, and the client should not make any further calls to it. The simplest way to ensure this is to release all pointers to the effect.

在把特效附加到XAudio2 voice上,XAudio2会接管此特效,并且客户端不应该对它再做任何进一步的调用。保证这样的最简单的方式就是释放所有指向特效的指针。

The effects in a given XAudio2 voice's effect chain must consume and produce floating-point audio at that voice's processing sample rate. The only aspect of the audio format they can change is the channel count (for example, a reverb effect can convert mono data to 5.1). The client can use the XAUDIO2_EFFECT_DESCRIPTOR.OutputChannels field to specify the number of channels that each effect should produce. The effect chain fails if any of the effects cannot fulfill these requirements, or if an effect produces a number of channels that the next effect cannot handle. Any IXAudio2Voice::EnableEffect or IXAudio2Voice::DisableEffect calls that cause the effect chain to stop fulfilling these requirements will fail.

一个给定的XAUdio2 voice效果链的特效必须以那个voice的处理采样率消费和生产浮点音频数据。音频格式中它们可以改变的唯一部分就是声道数(例如,一个混响特效可以将单声道数据转为5.1通道数据)。客户端可以使用XAUDIO2_EFFECT_DESCRIPTOR.OutputChannels 部分来指定每个特效应该产生的音频通道数。如果任何特效不能完成这些需求的话那么效果链就会失效,或者一个特效产生的通道数下一个效果不能处理。任何 IXAudio2Voice::EnableEffect or IXAudio2Voice::DisableEffect会导致效果链停止完成这些需求的调用都会失败。

APO interfaces used in XAudio2 must be destructive. This means they always overwrite any data they find in their output buffers. Otherwise, the resulting audio might be incorrect because XAudio2 makes no guarantee that these buffers have been initialized previously with silence.

使用在XAudio2的APO接口必须具有可销毁性。这表示它们会一直重写它们在自己的输出缓冲区发现的任何数据。否则,计算得到的音频可能会不正确,因为XAudio2没有保证这些缓冲区先前初始化时是没有声音的。

XAudio2 Built-in Effects

The following table lists the set of built-in audio effects provided by XAudio2 and their creation methods.

下面的表格列举了XAudio2提供的内置音频效果的集合以及他们的创建方法。

EffectCreation MethodReverbXAudio2CreateReverbVolume MeterXAudio2CreateVolumeMeter

For an example of creating and using an instance of an audio effect, see How to: Create an Effect Chain.

创建和使用音频效果的实例请参见How to: Create an Effect Chain.

Custom Effects in XAudio2

The XAPO API provides a framework for creating custom audio effects that you can use in XAudio2. For an example of creating a custom effect with XAPO, see How to: Create an XAPO.


XAPO Effect Library (XAPOFX)

XAPOFX provides an additional library of XAPOs and common mechanism for creating them. For an example of using XAPOFX with XAudio2, see How to: Use XAPOFX in XAudio2.

XAPOFX提供了一个XAPOs的额外的库,并且提供了创建它们的通用机制。使用XAPOFX和XAudio2的示例请参考How to: Use XAPOFX in XAudio2。

2 0