예제 #1
0
파일: primary.c 프로젝트: YokoZar/wine
static HRESULT WINAPI PrimaryBufferImpl_GetPan(
    LPDIRECTSOUNDBUFFER iface,LPLONG pan
) {
    IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface);
    DirectSoundDevice *device = This->device;
    DWORD ampfactors;
    TRACE("(%p,%p)\n", iface, pan);

    if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) {
        WARN("control unavailable\n");
        return DSERR_CONTROLUNAVAIL;
    }

    if (pan == NULL) {
        WARN("invalid parameter: pan == NULL\n");
        return DSERR_INVALIDPARAM;
    }

    waveOutGetVolume(device->hwo, &ampfactors);
    device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff;
    device->volpan.dwTotalRightAmpFactor=ampfactors >> 16;
    DSOUND_AmpFactorToVolPan(&device->volpan);
    *pan = device->volpan.lPan;
    return DS_OK;
}
예제 #2
0
static int winsnd_get_level(MSSndCard *card, MSSndCardMixerElem e)
{
	WinSndData *d=(WinSndData*)card->data;
    MMRESULT mr = NOERROR;
    DWORD dwVolume = 0x0000;

	if (d->mixdev==NULL) return -1;
	switch(e){
		case MS_SND_CARD_MASTER:
            mr=waveOutGetVolume(d->waveoutdev, &dwVolume);
            // Transform to 0 to 100 scale
            //dwVolume = (dwVolume *100) / (0xFFFF);
            return 60;
        break;
#if 0
        case MS_SND_CARD_CAPTURE:
			osscmd=SOUND_MIXER_IGAIN;
		break;
		case MS_SND_CARD_PLAYBACK:
			osscmd=SOUND_MIXER_PCM;
		break;
#endif
		default:
			ms_warning("winsnd_card_get_level: unsupported command.");
			return -1;
	}
	return -1;
}
예제 #3
0
파일: ds.c 프로젝트: btb/d2x
WORD SSGetVolume()
{
	DWORD vol;

	waveOutGetVolume((HWAVEOUT)WAVE_MAPPER, &vol);
	
	return XlatWAVToSSVol(vol);
}
예제 #4
0
파일: wavemap.c 프로젝트: Strongc/reactos
static	DWORD	wodGetVolume(UINT wDevID, WAVEMAPDATA* wom, LPDWORD lpVol)
{
    TRACE("(%04x %p %p)\n",wDevID, wom, lpVol);

    if (WAVEMAP_IsData(wom))
	return waveOutGetVolume(wom->u.out.hInnerWave, lpVol);
    return MMSYSERR_NOERROR;
}
void __fastcall TMainForm::tbRightVolumeChange(TObject *Sender)
{
    unsigned long      v ,t;
    t = tbRightVolume->Max-tbRightVolume->Position;
    waveOutGetVolume(0 ,&v);
    v = v & 0x0000ffff | (t<<24);
    waveOutSetVolume(0 ,v);
}
예제 #6
0
	DWORD TinyWaveOut::GetVolume()
	{
		DWORD dwVolume;
		if (hWaveOut != NULL)
		{
			waveOutGetVolume(hWaveOut, &dwVolume);
		}
		return dwVolume;
	}
