#include <mmsystem.h>
//-lwinmm

DWORD WINAPI playW (LPVOID);
static HANDLE gWThread=NULL;
DWORD wThreadId;
bool soundOn=false, keyLockS=false;
char charW [32];

void playWave (LPCSTR wave, bool force=false)
{
 strcpy (charW, wave);

 if (soundOn==true || force==true)
 {
  gWThread=CreateThread (NULL, 0, playW, (void *)"playW", 0, &wThreadId);
  Sleep (10);
  CloseHandle (gWThread);
  gWThread=NULL;
 }
}

DWORD WINAPI playW (LPVOID)
{
 char pathW [_MAX_PATH];
 memset (pathW, 0, _MAX_PATH);
 sprintf (pathW, "%sdata\\sound\\%s.wav", AppDir, charW);

 if ( !strcmp (charW, "enter") || !strcmp (charW, "exit") || !strcmp (charW, "new") || !strcmp (charW, "restart") || !strcmp (charW, "speech_draw") ||
      !strcmp (charW, "speech_loose") || !strcmp (charW, "speech_win") )
  sndPlaySound (pathW, SND_SYNC);
 else
  sndPlaySound (pathW, SND_ASYNC);
}