forked from sin365/AxibugEmuOnline
124 lines
2.9 KiB
C
124 lines
2.9 KiB
C
|
//
|
|||
|
// DirectSound class
|
|||
|
//
|
|||
|
#ifndef __DIRECTSOUND_INCLUDED__
|
|||
|
#define __DIRECTSOUND_INCLUDED__
|
|||
|
|
|||
|
#define WIN32_LEAN_AND_MEAN
|
|||
|
#include <windows.h>
|
|||
|
#include <mmsystem.h>
|
|||
|
|
|||
|
#define DIRECTSOUND_VERSION 0x0700
|
|||
|
#include <dsound.h>
|
|||
|
|
|||
|
#include "extsoundfile.h"
|
|||
|
|
|||
|
#include "typedef.h"
|
|||
|
#include "macro.h"
|
|||
|
|
|||
|
class CWaveData
|
|||
|
{
|
|||
|
public:
|
|||
|
CWaveData();
|
|||
|
virtual ~CWaveData();
|
|||
|
|
|||
|
BOOL Load( LPCSTR szFileName );
|
|||
|
void Free();
|
|||
|
|
|||
|
DWORD GetSize();
|
|||
|
WAVEFORMATEX* GetFormat();
|
|||
|
LPVOID GetData();
|
|||
|
protected:
|
|||
|
LPVOID m_pBuffer;
|
|||
|
|
|||
|
WAVEFORMATEX* m_pwfex;
|
|||
|
DWORD m_dwSize;
|
|||
|
|
|||
|
LPVOID m_pData;
|
|||
|
|
|||
|
private:
|
|||
|
};
|
|||
|
|
|||
|
class CDirectSound
|
|||
|
{
|
|||
|
public:
|
|||
|
// <20>p<EFBFBD>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD>ϐ<EFBFBD>
|
|||
|
typedef struct tagSAMPLERATE {
|
|||
|
DWORD Rate;
|
|||
|
DWORD Bits;
|
|||
|
} SAMPLERATE, *LPSAMPLERATE;
|
|||
|
|
|||
|
SAMPLERATE m_SampleRate; // <20><><EFBFBD>݃T<DD83><54><EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD><4F><EFBFBD>[<5B>g
|
|||
|
INT m_BufferSize; // <20>o<EFBFBD>b<EFBFBD>t<EFBFBD>@<40>T<EFBFBD>C<EFBFBD>Y(<28>t<EFBFBD><74><EFBFBD>[<5B><><EFBFBD><EFBFBD>)
|
|||
|
static SAMPLERATE m_SampleRateTable[]; // <20>T<EFBFBD><54><EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD><4F><EFBFBD>[<5B>g<EFBFBD>e<EFBFBD>[<5B>u<EFBFBD><75>
|
|||
|
static INT m_BufferSizeTable[]; // <20>o<EFBFBD>b<EFBFBD>t<EFBFBD>@<40>T<EFBFBD>C<EFBFBD>Y<EFBFBD>e<EFBFBD>[<5B>u<EFBFBD><75>
|
|||
|
|
|||
|
// <20>p<EFBFBD>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD><EFBFBD>
|
|||
|
CDirectSound();
|
|||
|
virtual ~CDirectSound();
|
|||
|
|
|||
|
BOOL InitialDSound( HWND hWnd );
|
|||
|
void ReleaseDSound();
|
|||
|
|
|||
|
BOOL InitialBuffer();
|
|||
|
void ReleaseBuffer();
|
|||
|
|
|||
|
BOOL SetSamplingRate( DWORD rate, DWORD bits );
|
|||
|
void GetSamplingRate( DWORD& rate, DWORD& bits );
|
|||
|
|
|||
|
void SetBufferSize( INT nSize ) { m_BufferSize = nSize; }
|
|||
|
INT GetBufferSize() { return m_BufferSize; }
|
|||
|
|
|||
|
BOOL IsStreamPlaying() { return (m_bStreamPlay&&!m_bStreamPause); }
|
|||
|
void StreamPlay();
|
|||
|
void StreamStop();
|
|||
|
void StreamPause();
|
|||
|
void StreamResume();
|
|||
|
|
|||
|
BOOL GetStreamLockPosition( LPDWORD lpdwStart, LPDWORD lpdwSize );
|
|||
|
BOOL StreamLock( DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOID* lplpvPtr1, LPDWORD lpdwBytes1, LPVOID* lplpvPtr2, LPDWORD lpdwBytes2, DWORD dwFlags );
|
|||
|
BOOL StreamUnlock( LPVOID lpvPtr1, DWORD dwBytes1, LPVOID lpvPtr2, DWORD dwBytes2 );
|
|||
|
|
|||
|
BOOL IsStreamPlay() { return m_bStreamPlay; }
|
|||
|
BOOL IsStreamPause() { return m_bStreamPause; }
|
|||
|
|
|||
|
// <20>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>Ή<EFBFBD>
|
|||
|
BOOL LoadEsf( LPCSTR szFileName, INT no );
|
|||
|
BOOL EsfPlay( INT no );
|
|||
|
BOOL EsfPlayLoop( INT no );
|
|||
|
BOOL EsfStop( INT no );
|
|||
|
void EsfAllStop();
|
|||
|
BOOL CreateESFBuffer( INT no, WAVEFORMATEX* pwfex, LPVOID pData, DWORD dwSize );
|
|||
|
void ReleaseEsfBuffer();
|
|||
|
|
|||
|
protected:
|
|||
|
// <20>v<EFBFBD><76><EFBFBD>e<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD>ϐ<EFBFBD>
|
|||
|
HWND m_hWnd; // Window handle
|
|||
|
|
|||
|
LPDIRECTSOUND m_lpDS; // DirectSound<6E>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g
|
|||
|
LPDIRECTSOUNDBUFFER m_lpDSPrimary; // <20>v<EFBFBD><76><EFBFBD>C<EFBFBD>}<7D><><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g
|
|||
|
|
|||
|
LPDIRECTSOUNDBUFFER m_lpDSStream; // <20>X<EFBFBD>g<EFBFBD><67><EFBFBD>[<5B>~<7E><><EFBFBD>O<EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g
|
|||
|
|
|||
|
DWORD m_dwDSBufferSize;
|
|||
|
DWORD m_dwDSBlockSize; // 1<>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD>̃T<CC83>C<EFBFBD>Y
|
|||
|
DWORD m_dwDSBlockNum; // <20>u<EFBFBD><75><EFBFBD>b<EFBFBD>N<EFBFBD>̐<EFBFBD>
|
|||
|
DWORD m_dwDSLastBlock; // <20>Ō<EFBFBD><C58C>ɏ<EFBFBD><C98F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>u<F182BE83><75><EFBFBD>b<EFBFBD>N<EFBFBD>ʒu
|
|||
|
|
|||
|
volatile BOOL m_bStreamPlay; // <20>X<EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>Đ<EFBFBD><C490><EFBFBD><EFBFBD>t<EFBFBD><74><EFBFBD>O
|
|||
|
volatile BOOL m_bStreamPause; // <20>X<EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>|<7C>[<5B>Y<EFBFBD>t<EFBFBD><74><EFBFBD>O
|
|||
|
|
|||
|
// <20>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>Ή<EFBFBD>
|
|||
|
CWaveData m_EsfWaveFile[ ESF_FILE_MAX ];
|
|||
|
LPDIRECTSOUNDBUFFER m_pEsfDSBuffer[ ESF_FILE_MAX ];
|
|||
|
|
|||
|
// <20>v<EFBFBD><76><EFBFBD>e<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD><EFBFBD>
|
|||
|
private:
|
|||
|
// <20>v<EFBFBD><76><EFBFBD>C<EFBFBD>x<EFBFBD>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD>ϐ<EFBFBD>
|
|||
|
// <20>v<EFBFBD><76><EFBFBD>C<EFBFBD>x<EFBFBD>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD><EFBFBD>
|
|||
|
};
|
|||
|
|
|||
|
extern CDirectSound DirectSound;
|
|||
|
|
|||
|
#endif // !__DIRECTSOUND_INCLUDED__
|