예제 #7
0
VolumeSettings VolumeWaveOut::volume() const
{
    VolumeSettings vol;
    DWORD data;
    waveOutGetVolume(0, (PDWORD)&data);
    vol.left = (long)LOWORD(data) * 100 / 0xFFFF + 1;
    vol.right = (long)HIWORD(data) * 100 / 0xFFFF + 1;
    return vol;
}
예제 #8
0
파일: player.cpp 프로젝트: afriza/GSPlayer
DWORD CPlayer::GetVolume(BOOL bSysVolume)
{
	DWORD dwVolume = 0;
	if (bSysVolume) {
		waveOutGetVolume(NULL, &dwVolume);
		return dwVolume;
	}
	else {
		return m_Output.GetVolume();
	}
}
예제 #9
0
파일: ds.c 프로젝트: btb/d2x
BOOL SSInit(HWND hWnd, int channels, unsigned flags)
{
	LPDIRECTSOUNDBUFFER lpPrimaryBuffer;
	LPDIRECTSOUND lpDS;
	DSBUFFERDESC dsbd;

	if (SSMixer.lpds) return TRUE;

//	Perform Direct Sound Initialization
	if (DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK) 
		return FALSE;

	SSMixer.lpds = lpDS;

	if (IDirectSound_SetCooperativeLevel(lpDS, hWnd, DSSCL_NORMAL) != DS_OK) {
		SSDestroy();
		return FALSE;
	}

//	Start Mixer
	memset(&dsbd, 0, sizeof(DSBUFFERDESC));
	dsbd.dwSize = sizeof(DSBUFFERDESC);
	dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
	if (IDirectSound_CreateSoundBuffer(SSMixer.lpds, &dsbd, &lpPrimaryBuffer, NULL) == DS_OK) {
		if (IDirectSoundBuffer_Play(lpPrimaryBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK) {
			IDirectSoundBuffer_Release(lpPrimaryBuffer);
			SSDestroy();
			return FALSE;
		}
		IDirectSoundBuffer_Release(lpPrimaryBuffer);
	}
	else {
		SSDestroy();
		return FALSE;
	}


//	Finish initializing SSMixer.
	SSMixer.ch_cur = 0;
	SSMixer.ch_list = (SSoundBuffer *)malloc(sizeof(SSoundBuffer)*channels);
	if (!SSMixer.ch_list) return FALSE;
	
	memset(SSMixer.ch_list, 0, sizeof(SSoundBuffer)*channels);
	
	SSMixer.ch_num = channels;

//	Determine Sound technology and volume caps
	waveOutGetVolume((HWAVEOUT)WAVE_MAPPER, (LPDWORD)&SSMixer.old_master_vol);
//	waveOutSetVolume((HWAVEOUT)WAVE_MAPPER, 0x40004000);
	return TRUE;
}
예제 #10
0
PxVolume Px_GetPCMOutputVolume( PxMixer *mixer )
{
  MMRESULT result;
  DWORD vol = 0;
  unsigned short mono_vol = 0;
  PxInfo *info = (PxInfo *)mixer;

  result = waveOutGetVolume(info->muxID, &vol);

  if (result != MMSYSERR_NOERROR)
     return 0.0;

  mono_vol = (unsigned short)vol;
  return (PxVolume)mono_vol/65535.0;
}
/** 
 * retrieved volume as an int in a scale from 0x0000 to 0xFFFF
 * only one value for all channels
 */
int sa_stream_get_write_volume(sa_stream_t *s, int32_t vol[], unsigned int *n) {
  int status;
	DWORD volume;
	WORD left;
	WORD right;

	ERROR_IF_NO_INIT(s);
  
	status = waveOutGetVolume(s->hWaveOut, &volume);
	HANDLE_WAVE_ERROR(status, "reading audio volume level");

	left = volume & LEFT_CHANNEL_MASK;
	right = (volume & RIGHT_CHANNEL_MASK) >> 16;
  vol[0] = (int32_t)(left + right /2);	

	return SA_SUCCESS;

}
예제 #12
0
static void sink_get_volume_cb(pa_sink *s) {
    struct userdata *u = s->userdata;
    WAVEOUTCAPS caps;
    DWORD vol;
    pa_volume_t left, right;

    if (waveOutGetDevCaps(u->hwo, &caps, sizeof(caps)) != MMSYSERR_NOERROR)
        return;
    if (!(caps.dwSupport & WAVECAPS_VOLUME))
        return;

    if (waveOutGetVolume(u->hwo, &vol) != MMSYSERR_NOERROR)
        return;

    left = PA_CLAMP_VOLUME((vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
    if (caps.dwSupport & WAVECAPS_LRVOLUME)
        right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
    else
예제 #13
0
파일: primary.c 프로젝트: carlosbislip/wine
static HRESULT WINAPI PrimaryBufferImpl_SetVolume(
	LPDIRECTSOUNDBUFFER iface,LONG vol
) {
	DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
	DWORD ampfactors;
        HRESULT hres = DS_OK;
	TRACE("(%p,%d)\n", iface, vol);

	if (!(device->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) {
		WARN("control unavailable\n");
		return DSERR_CONTROLUNAVAIL;
	}

	if ((vol > DSBVOLUME_MAX) || (vol < DSBVOLUME_MIN)) {
		WARN("invalid parameter: vol = %d\n", vol);
		return DSERR_INVALIDPARAM;
	}

	/* **** */
	EnterCriticalSection(&(device->mixlock));

        waveOutGetVolume(device->hwo, &ampfactors);
        device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff;
        device->volpan.dwTotalRightAmpFactor=ampfactors >> 16;
        DSOUND_AmpFactorToVolPan(&device->volpan);
        if (vol != device->volpan.lVolume) {
            device->volpan.lVolume=vol;
            DSOUND_RecalcVolPan(&device->volpan);
            if (device->hwbuf) {
                hres = IDsDriverBuffer_SetVolumePan(device->hwbuf, &device->volpan);
                if (hres != DS_OK)
                    WARN("IDsDriverBuffer_SetVolumePan failed\n");
            } else {
                ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFactor << 16);
                waveOutSetVolume(device->hwo, ampfactors);
            }
        }

	LeaveCriticalSection(&(device->mixlock));
	/* **** */

	return hres;
}
예제 #14
0
static UINT32 rdpsnd_winmm_get_volume(rdpsndDevicePlugin* device)
{
	DWORD dwVolume;
	UINT16 dwVolumeLeft;
	UINT16 dwVolumeRight;

	rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;

	dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
	dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
	dwVolume = (dwVolumeLeft << 16) | dwVolumeRight;

	if (!winmm->hWaveOut)
		return dwVolume;

	waveOutGetVolume(winmm->hWaveOut, &dwVolume);

	return dwVolume;
}
예제 #15
0
파일: primary.c 프로젝트: YokoZar/wine
static HRESULT WINAPI PrimaryBufferImpl_SetPan(
    LPDIRECTSOUNDBUFFER iface,LONG pan
) {
    IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface);
    DirectSoundDevice *device = This->device;
    DWORD ampfactors;
    HRESULT hres = DS_OK;
    TRACE("(%p,%d)\n", iface, pan);

    if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) {
        WARN("control unavailable\n");
        return DSERR_CONTROLUNAVAIL;
    }

    if ((pan > DSBPAN_RIGHT) || (pan < DSBPAN_LEFT)) {
        WARN("invalid parameter: pan = %d\n", pan);
        return DSERR_INVALIDPARAM;
    }

    /* **** */
    EnterCriticalSection(&(device->mixlock));

    waveOutGetVolume(device->hwo, &ampfactors);
    device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff;
    device->volpan.dwTotalRightAmpFactor=ampfactors >> 16;
    DSOUND_AmpFactorToVolPan(&device->volpan);
    if (pan != device->volpan.lPan) {
        device->volpan.lPan=pan;
        DSOUND_RecalcVolPan(&device->volpan);
        ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFactor << 16);
        waveOutSetVolume(device->hwo, ampfactors);
    }

    LeaveCriticalSection(&(device->mixlock));
    /* **** */

    return hres;
}
예제 #16
0
파일: primary.c 프로젝트: carlosbislip/wine
static HRESULT WINAPI PrimaryBufferImpl_GetVolume(
	LPDIRECTSOUNDBUFFER iface,LPLONG vol
) {
	DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
	DWORD ampfactors;
	TRACE("(%p,%p)\n", iface, vol);

	if (!(device->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) {
		WARN("control unavailable\n");
		return DSERR_CONTROLUNAVAIL;
	}

	if (vol == NULL) {
		WARN("invalid parameter: vol = NULL\n");
		return DSERR_INVALIDPARAM;
	}

        if (!device->hwbuf)
        {
	    waveOutGetVolume(device->hwo, &ampfactors);
	    device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff;
	    device->volpan.dwTotalRightAmpFactor=ampfactors >> 16;
	    DSOUND_AmpFactorToVolPan(&device->volpan);
        }
예제 #17
0
PxVolume Px_GetPCMOutputVolume( PxMixer *mixer )
{
  MMRESULT result;
  DWORD vol = 0;
  unsigned short mono_vol = 0;
  PxInfo *info = (PxInfo *)mixer;

	/* invalid waveID, return zero */
	if ( info->waveID == -1 )
		return 0.0 ;

	/* get the wave output volume */
	result = waveOutGetVolume( (HWAVEOUT)( info->waveID ), &vol);

	/* on failure, mark waveID as invalid and return zero */
	if ( result != MMSYSERR_NOERROR )
	{
		info->waveID = -1 ;
		return 0.0 ;
	}

  mono_vol = (unsigned short)vol;
  return (PxVolume)mono_vol/65535.0;
}
예제 #18
0
파일: ao_win32.c 프로젝트: 0p1pp1/mplayer
// to set/get/query special features/parameters
static int control(int cmd,void *arg)
{
	DWORD volume;
	switch (cmd)
	{
		case AOCONTROL_GET_VOLUME:
		{
			ao_control_vol_t* vol = (ao_control_vol_t*)arg;
			waveOutGetVolume(hWaveOut,&volume);
			vol->left = LOWORD(volume)/655.35;
			vol->right = HIWORD(volume)/655.35;
			mp_msg(MSGT_AO, MSGL_DBG2,"ao_win32: volume left:%f volume right:%f\n",vol->left,vol->right);
			return CONTROL_OK;
		}
		case AOCONTROL_SET_VOLUME:
		{
			ao_control_vol_t* vol = (ao_control_vol_t*)arg;
			volume = MAKELONG(vol->left*655.35,vol->right*655.35);
			waveOutSetVolume(hWaveOut,volume);
			return CONTROL_OK;
		}
	}
    return -1;
}
예제 #19
0
파일: sound.c 프로젝트: mmaruska/emacs
static int
do_play_sound (const char *psz_file, unsigned long ui_volume)
{
  int i_result = 0;
  MCIERROR mci_error = 0;
  char sz_cmd_buf[520] = {0};
  char sz_ret_buf[520] = {0};
  MMRESULT mm_result = MMSYSERR_NOERROR;
  unsigned long ui_volume_org = 0;
  BOOL b_reset_volume = FALSE;

  memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf));
  memset (sz_ret_buf, 0, sizeof (sz_ret_buf));
  sprintf (sz_cmd_buf,
           "open \"%s\" alias GNUEmacs_PlaySound_Device wait",
           psz_file);
  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), NULL);
  if (mci_error != 0)
    {
      SOUND_WARNING (mciGetErrorString, mci_error,
		     "The open mciSendString command failed to open "
		     "the specified sound file.");
      i_result = (int) mci_error;
      return i_result;
    }
  if ((ui_volume > 0) && (ui_volume != UINT_MAX))
    {
      mm_result = waveOutGetVolume ((HWAVEOUT) WAVE_MAPPER, &ui_volume_org);
      if (mm_result == MMSYSERR_NOERROR)
        {
          b_reset_volume = TRUE;
          mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume);
          if (mm_result != MMSYSERR_NOERROR)
            {
	      SOUND_WARNING (waveOutGetErrorText, mm_result,
			     "waveOutSetVolume failed to set the volume level "
			     "of the WAVE_MAPPER device.\n"
			     "As a result, the user selected volume level will "
			     "not be used.");
            }
        }
      else
        {
          SOUND_WARNING (waveOutGetErrorText, mm_result,
			 "waveOutGetVolume failed to obtain the original "
                         "volume level of the WAVE_MAPPER device.\n"
                         "As a result, the user selected volume level will "
                         "not be used.");
        }
    }
  memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf));
  memset (sz_ret_buf, 0, sizeof (sz_ret_buf));
  strcpy (sz_cmd_buf, "play GNUEmacs_PlaySound_Device wait");
  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), NULL);
  if (mci_error != 0)
    {
      SOUND_WARNING (mciGetErrorString, mci_error,
		     "The play mciSendString command failed to play the "
		     "opened sound file.");
      i_result = (int) mci_error;
    }
  memset (sz_cmd_buf, 0, sizeof (sz_cmd_buf));
  memset (sz_ret_buf, 0, sizeof (sz_ret_buf));
  strcpy (sz_cmd_buf, "close GNUEmacs_PlaySound_Device wait");
  mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, sizeof (sz_ret_buf), NULL);
  if (b_reset_volume == TRUE)
    {
      mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume_org);
      if (mm_result != MMSYSERR_NOERROR)
        {
          SOUND_WARNING (waveOutGetErrorText, mm_result,
			 "waveOutSetVolume failed to reset the original volume "
                         "level of the WAVE_MAPPER device.");
        }
    }
  return i_result;
}
예제 #20
0
void PlayMusicTest(void)
{
	int size, i, j, err;
	WAVEFORMATEX fmt;
	WAVEHDR hdr[2048];
	HWAVEOUT hwo;	
	U8 pause = 0;
	U8 mute = 0;	
	U32 volume;
	unsigned char *buf;

	downloadAddress = _NONCACHE_STARTADDRESS;
	buf = (unsigned char *)downloadAddress ;
	for( i = 0; i < 243552; i++ )  buf[i] = WindowsXP_Wav[i] ;
	downloadFileSize = 243552 ;

	size = *(U32 *)(downloadAddress+0x28);
	i = 0;							
	
	while(size>0)
	{
		hdr[i].lpData = (LPSTR)(downloadAddress+0x2c+i*BUF_SIZE);
		hdr[i].dwBufferLength = (size>BUF_SIZE)?BUF_SIZE:size;	
		size -= BUF_SIZE;
		i++;
	}
	
	fmt.wFormatTag		= WAVE_FORMAT_PCM;
	fmt.nChannels		= *(U16 *)(downloadAddress+0x16);
	fmt.nSamplesPerSec	= *(U32 *)(downloadAddress+0x18);
	fmt.nAvgBytesPerSec	= *(U32 *)(downloadAddress+0x1c);
	fmt.nBlockAlign		= *(U16 *)(downloadAddress+0x20);
	fmt.wBitsPerSample	= *(U16 *)(downloadAddress+0x22);
	Uart_Printf("\nSample Rate = %d, Channels = %d, %dBitsPerSample, size = %d\n",
			fmt.nSamplesPerSec, fmt.nChannels, fmt.wBitsPerSample, *(U32 *)(downloadAddress+0x28));
	
	hwo = 0;
	err = waveOutOpen(&hwo,
				0,
				&fmt,
				0,
				0,
				0);
	Uart_Printf("\nerr = %x\n", err);
	for(j=0;j<i;j++)
		waveOutWrite(0,	&hdr[j], 0);
		
	Uart_Printf("Now playing the file\n");
	Uart_Printf("Press 'ESC' to quit, '+' to inc volume, '-' to dec volume, 'm' to mute, 'p' to pause\n");		
	
	waveOutGetVolume(0,	&volume);
	while(1)
	{
		U8 key = Uart_Getch();
		if( key == ESC_KEY )
			break;
		if(key=='p')
		{
			pause ^= 1;
			if(pause&1)
				waveOutPause(0);
			else
				waveOutRestart(0);				
		}
		if(key=='m')
		{						
			mute ^= 1;
			if(mute&1)									
				waveOutSetVolume(0, 0);			
			else
				waveOutSetVolume(0, volume);			
		}
		if((key=='+')&&(volume<=64535))		
		{
			volume += 1000;
			waveOutSetVolume(0, volume);
		}
		if((key=='-')&&(volume>=1000))
		{
			volume -= 1000;
			waveOutSetVolume(0, volume);
		}	
					
	}					
	waveOutClose(0);
}
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
    //ShowMessage(String(MediaPlayer->Length));
    //取消 程序任务栏显示运行 !
    LONG style = GetWindowLong(Application->Handle ,GWL_EXSTYLE);
    SetWindowLong(Application->Handle ,GWL_EXSTYLE ,style|WS_EX_TOOLWINDOW);
    time_t t;
    srand((unsigned) time(&t));
