//GiGaHeRz's SPU2 Driver //Copyright (c) 2003-2008, David Quintana // //This library is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public //License as published by the Free Software Foundation; either //version 2.1 of the License, or (at your option) any later version. // //This library is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //Lesser General Public License for more details. // //You should have received a copy of the GNU Lesser General Public //License along with this library; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #include "spu2.h" class WaveOutModule: public SndOutModule { private: #define MAX_BUFFER_COUNT 5 #define BufferSize (CurBufferSize<<1) #define BufferSizeBytes (BufferSize<<1) HWAVEOUT hwodevice; WAVEFORMATEX wformat; WAVEHDR whbuffer[MAX_BUFFER_COUNT]; s32* tbuffer; s16* qbuffer; #define QBUFFER(x) (qbuffer + BufferSize * (x)) bool waveout_running; HANDLE thread; DWORD tid; SndBuffer *buff; FILE *voicelog; char ErrText[256]; static DWORD CALLBACK RThread(WaveOutModule*obj) { return obj->Thread(); } DWORD CALLBACK Thread() { while( waveout_running ) { int free=0; int first=-1; do { free=0; for(int i=0;idwBytesRecorded= buf->dwBufferLength; buff->ReadSamples(tbuffer,BufferSize); s16 *t = (s16*)buf->lpData; s32 *s = (s32*)tbuffer; for(int i=0;i>8); } waveOutWrite(hwodevice,buf,sizeof(WAVEHDR)); } return 0; } public: s32 Init(SndBuffer *sb) { buff = sb; MMRESULT woores; if (Test()) return -1; if(CurBufferSize<1024) CurBufferSize=1024; wformat.wFormatTag=WAVE_FORMAT_PCM; wformat.nSamplesPerSec=SampleRate; wformat.wBitsPerSample=16; wformat.nChannels=2; wformat.nBlockAlign=((wformat.wBitsPerSample * wformat.nChannels) / 8); wformat.nAvgBytesPerSec=(wformat.nSamplesPerSec * wformat.nBlockAlign); wformat.cbSize=0; woores = waveOutOpen(&hwodevice,WAVE_MAPPER,&wformat,0,0,0); if (woores != MMSYSERR_NOERROR) { waveOutGetErrorText(woores,(char *)&ErrText,255); SysMessage("WaveOut Error: %s",ErrText); return -1; } qbuffer=new s16[BufferSize*MAX_BUFFER_COUNT]; tbuffer=new s32[BufferSize]; for(int i=0;i