The CSoundManager sample class contains functionality for creating and initializing DirectSound, accessing the primary buffer, and creating secondary buffers.
class CSoundManager { protected: LPDIRECTSOUND8 m_pDS; public: CSoundManager(); ~CSoundManager(); HRESULT Initialize( HWND hWnd, DWORD dwCoopLevel ); inline LPDIRECTSOUND8 GetDirectSound() { return m_pDS; } HRESULT SetPrimaryBufferFormat( DWORD dwPrimaryChannels, DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate ); HRESULT Get3DListenerInterface(LPDIRECTSOUND3DLISTENER* ppDSListener ); HRESULT Create( CSound** ppSound, LPTSTR strWaveFileName, DWORD dwCreationFlags = 0, GUID guid3DAlgorithm = GUID_NULL, DWORD dwNumBuffers = 1 ); HRESULT CreateFromMemory( CSound** ppSound, BYTE* pbData, ULONG ulDataSize, LPWAVEFORMATEX pwfx, DWORD dwCreationFlags = 0, GUID guid3DAlgorithm = GUID_NULL, DWORD dwNumBuffers = 1 ); HRESULT CreateStreaming( CStreamingSound** ppStreamingSound, LPTSTR strWaveFileName, DWORD dwCreationFlags, GUID guid3DAlgorithm, DWORD dwNotifyCount, DWORD dwNotifySize, HANDLE hNotifyEvent ); };
The constructor initializes a data member.
The class contains the following public methods, in alphabetical order.
Method | Description |
---|---|
Create | Creates a CSound object associated with a WAV file and containing the specified number of buffers. For information on possible values in the dwCreationFlags and guid3DAlgorithm parameters, see DSBUFFERDESC. |
CreateFromMemory | Creates a CSound object associated with a waveform in memory and containing the specified number of buffers. For information on possible values in the dwCreationFlags and guid3DAlgorithm parameters, see DSBUFFERDESC. |
CreateStreaming | Creates a CStreamingSound object associated with a WAV file and containing a single streaming buffer. The application specifies notification positions and an event. In response to notifications, the application calls CStreamingSound::HandleWaveStreamNotification to refresh the data in the buffer. For information on possible values in the dwCreationFlags and guid3DAlgorithm parameters, see DSBUFFERDESC. |
Get3DListenerInterface | Retrieves the IDirectSound3DListener8 interface. |
GetDirectSound | Retrieves the IDirectSound8 interface of the DirectSound object created by Initialize. |
Initialize | Creates the DirectSound object and sets the cooperative level. |
SetPrimaryBufferFormat | Sets the format of the primary buffer. This method should not be used by most applications. For more information, see Mixing Sounds. |
The class is implemented in (SDK root)\samples\C++\Common\DXUTsound.cpp.
See Also