
//#define  DIRECTSOUND_VERSION 0x0900

#include <dsound.h>
// MySound.h: interface for the MySound class.
//
//////////////////////////////////////////////////////////////////////



#if !defined(AFX_MYSOUND_H__A6564B47_B116_4ECC_9F60_F8C1783B6F2B__INCLUDED_)
#define AFX_MYSOUND_H__A6564B47_B116_4ECC_9F60_F8C1783B6F2B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

 


class MySound  
{
private:
    
	//for playing
	LPDIRECTSOUND		 lpDS;			//pointer to the directsound object
	LPDIRECTSOUNDBUFFER  lpDsb;			//secondary buffer
	LPDIRECTSOUNDBUFFER* ppDsb;			//pointer to pointer to Dsb
	DSCAPS				 dscaps;        //Structure specifies the capabilities of a DirectSound device for use by the IDirectSound::GetCaps 
	HMMIO				 hMMFile,hMMFileW;//handle to MultiMedia files
	WAVEFORMATEX		 wfx;			//defines the format of waveform-audio data
    DSBUFFERDESC		 dsbdesc;		//describes the necessary characteristics of a new DirectSoundBuffer object
	BYTE				 *pbData;		//the sound data read from the file  
	unsigned int		 iSizeSoundData;//size of the sound data
	
	//for capturing
	LPDIRECTSOUNDCAPTURE		lpDSC;	//pointer to DirectSoundCapture object
	LPDIRECTSOUNDCAPTUREBUFFER  lpDSCB;	//pointer to DirectSoundCaptureBuffer
	WAVEFORMATEX				wfxC;	//WFX structure for using with the capture buffer
	DSCBUFFERDESC				dscbdesc;// description of the DSCapture buffer /Must be the same format as the play buffer/
	BYTE						*pbDataToWrite;	//data from the soundcard
		
public:
	HANDLE						rghEvent[2];		//handle for Events(for CaptureBuffer)
	
	MySound();
	~MySound();


	//----------------Writing to sound card
	//-----------------Opens MMIO File for Reading--------------1
	BOOL OpenMMFileRead(HWND, char*);
	//-----------------Init DirectSound-------------2
	BOOL InitDS(HWND);
	//--------------Read The whole File-------------3
	BOOL ReadWholeFile(HWND);
	//-----------------CreateBasicBuffer------------4
	BOOL CreateBasicBuffer(HWND);
	//--------------------Play File-----------------5
	BOOL PlayFile(HWND);
	//------------------Creates Events--------------
	HANDLE CreateMyEvent(HWND);
	//--------------Appends Data to Buffer----------
	BOOL AppWriteDataToBuffer(HWND, DWORD);
	//-----------------Play File Bufferd------------
	BOOL PlayFileBuffered(HWND);
	
	
	


};

#endif // !defined(AFX_MYSOUND_H__A6564B47_B116_4ECC_9F60_F8C1783B6F2B__INCLUDED_)
