juhara.com

  • Narrow screen resolution
  • Wide screen resolution
  • Decrease font size
  • Default font size
  • Increase font size
Home Articles DirectX Programming DirectX Audio Programming
DirectX Audio Programming PDF Print E-mail
Written by Zamrony P. Juhara   
Friday, 06 November 2009 16:39
Article Index
DirectX Audio Programming
Creating Performance and Loader
Loading Audio File
Playing Sound
Playing many sounds at the same time
Stop Sound Playback
Close DirectX Audio
Application Demo
All Pages
(This article was first published on PC Media magazine edition 08/2007)

After quite enough playing with 3D graphics programming on Direct3D in previous articles, to avoid you get bored, I want to explore other interesting programming topic, i.e, sound programming with other DirectX component, DirectX Audio.

What I want to discuss with you this time is basic information about DirectX Audio including: DirectX Audio architecture, most frequent used terminologies and of course, the most interesting part, how to use DirectX Audio to play audio file.

Why DirectX Audio?

Windows had multimedia feature through Multimedia Control Interface (MCI), Wave API and MIDI API. For simple applications, MCI is capable to be used for playing WAV file or MIDI.

But, if you need to develop riched-feature sound recording application, such as Cakewalk's products, or game with impressive sound quality, MCI is not suitable.

DirectX Audio was presented by Microsoft for high performance audio application development on Windows platform. With DirectX Audio, you are able to do following things with ease:
  • Playback of WAV, MIDI or SGT file format.
  • Playback of two or more samples, simultaneously.
  • Changing pitch, tempo, reverb and applying sound effect.
  • Recording sound.
  • Playing 3D sound.

DirectX Audio Architecture

DirectX Audio consists of two components, i.e DirectSound and DirectMusic. DirectSound, which was created first, was designed for fast and efficient audio hardware access. DirectSound provides low-level mechanism for direct access to audio hardware. DirectMusic, which was created later after DirectSound, provides low-level programming interface for MIDI device, called DirectMusic Core and high level programming interface for loading and playback of music media, called DirectMusic Performance.

On DirectX 7, DirectMusic and DirectSound were two separated components (see Figure 1). MIDI and style-based music was loaded by DirectMusic Performance and then it was sent to DirectMusic Core which handled MIDI device and synthesizer directly. Sound in wave file format was loaded into memory and prepared by application and then sent to DirectSound which handle wave hardware.

DirectMusic and DirectSound Architecture on DirectX 7

Figure 1. DirectMusic and DirectSound architecture on DirectX 7 or lower.

After DirectMusic release, application developers prefered DirectMusic Performance to handle loading and music file playback. On DirectX 8, DirectMusic and DirectSound architecture was united, so DirectMusic Performance was used to handle loading and playback of MIDI and wave format. Unification of DirectMusic and DirectSound was called DirectX Audio (Figure 2). This architecture is not change in DirectX 9.
DirectMusic and DirectSound architecture in DirectX 8 and 9
Figure 2. DirectMusic and DirectSound architecture on DirectX 8 and 9.

In DirectX 8, Microsoft added new functionalities to Performance object, enabled it to load wave file and play wave format data stored in segment. Significant change to the architecture is the introduction of audiopath concept which separates DirectMusic Performance from DirectMusic Core. An audiopath is virtual audio channel which controls sound data flow. DirectMusic Performance manages one or more audiopath.

Performance

Performance is the work-horse of DirectX Audio. Performance is responsible for audio initialization, scheduling segments, creating and mapping audiopath to segment also controlling sound playback.

Loader

Loader was created to handle file input/output task and to load audio data from memory or resource. Loader simplifies programmer's task to load audio data.

Segment

Segment represents any playable audio data. It can be in form of MIDI file or wave file or DirectMusic Segment (default format of DirectMusic with SGT file extension). You can create one or more segments in an application. You are even allowed to play two or more segments simultaneously.

AudioPath

AudioPath is DirectMusic object responsible to manage route that must be taken by music instrument or sound effect. Each segment is played through an audiopath. Applications can have one or more audiopaths.



Last Updated on Friday, 13 November 2009 15:09
 

Language

IndonesianEnglish (United Kingdom)

Game Institute
DAZ3D

Is this article helpful? Help this site improve by donating. Any amount is appreciated.