DirectSound and DirectMusic are separate components of DirectX with some overlapping functionality. Both play WAV sounds, and DirectMusic ultimately synthesizes all sounds into waveforms that are played through DirectSound buffers.DirectSound和DirectMusic是DirectX的两个独立组件,但是功能尚有部分重叠。二者都可以播放WAV文件,DirectMusic最终还是合成所有的声音,并通过DirectSound的缓冲区播放出来。
DirectMusic is a much more full-featured API that offers a complete solution for most audio scenarios in games and other interactive applications. Despite its name, DirectMusic plays all kinds of sounds including nonmusical sound effects. DirectSound is the API of choice for scenarios that require low-level management of hardware resources, such as games with many short sounds that must be played with the lowest possible latency and use of system resources. 在大部分的声音场合,DirectMusic提供完整的解决方案,但他并不仅仅是一个全功能的API。 不考虑它的名字,DirectMusic可以播放所有格式的声音,包括非音乐的声音效果。 当你需要对硬件资源进行底层控制,DirectSound是可供选择的另外一个API,比如说①游戏中包含了大量的短的声音、并且不需要频繁播放,②使用系统资源。
You can use the DirectSound API independently to play WAV sounds, even in applications that use DirectMusic to play other content. You can also use DirectSound to manipulate sound buffers that are managed by DirectMusic. For example, you can obtain a DirectSound buffer from a DirectMusic audiopath and move it in 3-D space.
The following table summarizes the functionality offered by the two APIs.
功能 | DirectMusic | DirectSound |
播放WAV文件 | Yes | Yes |
播放MIDI | Yes | No |
Play DirectMusic Producer segments | Yes | No |
Load content files and manage objects | Yes | No, but some support in sample code |
Control musical parameters at run time | Yes | No |
Manage timeline for cuing sounds | Yes | No |
Use downloadable sounds (DLS) | Yes | No |
Set volume, pitch, and pan of individual sounds | Yes, through DirectSound API | Yes |
Set volume on multiple sounds (audiopaths) | Yes | No |
Implement 3-D sounds | Yes, through DirectSound API | Yes |
Apply effects (DMOs) | Yes, through DirectMusic Producer content or DirectSound API | Yes |
Chain buffers for mix-in (send) effects | Yes, through DirectMusic Producer content | No |
Capture WAV sounds | No | Yes |
Implement full duplex | No | Yes |
Capture MIDI | Yes | No |
Control allocation of hardware buffers | No | Yes |