//或:srand((unsigned) time(0));//只能初始化一次!!!!
    ScanForward = false;
    //AutoPlayItem->Checked = false;
    /*
    if(Timer_Down->Interval > Timer_Display->Interval)
        Timer_Down->Interval = Timer_Display->Interval;
    else
        Timer_Display->Interval = Timer_Down->Interval;
    */
    //获取系统音量 数据 并显示于 TTrackBar 组件
    tbMainVolume->Max = 255;
    tbLeftVolume->Max = 255;
    tbRightVolume->Max = 255;
    unsigned long     volume;
    waveOutGetVolume(0 ,&volume);
    tbLeftVolume->Position = tbLeftVolume->Max -(double(volume&0x0000FFFF))/0xFFFF*tbLeftVolume->Max;
    tbRightVolume->Position = tbRightVolume->Max -(double((volume&0xFFFF0000)>>16))/0xFFFF*tbRightVolume->Max;
    if(tbRightVolume->Position<tbLeftVolume->Position)// 声道音量大小与位置Position 相反
        tbMainVolume->Position = tbRightVolume->Max-tbRightVolume->Position;
    else
        tbMainVolume->Position = tbLeftVolume->Max-tbLeftVolume->Position;

    GroupBoxGame->Left = (Screen->Width-GroupBoxGame->Width)/2;
    GroupBoxGame->Top  = (Screen->Height-GroupBoxGame->Height)/2;
    GroupBoxSet->Visible = false;
    ShowCursor(false);
    //自动开始游戏
    gameoverflag = false;
    NewGame();   /*  */
    try
    {
        MediaPlayerFlag = true;
        String  Mp3Path = ExtractFilePath(Application->ExeName) + "\\Music.mp3 ";
        MediaPlayer->FileName = Mp3Path;
        MediaPlayer->Open();
        MediaPlayer->Play();
        //ShowMessage(String(MediaPlayer->Length));
    }
    catch(...)
    {
        MediaPlayerFlag = false;
        try
        {
            String  WavePath = ExtractFilePath(Application->ExeName) + "\\Music.Wav ";
            //异步,循环,播放指定文件--,SND_ASYNC |SND_LOOP | SND_FILENAME
            if(! sndPlaySound(WavePath.c_str() ,SND_ASYNC | SND_LOOP | SND_FILENAME))
                throw 'e';
        }
        catch(char e)
        {
            ShowMessage("请把媒体文件Music.wav \n一同Copy到与应用程序同一目录!");
        }
        ShowMessage("请把媒体文件Music.mp3 \n一同Copy到与应用程序同一目录!");
    }
}
예제 #22
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp){

	//tab controls
	INITCOMMONCONTROLSEX ic;
	static RECT rcDisp;
	
	//trackbar
	static HWND hTrack = NULL;

	// buttons and edit(read-only) handles
	static HWND hOpen = NULL;  
	static HWND hPlay = NULL;
	static HWND hPause = NULL;
	static HWND hStop = NULL;
	static HWND hLoop = NULL;
	static HWND hDown = NULL;
	static HWND hUp = NULL;
	static HWND hExit = NULL;
	
	static HDC hdc;
	PAINTSTRUCT ps;
	DWORD dw;
	int i, ia;
	short s;

	static LPDWORD lpPixel;
	static BITMAPINFO bmpInfo;
	static int iWidth, iHeight;

	static LPDWORD lpPixelCursor;
	static BITMAPINFO bmpInfoCursor;
	static int iWidthCursor, iHeightCursor, iTimeCursor;

	static int iPixel = 0;

	HBITMAP hBmp;
	static HDC hdc_mem;

	// file
	static OPENFILENAME ofn;
	static char szFile[MAX_PATH];
	static char szFileTitle[MAX_PATH];

	//wav file
	static HWAVEOUT hWaveOut;
	static WAVEFORMATEX wfe;
	static WAVEHDR whdr;

	const RECT rcWave = {10, 10, 1225, 447};//10, 20, 1235, 550 //10, 10, 631, 381
	const RECT rcBar = {10, 390, 631, 401};
	static RECT rcInfo[] = {{1, 1060, 900, 20}, {2000, 1060, 110, 20}, {2220, 1060, 110, 20}, {2335, 1060, 108, 20}};
	static RECT rcMove = rcInfo[0];

	static MMTIME mmTime;
	static DWORD maxTime;
	DWORD dwOffset;

	// wave
	static POINT ptWaveL[1226], ptWaveR[1226];//621
	static WORD wHalfMaxAmp;
	static HPEN hPenL, hPenR;
	static int hueL, hueR, hueLR;

	// volume
	static DWORD dwVolStart;
	static WORD wVolNow;
	DWORD dwVolTemp;

	// font
	static HFONT hFont[3];
	
	static BYTE rr = 0, gg = 128, bb = 128; // open, pause, exit
	static BYTE r = 0, g = 128, b = 128; // play
	static BYTE rs = 0, gs = 128, bs = 128; // stop
	static BYTE vr1 = 0, vg1 = 128, vb1 = 128; // volume-down
	static BYTE vr2 = 0, vg2 = 128, vb2 = 128; // volume-up
	static BYTE rLoop = 0, gLoop = 128, bLoop = 128; // loop

	//text
	static char strFile[1024];
	static char strTime[32];
	static char strVol[16];
	static char strState[16];
	static SIZE sizeFile;

	static BOOL open = FALSE;
	static BOOL play = FALSE;
	static BOOL pause = FALSE;
	static BOOL loop = FALSE;

		switch( msg ){
			case WM_CREATE:
				
				DragAcceptFiles(hwnd, TRUE);
				
				// background bmp
				lpPixel = bmptoDIB("480127.bmp", &bmpInfo);
				iWidth = bmpInfo.bmiHeader.biWidth;
				iHeight = bmpInfo.bmiHeader.biHeight;

				// get Window's device context handle
				hdc = GetDC( hwnd );
				hBmp = CreateCompatibleBitmap(hdc, iWidth, iHeight);
				// make memory device context
				hdc_mem = CreateCompatibleDC(hdc);
				// select bitmap which is loaded 
				SelectObject( hdc_mem, hBmp );
				DeleteObject(hBmp);
				ReleaseDC(hwnd, hdc);

					// initialize OPENFILENAME
				ofn.lStructSize = sizeof(OPENFILENAME);
				ofn.hwndOwner = hwnd;
				ofn.lpstrFilter = "WAVE_FORMAT_PCM(*.wav)\0*.wav\0";
				ofn.lpstrFile = szFile;
				ofn.nMaxFile = MAX_PATH;
				ofn.lpstrFileTitle = szFileTitle;
				ofn.nMaxFileTitle = MAX_PATH;
				ofn.Flags = OFN_FILEMUSTEXIST;
				ofn.lpstrDefExt = "wav";
				ofn.lpstrTitle = "Select PCM type of Wav file";

				// create pen
				hPenL = CreatePen(PS_SOLID, 1, RGB(255,255,0)); // 
				hPenR = CreatePen(PS_SOLID, 1, RGB(0,255,255)); // 

				// initialize a coordinate for wave
				for(i = 0; i< sizeof(ptWaveL)/sizeof(ptWaveL[0]); i++)
				{
					ptWaveL[i].x = 10+i;
					ptWaveL[i].y = -10;

					ptWaveR[i].x = 10+i;
					ptWaveR[i].y = -10;
				}

				// change background mode
				SetBkMode(hdc_mem, TRANSPARENT);

				hFont[0] = CreateFont(18, 0, 0, 0, FW_BOLD, TRUE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Times New Roman");
				hFont[1] = CreateFont(24, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Arial Black");
				hFont[2] = CreateFont(12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Times New Roman");
			
				// initialize MMTIME
				mmTime.wType = TIME_BYTES;

				// store an initial value for volume and show the volume
				waveOutGetVolume(hWaveOut, &dwVolStart);
				wVolNow = LOWORD(dwVolStart);
				wsprintf(strVol, "%03d/128", (wVolNow +1)/512);

				// show state
				 wsprintf(strState, "NoData");
			
				//button
				hOpen = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Open") , WS_CHILD | WS_VISIBLE , 15, 620 , 70 , 30 , hwnd , (HMENU)ID_OPEN, ((LPCREATESTRUCT)(lp))->hInstance , NULL);
				hPlay = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Play") , WS_CHILD | WS_VISIBLE , 90, 620 , 70 , 30 , hwnd , (HMENU)ID_PLAY, ((LPCREATESTRUCT)(lp))->hInstance , NULL);
				hPause = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Pause") , WS_CHILD | WS_VISIBLE , 165 , 620 , 70 , 30 , hwnd , (HMENU)ID_PAUSE, ((LPCREATESTRUCT)(lp))->hInstance , NULL);
				hStop = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Stop") , WS_CHILD | WS_VISIBLE , 240 , 620 , 70 , 30 , hwnd , (HMENU)ID_STOP, ((LPCREATESTRUCT)(lp))->hInstance , NULL);
				hLoop = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Loop") , WS_CHILD | WS_VISIBLE , 900 , 620 , 70 , 30 , hwnd , (HMENU)ID_LOOP, ((LPCREATESTRUCT)(lp))->hInstance , NULL);
				hDown = CreateWindowEx(0, TEXT("BUTTON"), TEXT("-") , WS_CHILD | WS_VISIBLE , 1000 , 620 , 40 , 30 , hwnd , (HMENU)ID_DOWN, ((LPCREATESTRUCT)(lp))->hInstance, NULL);
				hUp = CreateWindowEx(0, TEXT("BUTTON"), TEXT("+") , WS_CHILD | WS_VISIBLE , 1050 , 620 , 40 , 30 , hwnd , (HMENU)ID_UP, ((LPCREATESTRUCT)(lp))->hInstance , NULL);
				hExit = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Exit") , WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, 1160, 620 , 70 , 30 , hwnd , (HMENU)ID_EXITT, ((LPCREATESTRUCT)(lp))->hInstance, NULL);		

				//track bar
				ic.dwSize = sizeof(INITCOMMONCONTROLSEX); 
				ic.dwICC = ICC_BAR_CLASSES;
				InitCommonControlsEx(&ic);

				hTrack = CreateWindowEx(0, TRACKBAR_CLASS, "", WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_AUTOTICKS, 10, 580, 1230, 25, hwnd, (HMENU)IDC_TRACKBAR, ((LPCREATESTRUCT)(lp))->hInstance, NULL);
			 //   TrackProc = (WNDPROC)GetWindowLong(hTrack, GWL_WNDPROC); 
				//SetWindowLong(hTrack, GWL_WNDPROC, (LONG)TrackProc); 
			//	SendMessage(hTrack, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELPARAM(0, 100));
				
				return 0;
			case WM_SIZE:
				return 0;
			/*case WM_NOTIFY:
				switch (((NMHDR *)lp)->code){
					case TCN_SELCHANGE:
						if (TabCtrl_GetCurSel(hTab) == 0){
							InvalidateRect(hTab, &rcDisp, FALSE); 
						    InvalidateRect(hStatic, NULL, FALSE);

						}else if(TabCtrl_GetCurSel(hTab) == 1){
							InvalidateRect(hStatic, NULL, FALSE);
						}else{

						}
						 
						break;
					case TCN_SELCHANGING:
						return FALSE;
				}
		
				return 0;
*/
			case WM_COMMAND:
				switch(LOWORD(wp)) {
					case ID_TAB:
						break;
					case ID_OPTIONS_DOWNLOADMUSIC:





						////////////////////////    CREATE UDP SOCKET     FROM MENU           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


						break;
					case ID_OPTIONS_MICROPHONE:
						





						/////////////////////            CREATE MICROPHONE FROM MENU        !!!!!!!!!!!!!!!!!!!!



						break;
					case ID_DIRECTX_MULTIPLAYER:
						hTab = MakeTabCtrl(hwnd);
					//	PostMessage(hStatic, ID_STATIC, (WPARAM)0, (LPARAM)0);	
						break;
					case ID_DIRECTX_TABCLOSEFORMULTIPLAYER:
						break;
					case ID_OPEN: // when "Open" is pushed
						if(GetOpenFileName(&ofn))
							{
								if(open)
								{		
									play=FALSE;
									pause=FALSE;

									KillTimer(hwnd, 1);
									rcMove.left = rcInfo[0].left;
									iTimeCursor = 0;
									 
									waveOutReset(hWaveOut);
									waveOutUnprepareHeader(hWaveOut, &whdr, sizeof(WAVEHDR));
									waveOutClose(hWaveOut);
									HeapFree(GetProcessHeap(), 0, whdr.lpData);
								}

								if(waveIn(ofn.lpstrFile, &hWaveOut, &wfe, &whdr))
								{
									for(i=0;i<sizeof(ptWaveL)/sizeof(ptWaveL[0]);i++)
									{
										ptWaveL[i].y = -10;		//default value
										ptWaveR[i].y = -10;		//default value
									}
									strFile[0] = NULL;
									strTime[0] = NULL;
									wsprintf(strState, "NoData");
								    InvalidateRect(hwnd, &rcWave, FALSE);
									InvalidateRect(hwnd, &rcInfo[0], FALSE);
									InvalidateRect(hwnd, &rcInfo[1], FALSE);
									InvalidateRect(hwnd, &rcInfo[3], FALSE);
									
									return 0;
								}
								waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfe, (DWORD)hwnd, 0, CALLBACK_WINDOW);
								waveOutPrepareHeader(hWaveOut, &whdr, sizeof(WAVEHDR));

								wHalfMaxAmp = pow(2, wfe.wBitsPerSample-1);	//half of the max amplitud
								
								for(i=0;i<sizeof(ptWaveL)/sizeof(ptWaveL[0]);i++)
									ptWaveL[i].y=250;		//screen center for wave

								if(wfe.nChannels == 2)
								{
                                    for(i = 0 ; i < sizeof(ptWaveR)/sizeof(ptWaveR[0]) ; i++)
										ptWaveR[i].y = 250;	//screen center for wave
								}
								else
								{
                                    for(i = 0 ; i < sizeof(ptWaveR)/sizeof(ptWaveR[0]) ; i++)
										ptWaveR[i].y = -10;	//default value
								}

								wsprintf(strFile,"%s :- %d bits / %s / %d Hz",
									ofn.lpstrFileTitle,wfe.wBitsPerSample,
									(wfe.nChannels==2)?"stereo":"mono",wfe.nSamplesPerSec);

								SelectObject(hdc_mem,hFont[2]);
								GetTextExtentPoint32(hdc_mem,strFile,(int)strlen(strFile),&sizeFile);

								maxTime=100*whdr.dwBufferLength/wfe.nAvgBytesPerSec;

								wsprintf(strTime,"00:00:00/%02d:%02d:%02d",
									(maxTime/100)/60,(maxTime/100)%60,maxTime%100);		//total time

								open=TRUE;
								wsprintf(strState,"ready");
								
								InvalidateRect(hwnd,&rcWave,FALSE);
								InvalidateRect(hwnd,&rcInfo[0],FALSE);
								InvalidateRect(hwnd,&rcInfo[1],FALSE);
								InvalidateRect(hwnd,&rcInfo[3],FALSE);
							}
							return 0;

					case ID_PLAY: // when "Play" is pressed
						if(!open || play) return 0;

							//file is open but not playing
							play=TRUE;
							wsprintf(strState,"playing");
							InvalidateRect(hwnd,&rcInfo[3],FALSE);
					
							if(pause)
							{	
								pause=FALSE;
								waveOutRestart(hWaveOut);
							}
							else
							{		
								iTimeCursor=0;
                            	waveOutWrite(hWaveOut,&whdr,sizeof(WAVEHDR));
							}
							SetTimer(hwnd,1,50,NULL);
							break;
					case ID_PAUSE: // when "Pause" button is pushed
						if(!play && !pause) return 0;

							//playing or pause
							if(pause)
							{
								pause=FALSE;
								play=TRUE;
								wsprintf(strState,"playing");
								waveOutRestart(hWaveOut);
								SetTimer(hwnd,1,50,NULL);
							}
							else
							{
								pause=TRUE;
								play=FALSE;
								wsprintf(strState,"pause");
								waveOutPause(hWaveOut);
								KillTimer(hwnd,1);
							}
							InvalidateRect(hwnd,&rcInfo[3],FALSE);
						break;
					case ID_STOP: // when "Stop" button is pressed
						if(!open) return 0;

							if(play) 
							{	//pushed during playing		
								play=FALSE;
								pause=FALSE;
								iTimeCursor=0;
								waveOutReset(hWaveOut);		//MM_WOM_DONE message is sent
							}
							else
							{
								for(i=0;i<sizeof(ptWaveL)/sizeof(ptWaveL[0]);i++)
									ptWaveL[i].y=250;		//center for wave drawn

								if(wfe.nChannels==2)
									for(i=0;i<sizeof(ptWaveR)/sizeof(ptWaveR[0]);i++)
										ptWaveR[i].y=250;	//center for wave drawn

								if(pause)
								{		//pushed during pause
									play=FALSE;
									pause=FALSE;
									waveOutReset(hWaveOut);

									rcMove.left=rcInfo[0].left;
									wsprintf(strState,"ready");

									InvalidateRect(hwnd,&rcWave,FALSE);
									InvalidateRect(hwnd,&rcInfo[0],FALSE);
									InvalidateRect(hwnd,&rcInfo[3],FALSE);
								}
								//pushed again after pause
								iTimeCursor=0;
								wsprintf(strTime,"00:00:00/%02d:%02d:%02d", (maxTime/100)/60,(maxTime/100)%60,maxTime%100);			//total time
								InvalidateRect(GetTopWindow(hwnd),&rcInfo[1],FALSE);
							}
						break;
					case ID_LOOP:
						if(loop)
						{
							loop=FALSE;
						}
						else
						{
							loop=TRUE;
						}
						break;
					case ID_DOWN://-
						waveOutGetVolume(hWaveOut,&dwVolTemp);
						ia=LOWORD(dwVolTemp);		// store in wVolNow after mute cancellation
						ia-=512;
						wVolNow=(ia<0)?0:ia;
						waveOutSetVolume(hWaveOut,MAKELONG(wVolNow,wVolNow));

						wsprintf(strVol,"%03d/128",(wVolNow+1)/512);
						InvalidateRect(hwnd,&rcInfo[2],FALSE);
						break;
					case ID_UP:
						waveOutGetVolume(hWaveOut,&dwVolTemp);
						ia=LOWORD(dwVolTemp);		// store in wVolNow after mute cancellation
						ia+=512;
						wVolNow=(ia>0xFFFF)?0xFFFF:ia;
						waveOutSetVolume(hWaveOut,MAKELONG(wVolNow,wVolNow));

						wsprintf(strVol,"%03d/128",(wVolNow+1)/512);
						InvalidateRect(hwnd,&rcInfo[2],FALSE);
						break;
					case ID_EXITT:
					case ID_EXIT_EXIT:
						 KillTimer(hwnd,1);
						// SetWindowLong(hTrack, GWL_WNDPROC, (LONG)TrackProc); 
						// DestroyWindow(hTrack);
						ExitProcess(-1);
						DestroyWindow(hwnd);
						break;
				}
				return 0;
			/*case WM_HSCROLL:
				if( (HWND)lp == GetDlgItem( hwnd, IDC_SLIDER ) ){
					pos = SendMessage( (HWND)lp, TBM_GETPOS, 0, 0 );
				}
				return 0;*/
			case WM_DROPFILES:		//drag and drop for file
				DragQueryFile((HDROP)wp, 0, strFile, sizeof(strFile));
				DragFinish((HDROP)wp);

				//when open button is pushed
				if(open)
				{		
					play = FALSE;
					pause = FALSE;

					KillTimer(hwnd, 1);
					rcMove.left = rcInfo[0].left;
					iTimeCursor = 0;
			
					waveOutReset(hWaveOut);
					waveOutUnprepareHeader(hWaveOut, &whdr, sizeof(WAVEHDR));
					waveOutClose(hWaveOut);
					HeapFree(GetProcessHeap(), 0, whdr.lpData);
				}

				if(waveIn(strFile, &hWaveOut, &wfe, &whdr))
				{
					//finished abnormaly
					for(i = 0 ; i < sizeof(ptWaveL)/sizeof(ptWaveL[0]) ; i++)
					{
						ptWaveL[i].y = -10;		//default value
						ptWaveR[i].y = -10;		//default value
					}
					strFile[0] = NULL;
					strTime[0] = NULL;
					wsprintf(strState, "NoData");

					InvalidateRect(hwnd, &rcWave, FALSE);
					InvalidateRect(hwnd, &rcInfo[0], FALSE);
					InvalidateRect(hwnd, &rcInfo[1], FALSE);
					InvalidateRect(hwnd, &rcInfo[3], FALSE);
					return 0;
				}
				waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfe, (DWORD)hwnd, 0, CALLBACK_WINDOW);
				waveOutPrepareHeader(hWaveOut, &whdr, sizeof(WAVEHDR));

				wHalfMaxAmp=pow(2, wfe.wBitsPerSample - 1);	//half of the max amplitud
			
				for(i=0;i<sizeof(ptWaveL)/sizeof(ptWaveL[0]);i++)
					ptWaveL[i].y=250;		//screen center for wave

				if(wfe.nChannels == 2)
				{
					for(i = 0 ; i < sizeof(ptWaveR)/sizeof(ptWaveR[0]) ; i++)
						ptWaveR[i].y = 250;	//screen center for wave 
				}
				else
				{
					for(i = 0 ; i < sizeof(ptWaveR)/sizeof(ptWaveR[0]) ; i++)
						ptWaveR[i].y = -10;	//default value
				}

				wsprintf(strFile, "%s :- %d bits / %s / %d Hz", PathFindFileName(strFile), wfe.wBitsPerSample, (wfe.nChannels==2)?"stereo":"mono", wfe.nSamplesPerSec);

				SelectObject(hdc_mem, hFont[2]);
				GetTextExtentPoint32(hdc_mem, strFile, (int)strlen(strFile), &sizeFile);

				maxTime = 100*whdr.dwBufferLength/wfe.nAvgBytesPerSec;

				wsprintf(strTime,"00:00:00/%02d:%02d:%02d",
					(maxTime/100)/60,(maxTime/100)%60,maxTime%100);		//total time

				open=TRUE;
				wsprintf(strState, "ready");

				InvalidateRect(hwnd, &rcWave, FALSE);
				InvalidateRect(hwnd, &rcInfo[0], FALSE);
				InvalidateRect(hwnd, &rcInfo[1], FALSE);
				InvalidateRect(hwnd, &rcInfo[3], FALSE);
				return 0;
				
				case MM_WOM_DONE:		
					pause = FALSE;
					waveOutReset(hWaveOut);

					if(loop && play)
					{		
						iTimeCursor = 0;
						waveOutWrite(hWaveOut, &whdr, sizeof(WAVEHDR));
						return 0;
					}

					if(play)
					{		//play completed
						iTimeCursor = 600;
						wsprintf(strTime,"%02d:%02d:%02d/%02d:%02d:%02d",
							(maxTime/100)/60,(maxTime/100)%60,maxTime%100,			//current time
							(maxTime/100)/60,(maxTime/100)%60,maxTime%100);			//total time
					}

					for(i = 0 ; i < sizeof(ptWaveL)/sizeof(ptWaveL[0]) ; i++)
						ptWaveL[i].y=250;		//center for wave drawn 195

					if(wfe.nChannels == 2)
						for(i=0 ; i<sizeof(ptWaveR)/sizeof(ptWaveR[0]) ; i++)
							ptWaveR[i].y=250;	//center for wave drawn 195

					play = FALSE;
					rcMove.left = rcInfo[0].left;
					wsprintf(strState, "ready");
					KillTimer(hwnd, 1);

					InvalidateRect(hwnd, &rcWave, FALSE);
					InvalidateRect(hwnd, &rcInfo[0], FALSE);
					InvalidateRect(hwnd, &rcInfo[1], FALSE);
					InvalidateRect(hwnd, &rcInfo[3], FALSE);
					return 0;
				case WM_TIMER:
					rcMove.left-= 1;
					if(rcMove.left<-sizeFile.cx) rcMove.left = rcInfo[0].right;

					waveOutGetPosition(hWaveOut, &mmTime, sizeof(MMTIME));
					dwOffset = mmTime.u.cb;

					iTimeCursor = (double)dwOffset/whdr.dwBufferLength*600;		//change Cursor coordinate

					for(i = -612 ; i <= 612 ; i++) //-310 310
					{			//left
						s = 0;
						dw = dwOffset + i*wfe.nBlockAlign;
						if(0 <= dw && dw < whdr.dwBufferLength)
						{
							CopyMemory(&s, whdr.lpData+dw, wfe.wBitsPerSample/8);
							if(wfe.wBitsPerSample == 8) s-= 128;			// shift no volume(128) to 0
						}
						ptWaveL[i+612].y = 185*(-s)/wHalfMaxAmp + 250; //ptWaveL[i+310].y     + 195;
					}
					if(wfe.nChannels == 2)
					{			//stereo
						for(i = -612 ; i <= 612 ; i++)//-310 310
						{		//right
							s = 0;
							dw = dwOffset + i*wfe.nBlockAlign + wfe.wBitsPerSample/8;
							if(0 <= dw && dw < whdr.dwBufferLength)
							{
								CopyMemory(&s, whdr.lpData + dw, wfe.wBitsPerSample/8);
								if(wfe.wBitsPerSample == 8) s-=128;		//shift no volume(128) to 0
							}
							ptWaveR[i+612].y = 185*(-s)/wHalfMaxAmp + 250; //ptWaveR[i+310].y      +195
						}
					}

					dw = (double)dwOffset/wfe.nAvgBytesPerSec*100;

					wsprintf(strTime, "%02d:%02d:%02d/%02d:%02d:%02d",
						(dw/100)/60,(dw/100)%60,dw%100,						//current time
						(maxTime/100)/60,(maxTime/100)%60,maxTime%100);		//total time
					InvalidateRect(hwnd, &rcWave, FALSE);
					InvalidateRect(hwnd, &rcInfo[0], FALSE);
					InvalidateRect(hwnd, &rcInfo[1], FALSE);
					return 0;
				case WM_PAINT:
					hdc = BeginPaint(hwnd, &ps); 

					StretchDIBits(hdc_mem, 0, 0, iWidth, iHeight, 0, 0, iWidth, iHeight, lpPixel, &bmpInfo, DIB_RGB_COLORS, SRCCOPY);

					/////////////////////////////////////////
					SelectObject(hdc_mem, hFont[2]);
					SetTextColor(hdc_mem, RGB(255, 255, 0)); 
				
					DrawText(hdc_mem, strFile, (int)strlen(strFile), &rcMove, DT_SINGLELINE | DT_VCENTER);
					DrawText(hdc_mem,strTime, (int)strlen(strTime), &rcInfo[1], DT_SINGLELINE | DT_CENTER | DT_VCENTER);
					DrawText(hdc_mem, strVol, (int)strlen(strVol), &rcInfo[2], DT_SINGLELINE | DT_CENTER | DT_VCENTER);
					DrawText(hdc_mem, strState, (int)strlen(strState), &rcInfo[3], DT_SINGLELINE | DT_CENTER | DT_VCENTER);

					SelectObject(hdc_mem, hPenR);
					Polyline(hdc_mem, ptWaveR, sizeof(ptWaveR)/sizeof(ptWaveR[0]));

					SelectObject(hdc_mem, hPenL);
					Polyline(hdc_mem, ptWaveL, sizeof(ptWaveL)/sizeof(ptWaveL[0]));

					// measure when strFile is over limitation
					StretchDIBits(hdc_mem, 0, 450, 20, 20, 0, 10, 20, 20, lpPixel, &bmpInfo, DIB_RGB_COLORS, SRCCOPY);
					//////////////////////////////////////////////////////

					BitBlt(hdc, 0, 0, iWidth, iHeight, hdc_mem, 0, 0, SRCCOPY);
				
				    EndPaint(hwnd, &ps);

					return 0;
			case WM_DESTROY:
				SetWindowLong(hTrack, GWL_WNDPROC, (LONG)TrackProc); 
				DestroyWindow(hTrack);
				PostQuitMessage(0);
				return 0;
			default:
				return DefWindowProc(hwnd, msg, wp, lp);
		}

		return 0;
}
예제 #23
0
Exec_stat MCAudioClip::getprop(uint4 parid, Properties which, MCExecPoint &ep, Boolean effective)
{
	switch (which)
	{
#ifdef /* MCAudioClip::getprop */ LEGACY_EXEC
	case P_SIZE:
		ep.setint(size);
		break;
	case P_PLAY_DESTINATION:
	case P_PLAY_LOUDNESS:
		if (this == MCtemplateaudio)
		{
			extern bool MCSystemGetPlayLoudness(uint2& r_loudness);
#ifdef _MOBILE
			if (MCSystemGetPlayLoudness(loudness))
#else
			if (false)
#endif
				;
			else if (!supported)
				loudness = 0;
			else
			{
#if defined _WINDOWS
				if (hwaveout == NULL)
				{
					WAVEFORMATEX pwfx;
					pwfx.wFormatTag = WAVE_FORMAT_PCM;
					pwfx.nChannels = 1;
					pwfx.nSamplesPerSec = 22050;
					pwfx.nAvgBytesPerSec = 22050;
					pwfx.nBlockAlign = 1;
					pwfx.wBitsPerSample = 8;
					pwfx.cbSize = 0;
					if (waveOutOpen(&hwaveout, WAVE_MAPPER, &pwfx, 0, 0, CALLBACK_NULL
					                | WAVE_ALLOWSYNC) == MMSYSERR_NOERROR)
					{
						DWORD v;
						waveOutGetVolume(hwaveout, &v);
						loudness = MCU_min((uint2)((v & 0xFFFF) * 100 / 0xFFFF) + 1, 100);
						waveOutClose(hwaveout);
						hwaveout = NULL;
					}
				}
#elif defined _MACOSX
				long volume;
				GetDefaultOutputVolume(&volume);
				loudness = (HiWord(volume) + LoWord(volume)) * 50 / 255;
#elif defined TARGET_PLATFORM_LINUX
				if ( x11audio != NULL)
					loudness = x11audio -> getloudness();
#endif
			}
		}
		if (which == P_PLAY_DESTINATION)
		{
			if (flags & F_EXTERNAL)
				ep.setstaticcstring("external");
			else
				ep.setstaticcstring("internal");
		}
		else
			ep.setint(loudness);
		break;
#endif /* MCAudioClip::getprop */ 
	default:
		return MCObject::getprop(parid, which, ep, effective);
	}
	return ES_NORMAL;
}
// Update all notifications except those that RegistryNotifyWindow succeeded.
// Return TRUE if at least one has changed.
BOOL CNotifications::PollingUpdate()
{
	BOOL changed = FALSE;

	for (int i = 0; i < MAXDWORDNOTIFICATION; i++) {
		if (!dwHrNotify[i] || i == SN_POWERBATTERYSTATE) {
			DWORD value = 0;
			if (i == SN_POWERBATTERYSTATE) {
				SYSTEM_POWER_STATUS_EX pwrStatus;
				if (GetSystemPowerStatusEx(&pwrStatus, TRUE)) {
					value = pwrStatus.BatteryLifePercent << 16;
					value |= pwrStatus.BatteryFlag;
				} else {
					value = BATTERY_PERCENTAGE_UNKNOWN << 16;
				}
			} else if (i == SN_VOLUME) {
				waveOutGetVolume(0, &value);
			} else {
				LoadDwordSetting(SN_DW[i].hKey, &value, SN_DW[i].pszSubKey, SN_DW[i].pszValueName, 0);
			}
			if (dwNotifications[i] != value) {
				dwNotifications[i] = value;
				dwNotificationsChanged[i] = TRUE;
				changed = TRUE;
			} else {
				dwNotificationsChanged[i] = FALSE;
			}
		}
	}

	for (int i = 0; i < MAXSTRINGNOTIFICATION; i++) {
		TCHAR value[MAX_PATH];
		if (!szHrNotify[i]) {
			LoadTextSetting(SN_SZ[i].hKey, value, SN_SZ[i].pszSubKey, SN_SZ[i].pszValueName, L"");
			if (lstrcmp(szNotifications[i], value) != 0) {
				wcscpy(szNotifications[i], value);
				szNotificationsChanged[i] = TRUE;
				changed = TRUE;
			} else {
				szNotificationsChanged[i] = FALSE;
			}
		}
	}

	//if (!ftHrNotify[SN_TIME] || !ftHrNotify[SN_DATE]) {
		SYSTEMTIME st_new;
		GetLocalTime(&st_new);
		if (st.wMinute != st_new.wMinute || st.wHour != st_new.wHour) {
			ftNotificationsChanged[SN_TIME] = TRUE;
			changed = TRUE;
		} else {
			ftNotificationsChanged[SN_TIME] = FALSE;
		}
		if (st.wDay != st_new.wDay || st.wDayOfWeek != st_new.wDayOfWeek) {
			ftNotificationsChanged[SN_DATE] = TRUE;
			changed = TRUE;
		} else {
			ftNotificationsChanged[SN_DATE] = FALSE;
		}
		memcpy(&st, &st_new, sizeof(SYSTEMTIME));
	//}

	if (!ftHrNotify[SN_ALARMS_NEXT]) {
		FILETIME ftAlarmsNext_new;
		LoadDateTimeSetting(SN_FT[SN_ALARMS_NEXT].hKey, &ftAlarmsNext_new, SN_FT[SN_ALARMS_NEXT].pszSubKey, SN_FT[SN_ALARMS_NEXT].pszValueName);
		if (CompareFileTime(&ftAlarmsNext_new , &ftAlarmsNext) != 0) {
			memcpy(&ftAlarmsNext, &ftAlarmsNext_new, sizeof(FILETIME));
			ftNotificationsChanged[SN_ALARMS_NEXT] = TRUE;
			changed = TRUE;
		} else {
			ftNotificationsChanged[SN_ALARMS_NEXT] = FALSE;
		}
	}

	int wss = GetWifiSignalStrength();
	if (wss != wifiSignalStrength) {
		wifiSignalStrength = wss;
		wifiSignalStrength_changed = TRUE;
	} else {
		wifiSignalStrength_changed = FALSE;
	}

	MEMORYSTATUS mems;
	mems.dwLength = sizeof(MEMORYSTATUS);
	GlobalMemoryStatus(&mems);
	if (mems.dwMemoryLoad != memoryStatus.dwMemoryLoad) {
		memory_changed = TRUE;
		changed = TRUE;
	} else {
		memory_changed = FALSE;
	}
	memcpy(&memoryStatus, &mems, sizeof(MEMORYSTATUS));

	return changed;
}
예제 #25
0
파일: sound.c 프로젝트: GiantGeorgeGo/emacs
static int
do_play_sound (const char *psz_file, unsigned long ui_volume)
{
  int i_result = 0;
  MCIERROR mci_error = 0;
  char sz_cmd_buf_a[520];
  char sz_ret_buf_a[520];
  MMRESULT mm_result = MMSYSERR_NOERROR;
  unsigned long ui_volume_org = 0;
  BOOL b_reset_volume = FALSE;
  char warn_text[560];

  /* Since UNICOWS.DLL includes only a stub for mciSendStringW, we
     need to encode the file in the ANSI codepage on Windows 9X even
     if w32_unicode_filenames is non-zero.  */
  if (w32_major_version <= 4 || !w32_unicode_filenames)
    {
      char fname_a[MAX_PATH], shortname[MAX_PATH], *fname_to_use;

      filename_to_ansi (psz_file, fname_a);
      fname_to_use = fname_a;
      /* If the file name is not encodable in ANSI, try its short 8+3
	 alias.  This will only work if w32_unicode_filenames is
	 non-zero.  */
      if (_mbspbrk ((const unsigned char *)fname_a,
		    (const unsigned char *)"?"))
	{
	  if (w32_get_short_filename (psz_file, shortname, MAX_PATH))
	    fname_to_use = shortname;
	  else
	    mci_error = MCIERR_FILE_NOT_FOUND;
	}

      if (!mci_error)
	{
	  memset (sz_cmd_buf_a, 0, sizeof (sz_cmd_buf_a));
	  memset (sz_ret_buf_a, 0, sizeof (sz_ret_buf_a));
	  sprintf (sz_cmd_buf_a,
		   "open \"%s\" alias GNUEmacs_PlaySound_Device wait",
		   fname_to_use);
	  mci_error = mciSendStringA (sz_cmd_buf_a,
				      sz_ret_buf_a, sizeof (sz_ret_buf_a), NULL);
	}
    }
  else
    {
      wchar_t sz_cmd_buf_w[520];
      wchar_t sz_ret_buf_w[520];
      wchar_t fname_w[MAX_PATH];

      filename_to_utf16 (psz_file, fname_w);
      memset (sz_cmd_buf_w, 0, sizeof (sz_cmd_buf_w));
      memset (sz_ret_buf_w, 0, sizeof (sz_ret_buf_w));
      /* _swprintf is not available on Windows 9X, so we construct the
	 UTF-16 command string by hand.  */
      wcscpy (sz_cmd_buf_w, L"open \"");
      wcscat (sz_cmd_buf_w, fname_w);
      wcscat (sz_cmd_buf_w, L"\" alias GNUEmacs_PlaySound_Device wait");
      mci_error = mciSendStringW (sz_cmd_buf_w,
				  sz_ret_buf_w, ARRAYELTS (sz_ret_buf_w) , NULL);
    }
  if (mci_error != 0)
    {
      strcpy (warn_text,
	      "mciSendString: 'open' command failed to open sound file ");
      strcat (warn_text, psz_file);
      SOUND_WARNING (mciGetErrorString, mci_error, warn_text);
      i_result = (int) mci_error;
      return i_result;
    }
  if ((ui_volume > 0) && (ui_volume != UINT_MAX))
    {
      mm_result = waveOutGetVolume ((HWAVEOUT) WAVE_MAPPER, &ui_volume_org);
      if (mm_result == MMSYSERR_NOERROR)
        {
          b_reset_volume = TRUE;
          mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume);
          if (mm_result != MMSYSERR_NOERROR)
            {
	      SOUND_WARNING (waveOutGetErrorText, mm_result,
			     "waveOutSetVolume: failed to set the volume level"
			     " of the WAVE_MAPPER device.\n"
			     "As a result, the user selected volume level will"
			     " not be used.");
            }
        }
      else
        {
          SOUND_WARNING (waveOutGetErrorText, mm_result,
			 "waveOutGetVolume: failed to obtain the original"
                         " volume level of the WAVE_MAPPER device.\n"
                         "As a result, the user selected volume level will"
                         " not be used.");
        }
    }
  memset (sz_cmd_buf_a, 0, sizeof (sz_cmd_buf_a));
  memset (sz_ret_buf_a, 0, sizeof (sz_ret_buf_a));
  strcpy (sz_cmd_buf_a, "play GNUEmacs_PlaySound_Device wait");
  mci_error = mciSendStringA (sz_cmd_buf_a, sz_ret_buf_a, sizeof (sz_ret_buf_a),
			      NULL);
  if (mci_error != 0)
    {
      strcpy (warn_text,
	      "mciSendString: 'play' command failed to play sound file ");
      strcat (warn_text, psz_file);
      SOUND_WARNING (mciGetErrorString, mci_error, warn_text);
      i_result = (int) mci_error;
    }
  memset (sz_cmd_buf_a, 0, sizeof (sz_cmd_buf_a));
  memset (sz_ret_buf_a, 0, sizeof (sz_ret_buf_a));
  strcpy (sz_cmd_buf_a, "close GNUEmacs_PlaySound_Device wait");
  mci_error = mciSendStringA (sz_cmd_buf_a, sz_ret_buf_a, sizeof (sz_ret_buf_a),
			      NULL);
  if (b_reset_volume == TRUE)
    {
      mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume_org);
      if (mm_result != MMSYSERR_NOERROR)
        {
          SOUND_WARNING (waveOutGetErrorText, mm_result,
			 "waveOutSetVolume: failed to reset the original"
                         " volume level of the WAVE_MAPPER device.");
        }
    }
  return i_result;
}
예제 #26
0
int MyHideWindows()
{
	NOTIFYICONDATA nid; 
	/*if(sOP.bUseBKMouse == 1)
	{
		MoveWindow2BK();
		return 1;;
	}*/

	if (bHideWindows == 1)	
	{
		if (sOP.bDisableSound == 1)
		{
			waveOutGetVolume(0,&dwOldVolume);
			waveOutSetVolume(0,0);
		}
		EnableWindow(hAll,FALSE);
		EnableWindow(hLV,FALSE);


		//EnumWindows((WNDENUMPROC)EnumWindowsFunc,0);
		for(int i1 = 0;i1<iBaSW_dll;i1++)
		{
			if (sW_dll[i1].bReserved != 1)
			{

				ShowWindow(sW_dll[i1].hWnd,SW_HIDE);
				sW_dll[i1].bHide = 1;
				if(sW_dll[i1].iHasTrayIcon == 1)
				{
					nid.cbSize = sizeof(NOTIFYICONDATA);
					nid.hWnd = sW_dll[i1].trayicon.hwnd;
					nid.uID = sW_dll[i1].trayicon.uID;
					Shell_NotifyIcon(NIM_DELETE,&nid);

				}
			}
		}   

		bHideWindows = 0;
	}
	else if (bHideWindows == 0)
	{
		if (sOP.bUsePassword == 1)
		{
			if(hDlg_Validate != NULL && IsWindow(hDlg_Validate))
			{
				return 1;
			}
			if (DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG_VALIDATE),NULL,(DLGPROC)ValidateProc) == 0)
			{
				return 1;
			}
		}

		EnableWindow(hAll,TRUE);
		EnableWindow(hLV,TRUE);

		if (dwOldVolume != 0)
		{
			waveOutSetVolume(0,dwOldVolume);
			dwOldVolume = 0;
		}
		//2.2 method ///
		for (int i = 0;i < iBaSW_dll;i++)
		{
			ShowWindow(sW_dll[i].hWnd,SW_SHOW);
			if(sW_dll[i].iHasTrayIcon == 1 && sW_dll[i].bHide == 1)
			{
				nid.cbSize           = sizeof(NOTIFYICONDATA);
				nid.uFlags           = NIF_ICON|NIF_TIP|NIF_MESSAGE;
				nid.uID              = sW_dll[i].trayicon.uID;
				nid.hIcon            = sW_dll[i].trayicon.hIcon;
				nid.hWnd             = sW_dll[i].trayicon.hwnd;
				strcpy(nid.szTip,(const char *)sW_dll[i].cIconTip);
				//wcstombs(nid.szTip,sW_dll[i].cIconTip,1022);
				nid.uCallbackMessage = sW_dll[i].trayicon.uCallbackMessage;
				Shell_NotifyIcon(NIM_ADD,&nid);				
			}
			sW_dll[i].bHide = 0;
		}
		bHideWindows = 1;


 
		/*iWin --;
		while(iWin >= 0)
		{
			ShowWindow(WindowsArray[iWin],SW_SHOW);
			iWin --;
		}
		iWin = 0;
		//pFT1->psNID ->hIcon = pFT1->hIcon1;
		//strcpy(pFT1->psNID ->szTip,"隐身专家(未隐藏窗口)");
		//Shell_NotifyIcon(NIM_MODIFY,pFT1->psNID);*/
	}
	return 1;
}
예제 #27
0
static int winsnd_open(WinSndData *device, int devnumber, int bits,int stereo, int rate, int *minsz)
{
    MMRESULT mr = NOERROR;
    DWORD dwFlag;
    int i;
    int channel = 1;
    if (stereo>0)
        channel = stereo;
	device->wfx.wFormatTag = WAVE_FORMAT_PCM;
	device->wfx.cbSize = 0;
	device->wfx.nAvgBytesPerSec = 16000;
	device->wfx.nBlockAlign = 2;
	device->wfx.nChannels = channel;
	device->wfx.nSamplesPerSec = rate; /* 8000; */
	device->wfx.wBitsPerSample = bits;


    dwFlag = CALLBACK_FUNCTION;
    if (devnumber != WAVE_MAPPER)
        dwFlag = WAVE_MAPPED | CALLBACK_FUNCTION;
    mr = waveOutOpen (&(device->waveoutdev), devnumber, &(device->wfx), (DWORD) SpeakerCallback,
                    (DWORD)device, dwFlag);
    if (mr != NOERROR)
    {
        ms_warning("Failed to open device: trying default device. (waveOutOpen:0x%i)", mr);
        dwFlag = CALLBACK_FUNCTION;
        mr = waveOutOpen (&(device->waveoutdev), WAVE_MAPPER, &(device->wfx), (DWORD) SpeakerCallback,
                        (DWORD)device, dwFlag);
    }
    if (mr != NOERROR)
    {
        ms_warning("Failed to open windows sound device. (waveOutOpen:0x%i)", mr);
        return -1;
    }

#if 0
#define MM_WOM_SETSECONDARYGAINCLASS   (WM_USER)
#define MM_WOM_SETSECONDARYGAINLIMIT   (WM_USER+1)
#define MM_WOM_FORCESPEAKER            (WM_USER+2)

	bool bSpeaker=TRUE;
	mr = waveOutMessage(device->waveoutdev, MM_WOM_FORCESPEAKER, bSpeaker, 0);
    if (mr != NOERROR)
    {
        ms_warning("Failed to use earphone. (waveOutMessage:0x%i)", mr);
        return -1;
    }

	typedef HRESULT (* _SetSpeakerMode)(DWORD mode);
	_SetSpeakerMode pfnSetSpeakerMode;

	HINSTANCE hDll = LoadLibrary(L"\\windows\\ossvcs.dll");
	//_debug(L"ossvcs.dll h=%X",hDll);
	pfnSetSpeakerMode = (_SetSpeakerMode)GetProcAddress(hDll,(LPCTSTR)218);
	if (pfnSetSpeakerMode)
	{
	//_debug(L"SetSpeakerMode imported.");
	DWORD sm = 0;
	//_debug(L"SpeakerMode set to %d", sm);
	pfnSetSpeakerMode(sm);
	}
	//else
	//_debug(L"pfnSetSpeakerMode import failed.");
	FreeLibrary(hDll);
#endif

#ifdef CONTROLVOLUME
	mr = waveOutGetVolume(device->waveoutdev, &device->dwOldVolume);
    if (mr != NOERROR)
    {
        ms_warning("Failed to get volume device. (waveOutGetVolume:0x%i)", mr);
    }

	mr = waveOutSetVolume(device->waveoutdev, 0xFFFFFFFF);
    if (mr != NOERROR)
    {
        ms_warning("Failed to set volume device. (waveOutSetVolume:0x%i)", mr);
    }
#endif

    /* prepare windows buffers */

    for (i = 0; i < MAX_WAVEHDR; i++)
    {
        memset (&(device->waveouthdr[i]), 0, sizeof (device->waveouthdr[i]));
        device->waveouthdr[i].lpData = device->waveoutbuffer[i];
        /* BUG: on ne connait pas la taille des frames a recevoir...
        on utilise enc_frame_per_packet au lien de dec_frame_per_packet */

        device->waveouthdr[i].dwBufferLength = device->rate/8000 * WINSND_BUFLEN;
        /* 480 pour 98 (speex) */
        device->waveouthdr[i].dwFlags = 0;
        device->waveouthdr[i].dwUser = i;

        mr = waveOutPrepareHeader (device->waveoutdev, &(device->waveouthdr[i]),
            sizeof (device->waveouthdr[i]));
        if (mr != MMSYSERR_NOERROR){
            ms_warning("Failed to prepare windows sound device. (waveOutPrepareHeader:0x%i)", mr);
        }
        else
        {
            ms_message("Sound Header prepared %i for windows sound device. (waveOutPrepareHeader)", i);
        }
    }


    /* Init Microphone device */
    dwFlag = CALLBACK_FUNCTION;
    if (devnumber != WAVE_MAPPER)
        dwFlag = WAVE_MAPPED | CALLBACK_FUNCTION;
    mr = waveInOpen (&(device->waveindev), devnumber, &(device->wfx),
                (DWORD) WaveInCallback, (DWORD)device, dwFlag);
    if (mr != NOERROR)
    {
        ms_warning("Failed to open device: trying default device. (waveInOpen:0x%i)", mr);
        dwFlag = CALLBACK_FUNCTION;
        mr = waveInOpen (&(device->waveindev), WAVE_MAPPER, &(device->wfx),
                    (DWORD) WaveInCallback, (DWORD)device, dwFlag);
    }

    if (mr != NOERROR)
    {
        ms_warning("Failed to prepare windows sound device. (waveInOpen:0x%i)", mr);
        return -1;
    }



    for (i = 0; i < MAX_WAVEHDR; i++)
    {
        memset (&(device->waveinhdr[i]), 0, sizeof (device->waveinhdr[i]));
        device->waveinhdr[i].lpData = device->waveinbuffer[i];
        /* frameSize */
        device->waveinhdr[i].dwBufferLength = device->rate/8000 * WINSND_BUFLEN;
        device->waveinhdr[i].dwFlags = 0;
        device->waveinhdr[i].dwUser = i;
        mr = waveInPrepareHeader (device->waveindev, &(device->waveinhdr[i]),
            sizeof (device->waveinhdr[i]));
        if (mr == MMSYSERR_NOERROR){
            mr = waveInAddBuffer (device->waveindev, &(device->waveinhdr[i]),
                sizeof (device->waveinhdr[i]));
            if (mr == MMSYSERR_NOERROR)
            {
                ms_message("Sound Header prepared %i for windows sound device. (waveInAddBuffer)", i);
            }
            else
            {
                ms_warning("Failed to prepare windows sound device. (waveInAddBuffer:0x%i)", mr);
            }
        }
        else
        {
            ms_warning("Failed to prepare windows sound device. (waveInPrepareHeader:0x%i)", mr);
        }
    }

#ifndef DISABLE_SPEEX
#if 0
	device->pst = speex_preprocess_state_init((device->rate/8000 * 320)/2, device->rate);
	if (device->pst!=NULL) {
		float f;
		i=1;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_VAD, &i);
		i=1;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_DENOISE, &i);
		i=0;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_AGC, &i);
		f=8000;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_AGC_LEVEL, &f);
		i=0;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_DEREVERB, &i);
		f=.4;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
		f=.3;
		speex_preprocess_ctl(device->pst, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
	}
#endif
#endif

	mr = waveInStart (device->waveindev);
    if (mr != MMSYSERR_NOERROR)
    {
        ms_warning("Failed to start recording on windows sound device. (waveInStart:0x%i)", mr);
        return -1;
    }

	*minsz=device->rate/8000 * 320;
	return 0;
}