BOOL CALLBACK SoundtouchCfg::DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { int wmId; //wchar_t temp[384]={0}; switch(uMsg) { case WM_PAINT: return FALSE; case WM_INITDIALOG: { INIT_SLIDER( IDC_SEQLEN_SLIDER, SequenceLen_Min, SequenceLen_Max, 20, 5, 1 ); INIT_SLIDER( IDC_SEEKWIN_SLIDER, SeekWindow_Min, SeekWindow_Max, 5, 2, 1 ); INIT_SLIDER( IDC_OVERLAP_SLIDER, Overlap_Min, Overlap_Max, 3, 2, 1 ); SendDialogMsg( hWnd, IDC_SEQLEN_SLIDER, TBM_SETPOS, TRUE, SequenceLenMS ); SendDialogMsg( hWnd, IDC_SEEKWIN_SLIDER, TBM_SETPOS, TRUE, SeekWindowMS ); SendDialogMsg( hWnd, IDC_OVERLAP_SLIDER, TBM_SETPOS, TRUE, OverlapMS ); } case WM_COMMAND: wmId = LOWORD(wParam); // Parse the menu selections: if( wmId == IDOK ) { SequenceLenMS = (int)SendDialogMsg( hWnd, IDC_SEQLEN_SLIDER, TBM_GETPOS, 0, 0 ); SeekWindowMS = (int)SendDialogMsg( hWnd, IDC_SEEKWIN_SLIDER, TBM_GETPOS, 0, 0 ); OverlapMS = (int)SendDialogMsg( hWnd, IDC_OVERLAP_SLIDER, TBM_GETPOS, 0, 0 ); ClampValues(); WriteSettings(); EndDialog(hWnd,0); } else if( wmId == IDC_RESET_DEFAULTS ) { SequenceLenMS = 30; SeekWindowMS = 20; OverlapMS = 10; SendDialogMsg( hWnd, IDC_SEQLEN_SLIDER, TBM_SETPOS, TRUE, SequenceLenMS ); SendDialogMsg( hWnd, IDC_SEEKWIN_SLIDER, TBM_SETPOS, TRUE, SeekWindowMS ); SendDialogMsg( hWnd, IDC_OVERLAP_SLIDER, TBM_SETPOS, TRUE, OverlapMS ); } else if( wmId == IDCANCEL ) { EndDialog(hWnd,0); } break; case WM_HSCROLL: DoHandleScrollMessage( hWnd, wParam, lParam ); break; default: return FALSE; } return TRUE; }
BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { int wmId,wmEvent; wchar_t temp[384]={0}; switch(uMsg) { case WM_PAINT: return FALSE; case WM_INITDIALOG: { SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_RESETCONTENT,0,0 ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_ADDSTRING,0,(LPARAM) L"0 - Nearest (fastest/bad quality)" ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_ADDSTRING,0,(LPARAM) L"1 - Linear (simple/okay sound)" ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_ADDSTRING,0,(LPARAM) L"2 - Cubic (artificial highs)" ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_ADDSTRING,0,(LPARAM) L"3 - Hermite (better highs)" ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_ADDSTRING,0,(LPARAM) L"4 - Catmull-Rom (PS2-like/slow)" ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_SETCURSEL,Interpolation,0 ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_RESETCONTENT,0,0 ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"TimeStretch (Recommended)" ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"Async Mix (Breaks some games!)" ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"None (Audio can skip.)" ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_SETCURSEL,SynchMode,0 ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_RESETCONTENT,0,0 ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Stereo (none, default)" ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Quadrafonic" ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Surround 5.1" ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Surround 7.1" ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_SETCURSEL,numSpeakers,0 ); SendDialogMsg( hWnd, IDC_OUTPUT, CB_RESETCONTENT,0,0 ); int modidx = 0; while( mods[modidx] != NULL ) { swprintf_s( temp, 72, L"%d - %s", modidx, mods[modidx]->GetLongName() ); SendDialogMsg( hWnd, IDC_OUTPUT, CB_ADDSTRING,0,(LPARAM)temp ); ++modidx; } SendDialogMsg( hWnd, IDC_OUTPUT, CB_SETCURSEL, OutputModule, 0 ); double minlat = (SynchMode == 0)?LATENCY_MIN_TS:LATENCY_MIN; int minexp = (int)(pow( minlat+1, 1.0/3.0 ) * 128.0); int maxexp = (int)(pow( (double)LATENCY_MAX+2, 1.0/3.0 ) * 128.0); INIT_SLIDER( IDC_LATENCY_SLIDER, minexp, maxexp, 200, 42, 1 ); SendDialogMsg( hWnd, IDC_LATENCY_SLIDER, TBM_SETPOS, TRUE, (int)((pow( (double)SndOutLatencyMS, 1.0/3.0 ) * 128.0) + 1) ); swprintf_s(temp,L"%d ms (avg)",SndOutLatencyMS); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL),temp); int configvol = (int)(FinalVolume * 100 + 0.5f); INIT_SLIDER( IDC_VOLUME_SLIDER, 0, 100, 10, 42, 1 ); SendDialogMsg( hWnd, IDC_VOLUME_SLIDER, TBM_SETPOS, TRUE, configvol ); swprintf_s(temp,L"%d%%",configvol); SetWindowText(GetDlgItem(hWnd,IDC_VOLUME_LABEL),temp); EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), (SynchMode == 0) ); EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_DEBUG ), DebugEnabled ); SET_CHECK(IDC_EFFECTS_DISABLE, EffectsDisabled); SET_CHECK(IDC_DEALIASFILTER, postprocess_filter_dealias); SET_CHECK(IDC_DEBUG_ENABLE, DebugEnabled); SET_CHECK(IDC_DSP_ENABLE, dspPluginEnabled); } break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: { double res = ((int)SendDialogMsg( hWnd, IDC_LATENCY_SLIDER, TBM_GETPOS, 0, 0 )) / 128.0; SndOutLatencyMS = (int)pow( res, 3.0 ); Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX ); FinalVolume = (float)(SendDialogMsg( hWnd, IDC_VOLUME_SLIDER, TBM_GETPOS, 0, 0 )) / 100; Interpolation = (int)SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_GETCURSEL,0,0 ); OutputModule = (int)SendDialogMsg( hWnd, IDC_OUTPUT, CB_GETCURSEL,0,0 ); SynchMode = (int)SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_GETCURSEL,0,0 ); numSpeakers = (int)SendDialogMsg( hWnd, IDC_SPEAKERS, CB_GETCURSEL,0,0 ); WriteSettings(); EndDialog(hWnd,0); } break; case IDCANCEL: EndDialog(hWnd,0); break; case IDC_OUTCONF: { const int module = (int)SendMessage(GetDlgItem(hWnd,IDC_OUTPUT),CB_GETCURSEL,0,0); if( mods[module] == NULL ) break; mods[module]->Configure((uptr)hWnd); } break; case IDC_OPEN_CONFIG_DEBUG: { // Quick Hack -- DebugEnabled is re-loaded with the DebugConfig's API, // so we need to override it here: bool dbgtmp = DebugEnabled; DebugConfig::OpenDialog(); DebugEnabled = dbgtmp; } break; case IDC_SYNCHMODE: { if(wmEvent == CBN_SELCHANGE) { int sMode = (int)SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_GETCURSEL,0,0 ); double minlat = (sMode == 0)?LATENCY_MIN_TS:LATENCY_MIN; int minexp = (int)(pow( minlat+1, 1.0/3.0 ) * 128.0); int maxexp = (int)(pow( (double)LATENCY_MAX+2, 1.0/3.0 ) * 128.0); INIT_SLIDER( IDC_LATENCY_SLIDER, minexp, maxexp, 200, 42, 1 ); int curpos = (int)SendMessage(GetDlgItem( hWnd, IDC_LATENCY_SLIDER ),TBM_GETPOS,0,0); double res = pow( curpos / 128.0, 3.0 ); curpos = (int)res; swprintf_s(temp,L"%d ms (avg)",curpos); SetDlgItemText(hWnd,IDC_LATENCY_LABEL,temp); } } break; case IDC_OPEN_CONFIG_SOUNDTOUCH: SoundtouchCfg::OpenDialog( hWnd ); break; HANDLE_CHECK(IDC_EFFECTS_DISABLE,EffectsDisabled); HANDLE_CHECK(IDC_DEALIASFILTER,postprocess_filter_dealias); HANDLE_CHECK(IDC_DSP_ENABLE,dspPluginEnabled); // Fixme : Eh, how to update this based on drop list selections? :p // IDC_TS_ENABLE already deleted! //HANDLE_CHECKNB(IDC_TS_ENABLE,timeStretchEnabled); // EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), timeStretchEnabled ); break; HANDLE_CHECKNB(IDC_DEBUG_ENABLE,DebugEnabled); DebugConfig::EnableControls( hWnd ); EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_DEBUG ), DebugEnabled ); break; default: return FALSE; } break; case WM_HSCROLL: { wmEvent = LOWORD(wParam); HWND hwndDlg = (HWND)lParam; // TB_THUMBTRACK passes the curpos in wParam. Other messages // have to use TBM_GETPOS, so they will override this assignment (see below) int curpos = HIWORD( wParam ); switch( wmEvent ) { //case TB_ENDTRACK: //case TB_THUMBPOSITION: case TB_LINEUP: case TB_LINEDOWN: case TB_PAGEUP: case TB_PAGEDOWN: curpos = (int)SendMessage(hwndDlg,TBM_GETPOS,0,0); case TB_THUMBTRACK: Clampify( curpos, (int)SendMessage(hwndDlg,TBM_GETRANGEMIN,0,0), (int)SendMessage(hwndDlg,TBM_GETRANGEMAX,0,0) ); SendMessage((HWND)lParam,TBM_SETPOS,TRUE,curpos); if( hwndDlg == GetDlgItem( hWnd, IDC_LATENCY_SLIDER ) ) { double res = pow( curpos / 128.0, 3.0 ); curpos = (int)res; swprintf_s(temp,L"%d ms (avg)",curpos); SetDlgItemText(hWnd,IDC_LATENCY_LABEL,temp); } if( hwndDlg == GetDlgItem( hWnd, IDC_VOLUME_SLIDER ) ) { swprintf_s(temp,L"%d%%",curpos); SetDlgItemText(hWnd,IDC_VOLUME_LABEL,temp); } break; default: return FALSE; } } break; default: return FALSE; } return TRUE; }
BOOL CALLBACK DSound51::ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { int wmId,wmEvent; int tSel=0; switch(uMsg) { case WM_INITDIALOG: haveGuid = ! FAILED(GUIDFromString(Config_DSound51.Device,&DevGuid)); SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_RESETCONTENT,0,0); ndevs=0; DirectSoundEnumerate(DSEnumCallback,NULL); tSel=-1; for(int i=0;i<ndevs;i++) { SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_ADDSTRING,0,(LPARAM)devices[i].name); if(haveGuid && IsEqualGUID(devices[i].guid,DevGuid)) { tSel=i; } } if(tSel>=0) { SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_SETCURSEL,tSel,0); } INIT_SLIDER(IDC_LEFT_GAIN_SLIDER,0,512,64,16,8); INIT_SLIDER(IDC_RIGHT_GAIN_SLIDER,0,512,64,16,8); INIT_SLIDER(IDC_RLEFT_GAIN_SLIDER,0,512,64,16,8); INIT_SLIDER(IDC_RRIGHT_GAIN_SLIDER,0,512,64,16,8); INIT_SLIDER(IDC_CENTER_GAIN_SLIDER,0,512,64,16,8); INIT_SLIDER(IDC_LFE_SLIDER,0,512,64,16,8); INIT_SLIDER(IDC_LR_CENTER_SLIDER,0,512,64,16,8); AssignSliderValue( hWnd, IDC_LEFT_GAIN_SLIDER, IDC_LEFT_GAIN_EDIT, Config_DSound51.GainL ); AssignSliderValue( hWnd, IDC_RIGHT_GAIN_SLIDER, IDC_RIGHT_GAIN_EDIT, Config_DSound51.GainR ); AssignSliderValue( hWnd, IDC_RLEFT_GAIN_SLIDER, IDC_RLEFT_GAIN_EDIT, Config_DSound51.GainSL ); AssignSliderValue( hWnd, IDC_RRIGHT_GAIN_SLIDER, IDC_RRIGHT_GAIN_EDIT, Config_DSound51.GainSR ); AssignSliderValue( hWnd, IDC_CENTER_GAIN_SLIDER, IDC_CENTER_GAIN_EDIT, Config_DSound51.GainC); AssignSliderValue( hWnd, IDC_LFE_SLIDER, IDC_LFE_EDIT, Config_DSound51.GainLFE); AssignSliderValue( hWnd, IDC_LR_CENTER_SLIDER, IDC_LR_CENTER_EDIT, Config_DSound51.AddCLR ); char temp[128]; INIT_SLIDER( IDC_BUFFERS_SLIDER, 2, MAX_BUFFER_COUNT, 2, 1, 1 ); SendMessage(GetDlgItem(hWnd,IDC_BUFFERS_SLIDER),TBM_SETPOS,TRUE,Config_DSound51.NumBuffers); sprintf_s(temp, 128, "%d (%d ms latency)",Config_DSound51.NumBuffers, 1000 / (96000 / (Config_DSound51.NumBuffers * BufferSize))); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL2),temp); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: { int i = (int)SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_GETCURSEL,0,0); if(!devices[i].hasGuid) { Config_DSound51.Device[0]=0; // clear device name to "" } else { sprintf_s(Config_DSound51.Device,256,"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", devices[i].guid.Data1, devices[i].guid.Data2, devices[i].guid.Data3, devices[i].guid.Data4[0], devices[i].guid.Data4[1], devices[i].guid.Data4[2], devices[i].guid.Data4[3], devices[i].guid.Data4[4], devices[i].guid.Data4[5], devices[i].guid.Data4[6], devices[i].guid.Data4[7] ); Config_DSound51.NumBuffers = GetSliderValue( hWnd, IDC_BUFFERS_SLIDER ); Config_DSound51.GainL = GetSliderValue( hWnd, IDC_LEFT_GAIN_SLIDER ); Config_DSound51.GainR = GetSliderValue( hWnd, IDC_RIGHT_GAIN_SLIDER ); Config_DSound51.GainSL = GetSliderValue( hWnd, IDC_RLEFT_GAIN_SLIDER ); Config_DSound51.GainSR = GetSliderValue( hWnd, IDC_RRIGHT_GAIN_SLIDER ); Config_DSound51.GainLFE = GetSliderValue( hWnd, IDC_LFE_SLIDER ); Config_DSound51.GainC = GetSliderValue( hWnd, IDC_CENTER_GAIN_SLIDER ); Config_DSound51.AddCLR = GetSliderValue( hWnd, IDC_LR_CENTER_SLIDER ); if( Config_DSound51.NumBuffers < 2 ) Config_DSound51.NumBuffers = 2; if( Config_DSound51.NumBuffers > MAX_BUFFER_COUNT ) Config_DSound51.NumBuffers = MAX_BUFFER_COUNT; } } EndDialog(hWnd,0); break; case IDCANCEL: EndDialog(hWnd,0); break; default: return FALSE; } break; case WM_HSCROLL: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch(wmId) { //case TB_ENDTRACK: //case TB_THUMBPOSITION: case TB_LINEUP: case TB_LINEDOWN: case TB_PAGEUP: case TB_PAGEDOWN: wmEvent=(int)SendMessage((HWND)lParam,TBM_GETPOS,0,0); case TB_THUMBTRACK: if( wmEvent < 2 ) wmEvent = 2; if( wmEvent > MAX_BUFFER_COUNT ) wmEvent = MAX_BUFFER_COUNT; SendMessage((HWND)lParam,TBM_SETPOS,TRUE,wmEvent); sprintf_s(temp,128,"%d (%d ms latency)",wmEvent, 1000 / (96000 / (wmEvent * BufferSize))); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL2),temp); break; default: return FALSE; } break; case WM_VSCROLL: HANDLE_SCROLL_MESSAGE(IDC_LEFT_GAIN_SLIDER,IDC_LEFT_GAIN_EDIT); HANDLE_SCROLL_MESSAGE(IDC_RIGHT_GAIN_SLIDER,IDC_RIGHT_GAIN_EDIT); HANDLE_SCROLL_MESSAGE(IDC_RLEFT_GAIN_SLIDER,IDC_RLEFT_GAIN_EDIT); HANDLE_SCROLL_MESSAGE(IDC_RRIGHT_GAIN_SLIDER,IDC_RRIGHT_GAIN_EDIT); HANDLE_SCROLL_MESSAGE(IDC_CENTER_GAIN_SLIDER,IDC_CENTER_GAIN_EDIT); HANDLE_SCROLL_MESSAGE(IDC_LFE_SLIDER,IDC_LFE_EDIT); HANDLE_SCROLL_MESSAGE(IDC_LR_CENTER_SLIDER,IDC_LR_CENTER_EDIT); default: return FALSE; } return TRUE; }
static BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { int wmId,wmEvent; int tSel=0; switch(uMsg) { case WM_INITDIALOG: { wchar_t temp[128]; char temp2[192]; sprintf_s( temp2, "%S", Config_DSoundOut.Device.c_str() ); haveGuid = ! FAILED(GUIDFromString(temp2,&DevGuid)); SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_RESETCONTENT,0,0); ndevs=0; DirectSoundEnumerate( DSEnumCallback, NULL ); tSel=-1; for(int i=0;i<ndevs;i++) { SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_ADDSTRING,0,(LPARAM)devices[i].name.c_str()); if(haveGuid && IsEqualGUID(devices[i].guid,DevGuid)) { tSel=i; } } if(tSel>=0) { SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_SETCURSEL,tSel,0); } INIT_SLIDER( IDC_BUFFERS_SLIDER, 2, MAX_BUFFER_COUNT, 2, 1, 1 ); SendMessage(GetDlgItem(hWnd,IDC_BUFFERS_SLIDER),TBM_SETPOS,TRUE,Config_DSoundOut.NumBuffers); swprintf_s(temp, _T("%d (%d ms latency)"),Config_DSoundOut.NumBuffers, 1000 / (96000 / (Config_DSoundOut.NumBuffers * BufferSize))); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL),temp); } break; case WM_COMMAND: { wchar_t temp[128]; wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: { int i = (int)SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_GETCURSEL,0,0); if(!devices[i].hasGuid) { Config_DSoundOut.Device[0] = 0; // clear device name to "" } else { swprintf_s(temp, _T("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), devices[i].guid.Data1, devices[i].guid.Data2, devices[i].guid.Data3, devices[i].guid.Data4[0], devices[i].guid.Data4[1], devices[i].guid.Data4[2], devices[i].guid.Data4[3], devices[i].guid.Data4[4], devices[i].guid.Data4[5], devices[i].guid.Data4[6], devices[i].guid.Data4[7] ); Config_DSoundOut.Device = temp; } Config_DSoundOut.NumBuffers = (int)SendMessage( GetDlgItem( hWnd, IDC_BUFFERS_SLIDER ), TBM_GETPOS, 0, 0 ); if( Config_DSoundOut.NumBuffers < 2 ) Config_DSoundOut.NumBuffers = 2; if( Config_DSoundOut.NumBuffers > MAX_BUFFER_COUNT ) Config_DSoundOut.NumBuffers = MAX_BUFFER_COUNT; } EndDialog(hWnd,0); break; case IDCANCEL: EndDialog(hWnd,0); break; default: return FALSE; } } break; case WM_HSCROLL: { wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch(wmId) { //case TB_ENDTRACK: //case TB_THUMBPOSITION: case TB_LINEUP: case TB_LINEDOWN: case TB_PAGEUP: case TB_PAGEDOWN: wmEvent=(int)SendMessage((HWND)lParam,TBM_GETPOS,0,0); case TB_THUMBTRACK: { wchar_t temp[128]; if( wmEvent < 2 ) wmEvent = 2; if( wmEvent > MAX_BUFFER_COUNT ) wmEvent = MAX_BUFFER_COUNT; SendMessage((HWND)lParam,TBM_SETPOS,TRUE,wmEvent); swprintf_s(temp,_T("%d (%d ms latency)"),wmEvent, 1000 / (96000 / (wmEvent * BufferSize))); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL),temp); break; } default: return FALSE; } } break; default: return FALSE; } return TRUE; }
bool _ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { int wmId,wmEvent; int tSel = 0; switch(uMsg) { case WM_INITDIALOG: { wchar_t temp[128]; haveGuid = !FAILED(GUIDFromString(m_Device, &DevGuid)); SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_RESETCONTENT,0,0); ndevs=0; DirectSoundEnumerate( DSEnumCallback, NULL ); tSel=-1; for(int i=0;i<ndevs;i++) { SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_ADDSTRING,0,(LPARAM)m_devices[i].name.wc_str()); if(haveGuid && IsEqualGUID(m_devices[i].guid,DevGuid) || tSel < 0 && !m_devices[i].hasGuid) tSel = i; } if(tSel>=0) SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_SETCURSEL,tSel,0); INIT_SLIDER( IDC_BUFFERS_SLIDER, 2, MAX_BUFFER_COUNT, 2, 1, 1 ); SendMessage(GetDlgItem(hWnd,IDC_BUFFERS_SLIDER),TBM_SETPOS,TRUE,m_NumBuffers); swprintf_s(temp, L"%d (%d ms latency)",m_NumBuffers, 1000 / (96000 / (m_NumBuffers * BufferSize))); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL),temp); SET_CHECK( IDC_GLOBALFOCUS_DISABLE, m_DisableGlobalFocus ); SET_CHECK( IDC_USE_HARDWARE, m_UseHardware ); } break; case WM_COMMAND: { wchar_t temp[128]; wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: { int i = (int)SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_GETCURSEL,0,0); if(!m_devices[i].hasGuid) { m_Device[0] = 0; // clear device name to "" } else { swprintf_s(temp, L"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", m_devices[i].guid.Data1, m_devices[i].guid.Data2, m_devices[i].guid.Data3, m_devices[i].guid.Data4[0], m_devices[i].guid.Data4[1], m_devices[i].guid.Data4[2], m_devices[i].guid.Data4[3], m_devices[i].guid.Data4[4], m_devices[i].guid.Data4[5], m_devices[i].guid.Data4[6], m_devices[i].guid.Data4[7] ); m_Device = temp; } m_NumBuffers = (int)SendMessage( GetDlgItem( hWnd, IDC_BUFFERS_SLIDER ), TBM_GETPOS, 0, 0 ); if( m_NumBuffers < 2 ) m_NumBuffers = 2; if( m_NumBuffers > MAX_BUFFER_COUNT ) m_NumBuffers = MAX_BUFFER_COUNT; EndDialog(hWnd,0); } break; case IDCANCEL: EndDialog(hWnd,0); break; HANDLE_CHECK( IDC_GLOBALFOCUS_DISABLE, m_DisableGlobalFocus ); HANDLE_CHECK( IDC_USE_HARDWARE, m_UseHardware ); default: return FALSE; } } break; case WM_HSCROLL: { wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch(wmId) { //case TB_ENDTRACK: //case TB_THUMBPOSITION: case TB_LINEUP: case TB_LINEDOWN: case TB_PAGEUP: case TB_PAGEDOWN: wmEvent = (int)SendMessage((HWND)lParam,TBM_GETPOS,0,0); case TB_THUMBTRACK: { wchar_t temp[128]; if( wmEvent < 2 ) wmEvent = 2; if( wmEvent > MAX_BUFFER_COUNT ) wmEvent = MAX_BUFFER_COUNT; SendMessage((HWND)lParam,TBM_SETPOS,TRUE,wmEvent); swprintf_s(temp,L"%d (%d ms latency)",wmEvent, 1000 / (96000 / (wmEvent * BufferSize))); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL),temp); break; } default: return FALSE; } } break; default: return FALSE; } return TRUE; }
static BOOL CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (uMsg) { case WM_INITDIALOG: wchar_t temp[128]; INIT_SLIDER(IDC_BUFFERS_SLIDER, 3, MAX_BUFFER_COUNT, 2, 1, 1); SendMessage(GetDlgItem(hWnd, IDC_BUFFERS_SLIDER), TBM_SETPOS, TRUE, Config_WaveOut.NumBuffers); swprintf_s(temp, 128, L"%d (%d ms latency)", Config_WaveOut.NumBuffers, 1000 / (96000 / (Config_WaveOut.NumBuffers * BufferSize))); SetWindowText(GetDlgItem(hWnd, IDC_LATENCY_LABEL), temp); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: { Config_WaveOut.NumBuffers = (int)SendMessage(GetDlgItem(hWnd, IDC_BUFFERS_SLIDER), TBM_GETPOS, 0, 0); if (Config_WaveOut.NumBuffers < 3) Config_WaveOut.NumBuffers = 3; if (Config_WaveOut.NumBuffers > MAX_BUFFER_COUNT) Config_WaveOut.NumBuffers = MAX_BUFFER_COUNT; } EndDialog(hWnd, 0); break; case IDCANCEL: EndDialog(hWnd, 0); break; default: return FALSE; } break; case WM_HSCROLL: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { //case TB_ENDTRACK: //case TB_THUMBPOSITION: case TB_LINEUP: case TB_LINEDOWN: case TB_PAGEUP: case TB_PAGEDOWN: wmEvent = (int)SendMessage((HWND)lParam, TBM_GETPOS, 0, 0); case TB_THUMBTRACK: if (wmEvent < 3) wmEvent = 3; if (wmEvent > MAX_BUFFER_COUNT) wmEvent = MAX_BUFFER_COUNT; SendMessage((HWND)lParam, TBM_SETPOS, TRUE, wmEvent); swprintf_s(temp, L"%d (%d ms latency)", wmEvent, 1000 / (96000 / (wmEvent * BufferSize))); SetWindowText(GetDlgItem(hWnd, IDC_LATENCY_LABEL), temp); break; default: return FALSE; } break; default: return FALSE; } return TRUE; }