![download directsound download directsound](https://vinever.weebly.com/uploads/1/2/5/0/125046444/815897925.jpg)
Use the method QueryInterface of IDirectSoundCaptureBuffer(pDSCB->QueryInterface()) to get a pointer(pDSCB8) to the interface IDirectSoundCaptureBuffer8.Use the method CreateCaptureBuffer() of IDirectSoundCapture8(pDSC8->CreateSoundBuffer()) to create and initialize an object and get the pointer (pDSCB) to IDirectSoundCaptureBuffer.Use DirectSoundCaptureCreate8() to create and initialize an object and get the pointer (pDSC8) to IDirectSoundCapture8.Capture waveform (including notification): Use the method Release() of IDirectSoundBuffer, IDirectSoundBuffer and IDirectSound8 to realease the objects (pDSCB8->Release(), pDsb->Release(), pDS8->Release()).ī.After finishing playing, use the method Stop() of IDirectSoundBuffer (pDSCB8->Stop()) to stop the playing.Use the method Play() of IDirectSoundBuffer (pDSCB8->Play()) to play the waveform.Use the method SetCurrentPosition() of IDirectSound8 (pDSCB8->SetCurrentPosition()) to set the current play position.Use the method SetCurrentPosition() of IDirectSoundBuffer (pDSCB8->SetCurrentPosition()) to set the current play position.Use the method Unlock() of IDirectSoundBuffer (pDSCB8->Unlock()) to unlock the buffer.
![download directsound download directsound](http://www.rastertek.com/pic0039.gif)
Use the pointer (lpvWrite) to write waveform to the buffer.Use the method Lock() of IDirectSound8 (pDSCB8->Lock()) to lock the buffer and get a pointer to it (lpvWrite).Use the method QueryInterface of IDirectSoundBuffer (pDsb->QueryInterface()) to get a pointer(pDSCB8) to the interface IDirectSoundBuffer8.Use the method CreateSoundBuffer() of IDirectSound8 (pDS8->CreateSoundBuffer()) to create and initialize an object and get the pointer (pDsb) to IDirectSoundBuffer.Use the method SetCooperativeLevel() of IDirectSound8 (pDS8->SetCooperativeLevel()) to set the cooperative level.Use DirectSoundCreate8() to create and initialize an object and get the pointer (pDS8) to IDirectSound8.Play waveform (for notification, please refer to the notification part of B): The following libraries should be added to the link list: Dsound.lib, dxguid.lib and Dxerr8.libĪ. Two header files from DirectX SDK should be included: To use COM the functions of CoInitializeEx() and ::CoUninitialize( ) need to be run at the beginning and end of the use of COM objects respectively. Two separate procedures listed for using DirectSound and DirectSoundCapture objects respectively to make the concepts clearer although the function of DirectSoundFullDuplexCreate8() can be used to create create both of the objects. The following is the procedures to use DirectSound to play waveform and capture waveform. The interface pointer can be used to get other interfaces of the same object through the method QueryInterface(). In most cases one function of DirectX creates an object and returns a pointer to an interface at the same time. Therefore to use a method two things have to be done first: 1. Usually programmers are only interested in some functions (that are called methods in COM) that will get the work done, but the functions (methods) belong to interfaces that belong to COM objects as shown in the following figure: Programmer need to clearly understand the concept (not the details) of COM to use DirectX that is set of COM objects. This article addresses the concepts of programming DirectSound and lays out a practical guideline for coding. However DirectSound is still needed to handle waveform data in sound buffers directly. Most applications using sound only need the current DirectMusic that can handle waveforms that used to be only handled by DirectSound. One component of DirectX 8.1 is DirectX Audio that merges former DirectMusic and DirectSound into one set of more unified API. The latest version of DirectX as of is DirectX 8.1. Microsoft DirectX is a set of low-level application programming interfaces (APIs) for creating games and other high-performance multimedia applications.