config.cpp 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. #include "main.h"
  2. #include <shlobj.h>
  3. #include <commctrl.h>
  4. #include "resource.h"
  5. #include "../winamp/wa_ipc.h"
  6. #include "../pfc/string_unicode.h"
  7. static HWND g_theConfig;
  8. static struct
  9. {
  10. HWND wnd;
  11. int id;
  12. UINT l_id;
  13. } child_dlgs[]={
  14. {0,IDD_CONFIG1,IDS_PREFS_DEVICE},
  15. {0,IDD_CONFIG8,IDS_PREFS_DISPLAY},
  16. {0,IDD_CONFIG2,IDS_PREFS_SAMPLING},
  17. {0,IDD_CONFIG3,IDS_PREFS_DIRECTMUSIC},
  18. {0,IDD_CONFIG4,IDS_PREFS_MISC},
  19. {0,IDD_CONFIG7,IDS_PREFS_FILE_TYPES},
  20. {0,IDD_CONFIG5,IDS_PREFS_FILES},
  21. {0,IDD_CONFIG6,IDS_PREFS_HARDWARE_SETUP},
  22. };
  23. enum
  24. {
  25. IDC_CONFIG1,IDC_CONFIG8,IDC_CONFIG2,IDC_CONFIG3,IDC_CONFIG4,IDC_CONFIG7,IDC_CONFIG5,IDC_CONFIG6
  26. };
  27. static const char CFG_NAME[]="IN_MIDI";
  28. #define FILE_BLAH MessageBoxA(wnd,WASABI_API_LNGSTRING(IDS_UNABLE_TO_LOAD_FILE),0,MB_ICONERROR)
  29. int loop_txt[3]={STRING_LOOP1,STRING_LOOP2,STRING_LOOP3};
  30. #define MAKEID(X,Y) ( ( (DWORD)(X)<<16) | (DWORD)(Y)) //MAKEID(DLG_ID,CTRL_ID)
  31. extern cfg_int cfg_seq_showpanel;
  32. extern cfg_int cfg_lyrics;
  33. cfg_int cfg_smp("smp",0),cfg_reverb("reverb",0),cfg_chorus("chorus",0),cfg_dls_active("dls_active",0);
  34. cfg_int cfg_sampout("sampout",0);
  35. cfg_int cfg_hardware_reset("hardware_reset",0);
  36. cfg_int cfg_gm_reset("gm_reset",0),cfg_gm_reset1("gm_reset1",0);
  37. cfg_int cfg_gs_reset("gs_reset",0),cfg_gs_reset1("gs_reset1",0);
  38. cfg_int cfg_nosysex("nosysex",0);
  39. cfg_int cfg_dm_keep_port("dm_keep_port",0);
  40. cfg_int cfg_recover_tracks("recover_tracks",1);
  41. cfg_int cfg_rmi_def("rmi_def",0);
  42. cfg_int cfg_logvol("logvol",1);
  43. cfg_int cfg_ff7loopz("ff7loopz",1);
  44. cfg_int cfg_samp_revert("samp_revert",1);
  45. cfg_int cfg_hack_xg_drums("hack_xg_drums",0),cfg_hack_dls_instruments("hack_dls_instruments",1),cfg_hack_dls_drums("hack_dls_drums",1);
  46. static const WORD sr_tab[]={8000,11025,16000,22050,24000,32000,44100,48000};
  47. cfg_int cfg_cur_tab("cur_tab",0);
  48. cfg_int cfg_volmode("volmode",2);
  49. //0 - no volume, 1 - default, 2,3,4 ... - mixers
  50. cfg_string cfg_extra_exts("extra_exts","");
  51. cfg_int cfg_freq("freq",22050);
  52. cfg_int cfg_eof_delay("eof_delay",0);
  53. cfg_string cfg_dls_file("dls_file","");
  54. cfg_int cfg_bugged("bugged",0);
  55. cfg_int cfg_loop_type("loop_type",0),cfg_loop_count("loop_count",1),cfg_loop_infinite("loop_infinite",0);
  56. cfg_int cfg_wavein_dev("wavein_dev",-1),cfg_wavein_sr("wavein_sr",44100),cfg_wavein_ch("wavein_ch",2),cfg_wavein_bps("wavein_bps",16),cfg_wavein_src("wavein_src",0);
  57. cfg_int cfg_playback_mode("playback_mode",0);
  58. static UINT vm_retval=-666;
  59. cfg_struct_t<GUID> cfg_driver("driver",0),cfg_device("device",0);
  60. UINT volmode_detect()
  61. {
  62. if (vm_retval!=-666) return vm_retval;
  63. UINT dev;
  64. UINT id;
  65. UINT n_devz=mixerGetNumDevs();
  66. UINT pos=0;
  67. for(dev=0;dev<n_devz;dev++)
  68. {
  69. mixerGetID((HMIXEROBJ)dev,&id,MIXER_OBJECTF_MIXER);
  70. MIXERLINE ml;
  71. memset(&ml,0,sizeof(ml));
  72. ml.cbStruct=sizeof(ml);
  73. ml.dwComponentType=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
  74. mixerGetLineInfo((HMIXEROBJ)id,&ml,MIXER_GETLINEINFOF_COMPONENTTYPE|MIXER_OBJECTF_MIXER);
  75. UINT con;
  76. for(con=0;con<ml.cConnections;con++)
  77. {
  78. MIXERLINE ml1;
  79. memset(&ml1,0,sizeof(ml1));
  80. ml1.cbStruct=sizeof(ml);
  81. ml1.dwSource=con;
  82. mixerGetLineInfo((HMIXEROBJ)id,&ml1,MIXER_GETLINEINFOF_SOURCE|MIXER_OBJECTF_MIXER);
  83. if (ml1.dwComponentType==MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER)
  84. {
  85. vm_retval=pos;
  86. return vm_retval;
  87. }
  88. pos++;
  89. }
  90. }
  91. vm_retval=-1;
  92. return vm_retval;
  93. }
  94. //avoid double id shit
  95. #define _IDC_PORT MAKEID(IDC_CONFIG1,IDC_PORT)
  96. #define _IDC_DEV_INFO MAKEID(IDC_CONFIG1,IDC_DEV_INFO)
  97. #define _IDC_HARDWARE_RESET MAKEID(IDC_CONFIG1,IDC_HARDWARE_RESET)
  98. #define _IDC_VOLMODE MAKEID(IDC_CONFIG1,IDC_VOLMODE)
  99. #define _IDC_LOGVOL MAKEID(IDC_CONFIG1,IDC_LOGVOL)
  100. #define _IDC_SAMPLING_ENABLED MAKEID(IDC_CONFIG2,IDC_SAMPLING_ENABLED)
  101. #define _IDC_WAVEIN MAKEID(IDC_CONFIG2,IDC_WAVEIN)
  102. #define _IDC_WAVEIN_SRC MAKEID(IDC_CONFIG2,IDC_WAVEIN_SRC)
  103. #define _IDC_WAVEIN_SR MAKEID(IDC_CONFIG2,IDC_WAVEIN_SR)
  104. #define _IDC_WAVEIN_S2 MAKEID(IDC_CONFIG2,IDC_WAVEIN_S2)
  105. #define _IDC_WAVEIN_CH MAKEID(IDC_CONFIG2,IDC_WAVEIN_CH)
  106. #define _IDC_WAVEIN_BPS MAKEID(IDC_CONFIG2,IDC_WAVEIN_BPS)
  107. #define _IDC_SAMPLING_DSP MAKEID(IDC_CONFIG2,IDC_SAMPLING_DSP)
  108. #define _IDC_SAMPLING_OUTPUT MAKEID(IDC_CONFIG2,IDC_SAMPLING_OUTPUT)
  109. #define _IDC_SAMP_REVERT MAKEID(IDC_CONFIG2,IDC_SAMP_REVERT)
  110. #define _IDC_REVERB MAKEID(IDC_CONFIG3,IDC_REVERB)
  111. #define _IDC_CHORUS MAKEID(IDC_CONFIG3,IDC_CHORUS)
  112. #define _IDC_DM_KEEP_PORT MAKEID(IDC_CONFIG3,IDC_DM_KEEP_PORT)
  113. #define _IDC_FREQ MAKEID(IDC_CONFIG3,IDC_FREQ)
  114. #define _IDC_DLS_CB MAKEID(IDC_CONFIG3,IDC_DLS_CB)
  115. #define _IDC_DLS MAKEID(IDC_CONFIG3,IDC_DLS)
  116. #define _IDC_DLS_B MAKEID(IDC_CONFIG3,IDC_DLS_B)
  117. #define _IDC_HACK_DM_RESETS MAKEID(IDC_CONFIG3,IDC_HACK_DM_RESETS)
  118. #define _IDC_SHOW_PANEL MAKEID(IDC_CONFIG4,IDC_SHOW_PANEL)
  119. #define _IDC_LOOP_S MAKEID(IDC_CONFIG4,IDC_LOOP_S)
  120. #define _IDC_LOOP MAKEID(IDC_CONFIG4,IDC_LOOP)
  121. #define _IDC_LOOP_S1 MAKEID(IDC_CONFIG4,IDC_LOOP_S1)
  122. #define _IDC_LOOP_S2 MAKEID(IDC_CONFIG4,IDC_LOOP_S2)
  123. #define _IDC_LOOP_T MAKEID(IDC_CONFIG4,IDC_LOOP_T)
  124. #define _IDC_LOOP_SP MAKEID(IDC_CONFIG4,IDC_LOOP_SP)
  125. #define _IDC_LOOP_S3 MAKEID(IDC_CONFIG4,IDC_LOOP_S3)
  126. #define _IDC_LOOP_S4 MAKEID(IDC_CONFIG4,IDC_LOOP_S4)
  127. #define _IDC_INFINITE MAKEID(IDC_CONFIG4,IDC_INFINITE)
  128. #define _IDC_PLAYBACK_METHOD MAKEID(IDC_CONFIG4,IDC_PLAYBACK_METHOD)
  129. #define _IDC_RESET MAKEID(IDC_CONFIG4,IDC_RESET)
  130. #define _IDC_RESET1 MAKEID(IDC_CONFIG4,IDC_RESET1)
  131. #define _IDC_STEREO MAKEID(IDC_CONFIG5,IDC_STEREO)
  132. #define _IDC_HACKTRACK MAKEID(IDC_CONFIG5,IDC_HACKTRACK)
  133. #define _IDC_HACK_NO_SYSEX MAKEID(IDC_CONFIG5,IDC_HACK_NO_SYSEX)
  134. #define _IDC_HACK_XG_DRUMS MAKEID(IDC_CONFIG5,IDC_HACK_XG_DRUMS)
  135. #define _IDC_HACK_DLS_DRUMS MAKEID(IDC_CONFIG5,IDC_HACK_DLS_DRUMS)
  136. #define _IDC_HACK_DLS_INSTRUMENTS MAKEID(IDC_CONFIG5,IDC_HACK_DLS_INSTRUMENTS)
  137. #define _IDC_LYRICS_ENABLED MAKEID(IDC_CONFIG8,IDC_LYRICS_ENABLED)
  138. #define _IDC_EOF_DELAY MAKEID(IDC_CONFIG5,IDC_EOF_DELAY)
  139. #define _IDC_EOF_DELAY_SPIN MAKEID(IDC_CONFIG5,IDC_EOF_DELAY_SPIN)
  140. sysex_table cfg_sysex_table;
  141. static sysex_table edit_sysex_table;
  142. #define _IDC_SYSEX_LIST MAKEID(IDC_CONFIG6,IDC_SYSEX_LIST)
  143. #define _IDC_IMP_F MAKEID(IDC_CONFIG6,IDC_IMP_F)
  144. #define _IDC_EXP_F MAKEID(IDC_CONFIG6,IDC_EXP_F)
  145. #define _IDC_IMP_PR MAKEID(IDC_CONFIG6,IDC_IMP_PR)
  146. #define _IDC_EXP_PR MAKEID(IDC_CONFIG6,IDC_EXP_PR)
  147. #define _IDC_SYSEX_ADD MAKEID(IDC_CONFIG6,IDC_SYSEX_ADD)
  148. #define _IDC_SYSEX_DELETE MAKEID(IDC_CONFIG6,IDC_SYSEX_DELETE)
  149. #define _IDC_SYSEX_EDIT MAKEID(IDC_CONFIG6,IDC_SYSEX_EDIT)
  150. #define _IDC_SYSEX_UP MAKEID(IDC_CONFIG6,IDC_SYSEX_UP)
  151. #define _IDC_SYSEX_DOWN MAKEID(IDC_CONFIG6,IDC_SYSEX_DOWN)
  152. #define _IDC_EXTS_LIST MAKEID(IDC_CONFIG7,IDC_EXTS_LIST)
  153. #define _IDC_EXTS_ED MAKEID(IDC_CONFIG7,IDC_EXTS_ED)
  154. #define _IDC_RMI_FMT MAKEID(IDC_CONFIG8,IDC_RMI_FMT)
  155. #define _IDC_RMI_DEF MAKEID(IDC_CONFIG8,IDC_RMI_DEF)
  156. #define EnableDlgItem(X,Y,Z) EnableWindow(_GetDlgItem(X,Y),Z)
  157. static HWND cfgGetTab(UINT id)
  158. {
  159. id-=IDC_CONFIG1;
  160. if (id>=tabsize(child_dlgs)) return 0;
  161. return child_dlgs[id].wnd;
  162. }
  163. static HWND __getdlgitem(UINT id)
  164. {
  165. HWND w=cfgGetTab(id>>16);
  166. if (!w) return 0;
  167. return GetDlgItem(w,id&0xFFFF);
  168. }
  169. #define _GetDlgItem(w,id) __getdlgitem(id)
  170. #define _GetDlgItemText(p,id,tx,l) GetWindowText(__getdlgitem(id),tx,l)
  171. #define _SetDlgItemText(p,id,tx) SetWindowText(__getdlgitem(id),tx)
  172. #define _SetDlgItemTextW(p,id,tx) SetWindowTextW(__getdlgitem(id),tx)
  173. #define _GetDlgItemInt(a,b,c,d) __getdlgitemint(b)
  174. #define _SetDlgItemInt(a,b,c,d) __setdlgitemint(b,c)
  175. #define _SendDlgItemMessage(a,b,c,d,e) SendMessage(_GetDlgItem(a,b),c,d,e)
  176. static void __setdlgitemint(UINT id,UINT val)
  177. {
  178. char buf[32] = {0};
  179. _itoa(val,buf,10);
  180. SetWindowTextA(__getdlgitem(id),buf);
  181. }
  182. static int __getdlgitemint(UINT id)
  183. {
  184. char buf[32] = {0};
  185. GetWindowTextA(__getdlgitem(id),buf,32);
  186. return atoi(buf);
  187. }
  188. static BOOL CALLBACK cfgVisStatusProc(HWND wnd,LPARAM param)
  189. {
  190. if (GetWindowLong(wnd,GWL_ID)==IDC_SAMPLING_ENABLED)
  191. {
  192. EnableWindow(wnd,(param & 2) >> 1);
  193. }
  194. else
  195. {
  196. EnableWindow(wnd,param & 1);
  197. }
  198. return 1;
  199. }
  200. static MIDI_device * get_device(HWND wnd)
  201. {
  202. int idx = _SendDlgItemMessage(wnd,_IDC_PORT,CB_GETCURSEL,0,0);
  203. if (idx<0) return 0;
  204. return (MIDI_device*)_SendDlgItemMessage(wnd,_IDC_PORT,CB_GETITEMDATA,idx,0);
  205. }
  206. static void cfgVisStatus(HWND wnd)
  207. {
  208. int samp =_SendDlgItemMessage(wnd,_IDC_SAMPLING_ENABLED,BM_GETCHECK,0,0);
  209. int output = 0;
  210. int flags = 0;
  211. MIDI_device * dev = get_device(wnd);
  212. if (dev && dev->has_output()) output = 1;
  213. if (output && samp) {samp = 0;_SendDlgItemMessage(wnd,_IDC_SAMPLING_ENABLED,BM_SETCHECK,0,0);}
  214. if (!output)
  215. {
  216. flags|=2;
  217. if (samp) flags|=1;
  218. else {
  219. _SendDlgItemMessage(wnd,_IDC_SAMPLING_DSP,BM_SETCHECK,0,0);
  220. _SendDlgItemMessage(wnd,_IDC_SAMPLING_OUTPUT,BM_SETCHECK,0,0);
  221. }
  222. }
  223. EnumChildWindows(cfgGetTab(IDC_CONFIG2),cfgVisStatusProc,flags);
  224. }
  225. static void cfgVisMix(HWND wnd,int dev)
  226. {
  227. HWND w=_GetDlgItem(wnd,_IDC_WAVEIN_SRC);
  228. SendMessage(w,CB_RESETCONTENT,0,0);
  229. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(STRING_SAMP_SRC_DEFAULT));
  230. SendMessage(w,CB_SETCURSEL,0,0);
  231. UINT id=0;
  232. if (mixerGetID((HMIXEROBJ)dev,&id,MIXER_OBJECTF_WAVEOUT)) return;
  233. MIXERLINE ml;
  234. memset(&ml,0,sizeof(ml));
  235. ml.cbStruct=sizeof(ml);
  236. ml.dwComponentType=MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
  237. if (mixerGetLineInfo((HMIXEROBJ)id,&ml,MIXER_GETLINEINFOF_COMPONENTTYPE|MIXER_OBJECTF_MIXER)) return;
  238. MIXERLINECONTROLS cs;
  239. MIXERCONTROL c;
  240. memset(&cs,0,sizeof(cs));
  241. cs.cbStruct=sizeof(cs);
  242. cs.cControls=1;
  243. cs.dwLineID=ml.dwLineID;
  244. cs.dwControlType=MIXERCONTROL_CONTROLTYPE_MUX;
  245. cs.cbmxctrl=sizeof(c);
  246. cs.pamxctrl=&c;
  247. memset(&c,0,sizeof(c));
  248. c.cbStruct=sizeof(c);
  249. if (!mixerGetLineControls((HMIXEROBJ)id,&cs,MIXER_OBJECTF_MIXER|MIXER_GETLINECONTROLSF_ONEBYTYPE))
  250. {
  251. MIXERCONTROLDETAILS_LISTTEXT *t = (MIXERCONTROLDETAILS_LISTTEXT*)malloc(sizeof(MIXERCONTROLDETAILS_LISTTEXT)*c.cMultipleItems);
  252. MIXERCONTROLDETAILS d;
  253. d.cbStruct=sizeof(d);
  254. d.dwControlID=c.dwControlID;
  255. d.cbDetails=sizeof(*t);
  256. d.cChannels=ml.cChannels;
  257. d.cMultipleItems=c.cMultipleItems;
  258. d.paDetails=t;
  259. UINT n;
  260. for(n=0;n<c.cMultipleItems;n++)
  261. {
  262. t[n].dwParam1=ml.dwLineID;
  263. }
  264. mixerGetControlDetails((HMIXEROBJ)id,&d,MIXER_GETCONTROLDETAILSF_LISTTEXT|MIXER_OBJECTF_MIXER);
  265. for(n=0;n<c.cMultipleItems;n++)
  266. {
  267. SendMessage(w,CB_ADDSTRING,0,(long)t[n].szName);
  268. }
  269. free(t);
  270. }
  271. }
  272. static void ChangePort(HWND wnd,MIDI_device * dev)
  273. {
  274. cfgVisStatus(wnd);
  275. {
  276. string_w temp;
  277. temp+=WASABI_API_LNGSTRINGW(IDS_TYPE);
  278. temp+=dev->get_driver()->get_name();
  279. temp+=L"\x0d\x0a";
  280. temp+=dev->get_info();
  281. if (!wcscmp((const wchar_t*)temp + temp.length()-2,L"\x0d\x0a")) temp.truncate(temp.length()-2);
  282. _SetDlgItemTextW(wnd,_IDC_DEV_INFO,temp);
  283. }
  284. }
  285. #undef DEV
  286. const static struct
  287. {
  288. UINT id;
  289. cfg_int * var;
  290. } bWnds[]=
  291. {
  292. {_IDC_SAMP_REVERT,&cfg_samp_revert},
  293. {_IDC_LOGVOL,&cfg_logvol},
  294. {_IDC_RMI_DEF,&cfg_rmi_def},
  295. {_IDC_HACK_DLS_DRUMS,&cfg_hack_dls_drums},
  296. {_IDC_HACK_DLS_INSTRUMENTS,&cfg_hack_dls_instruments},
  297. {_IDC_HACK_XG_DRUMS,&cfg_hack_xg_drums},
  298. {_IDC_HACKTRACK,&cfg_recover_tracks},
  299. {_IDC_DM_KEEP_PORT,&cfg_dm_keep_port},
  300. {_IDC_SAMPLING_ENABLED,&cfg_smp},
  301. {_IDC_REVERB,&cfg_reverb},
  302. {_IDC_CHORUS,&cfg_chorus},
  303. {_IDC_SAMPLING_OUTPUT,&cfg_sampout},
  304. {_IDC_HACK_NO_SYSEX,&cfg_nosysex},
  305. {_IDC_LYRICS_ENABLED,&cfg_lyrics},
  306. {_IDC_SHOW_PANEL,&cfg_seq_showpanel},
  307. };
  308. #define NUM_BWNDS (sizeof(bWnds)/sizeof(*bWnds))
  309. #define WM_CMDNOTIFY (WM_USER+6)
  310. static BOOL WINAPI CfgChildProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
  311. {
  312. if (msg==WM_COMMAND)
  313. {
  314. #if defined(_WIN64)
  315. SendMessage(GetParent(wnd),WM_CMDNOTIFY,wp,MAKEID(GetWindowLong(wnd,DWLP_USER),LOWORD(wp)));
  316. #else
  317. SendMessage(GetParent(wnd), WM_CMDNOTIFY, wp, MAKEID(GetWindowLong(wnd, DWL_USER), LOWORD(wp)));
  318. #endif
  319. }
  320. return 0;
  321. }
  322. static bool is_hex(char c) {return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F');}
  323. static UINT read_hex(char* t)
  324. {
  325. UINT r=0;
  326. while(is_hex(*t))
  327. {
  328. r<<=4;
  329. if (*t>='0' && *t<='9')
  330. r|=*t-'0';
  331. else if (*t>='a' && *t<='f')
  332. r|=*t-'a'+10;
  333. else r|=*t-'A'+10;
  334. t++;
  335. }
  336. return r;
  337. }
  338. BYTE* read_sysex_edit(HWND w,UINT *siz)//used in seq.cpp
  339. {
  340. UINT tl=GetWindowTextLength(w)+2;
  341. char* tx=(char*)malloc(tl);
  342. if (!tx) return 0;
  343. GetWindowTextA(w,tx,tl+2);
  344. UINT sl=0;
  345. BYTE* tmp=(BYTE*)malloc(tl/2+2);
  346. char* t=tx;
  347. if (!tmp)
  348. {
  349. free(tx);
  350. return 0;
  351. }
  352. tmp[sl++]=0xF0;
  353. while(t && *t)
  354. {
  355. while(!is_hex(*t) && *t) t++;
  356. if (!*t) break;
  357. tmp[sl++]=read_hex(t);
  358. while(is_hex(*t)) t++;
  359. }
  360. tmp[sl++]=0xF7;
  361. free(tx);
  362. *siz=sl;
  363. return tmp;
  364. }
  365. static BOOL WINAPI SysexProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
  366. {
  367. switch(msg)
  368. {
  369. case WM_INITDIALOG:
  370. #if defined(_WIN64)
  371. SetWindowLong(wnd,DWLP_USER,lp);
  372. #else
  373. SetWindowLong(wnd, DWL_USER, lp);
  374. #endif
  375. SendDlgItemMessage(wnd,IDC_SPIN1,UDM_SETRANGE,0,MAKELONG(9999,0));
  376. SetDlgItemInt(wnd,IDC_DELAY,edit_sysex_table.get_time(lp),0);
  377. edit_sysex_table.print_edit(lp,GetDlgItem(wnd,IDC_EDIT1));
  378. return 1;
  379. case WM_COMMAND:
  380. switch(wp)
  381. {
  382. case IDOK:
  383. {
  384. UINT size;
  385. BYTE* data=read_sysex_edit(GetDlgItem(wnd,IDC_EDIT1),&size);
  386. if (!data)
  387. {
  388. EndDialog(wnd,0);
  389. break;
  390. }
  391. #if defined(_WIN64)
  392. edit_sysex_table.modify_entry(GetWindowLong(wnd, DWLP_USER), data, size, GetDlgItemInt(wnd, IDC_DELAY, 0, 0));
  393. #else
  394. edit_sysex_table.modify_entry(GetWindowLong(wnd, DWL_USER), data, size, GetDlgItemInt(wnd, IDC_DELAY, 0, 0));
  395. #endif
  396. free(data);
  397. }
  398. EndDialog(wnd,1);
  399. break;
  400. case IDCANCEL:
  401. EndDialog(wnd,0);
  402. break;
  403. }
  404. }
  405. return 0;
  406. }
  407. extern int initDefaultDeviceShit();
  408. static BOOL WINAPI CfgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
  409. {
  410. switch(msg)
  411. {
  412. case WM_INITDIALOG:
  413. if (g_theConfig && g_theConfig!=wnd)
  414. {
  415. ShowWindow(g_theConfig,SW_SHOW);
  416. EndDialog(wnd,0);
  417. return 0;
  418. }
  419. initDefaultDeviceShit();
  420. g_theConfig=wnd;
  421. {
  422. HWND hTab=GetDlgItem(wnd,IDC_TAB);
  423. #if defined(_WIN64)
  424. SetWindowLong(wnd, DWLP_USER, (long)hTab);
  425. #else
  426. SetWindowLong(wnd, DWL_USER, (long)hTab);
  427. #endif
  428. HWND w;
  429. UINT n;
  430. TC_ITEMW it=
  431. {
  432. TCIF_TEXT,
  433. 0,0,
  434. 0, //pszText
  435. 0,
  436. -1,0
  437. };
  438. for(n=0;n<tabsize(child_dlgs);n++)
  439. {
  440. it.pszText=WASABI_API_LNGSTRINGW(child_dlgs[n].l_id);
  441. SendMessage(hTab,TCM_INSERTITEMW,n,(long)&it);
  442. }
  443. SendMessage(hTab,TCM_SETCURFOCUS,cfg_cur_tab,0);
  444. RECT r;
  445. GetClientRect(hTab,&r);
  446. TabCtrl_AdjustRect(hTab,0,&r);
  447. MapWindowPoints(hTab,wnd,(LPPOINT)&r,2);
  448. for(n=0;n<tabsize(child_dlgs);n++)
  449. {
  450. child_dlgs[n].wnd=w=WASABI_API_CREATEDIALOGW(child_dlgs[n].id,wnd,CfgChildProc);
  451. SendMessage(MIDI_callback::GetMainWindow(),WM_WA_IPC,(WPARAM)w,IPC_USE_UXTHEME_FUNC);
  452. SetWindowPos(w,0,r.left,r.top,r.right-r.left,r.bottom-r.top,SWP_NOZORDER);
  453. #if defined(_WIN64)
  454. SetWindowLong(w, DWLP_USER, IDC_CONFIG1 + n);
  455. #else
  456. SetWindowLong(w, DWL_USER, IDC_CONFIG1 + n);
  457. #endif
  458. ShowWindow(w,n==cfg_cur_tab ? SW_SHOW : SW_HIDE);
  459. }
  460. }
  461. {
  462. UINT n;
  463. for(n=0;n<NUM_BWNDS;n++)
  464. {
  465. _SendDlgItemMessage(wnd,bWnds[n].id,BM_SETCHECK,*bWnds[n].var,0);
  466. }
  467. }
  468. SetDlgItemTextA(wnd,_IDC_DLS,cfg_dls_file);
  469. _SendDlgItemMessage(wnd,_IDC_DLS_CB,BM_SETCHECK,cfg_dls_active,0);
  470. EnableWindow(_GetDlgItem(wnd,_IDC_DLS),cfg_dls_active);
  471. EnableWindow(_GetDlgItem(wnd,_IDC_DLS_B),cfg_dls_active);
  472. _SetDlgItemInt(wnd,_IDC_LOOP_T,cfg_loop_count,0);
  473. _SendDlgItemMessage(wnd,_IDC_INFINITE,BM_SETCHECK,cfg_loop_infinite,0);
  474. _SendDlgItemMessage(wnd,_IDC_LOOP_T,EM_LIMITTEXT,3,0);
  475. _SendDlgItemMessage(wnd,_IDC_LOOP_SP,UDM_SETRANGE,0,MAKELONG(999,1));
  476. {
  477. int n;
  478. HWND w=_GetDlgItem(wnd,_IDC_LOOP);
  479. for(n=0;n<3;n++)
  480. {
  481. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(loop_txt[n]));
  482. }
  483. SendMessage(w,CB_SETCURSEL,cfg_loop_type,0);
  484. char tmp[10] = {0};
  485. w=_GetDlgItem(wnd,_IDC_FREQ);
  486. for(n=0;n<3;n++)
  487. {
  488. int freq = 11025<<n;
  489. _itoa(freq,tmp,10);
  490. int idx = SendMessageA(w,CB_ADDSTRING,0,(long)tmp); // Must stay in ANSI
  491. if (cfg_freq==freq)
  492. SendMessageA(w,CB_SETCURSEL,idx,0); // Must stay in ANSI
  493. }
  494. w=_GetDlgItem(wnd,_IDC_PORT);
  495. {
  496. int idx_driver=0;
  497. MIDI_driver * driver;
  498. while(driver = MIDI_driver::driver_enumerate(idx_driver++))
  499. {
  500. int idx_device=0;
  501. MIDI_device * device;
  502. while(device = driver->device_enumerate(idx_device++))
  503. {
  504. string_w temp;
  505. temp+=driver->get_name();
  506. temp+=L" / ";
  507. temp+=device->get_name();
  508. int idx_combo = SendMessageW(w,CB_ADDSTRING,0,(LPARAM)(const wchar_t*)temp);
  509. SendMessage(w,CB_SETITEMDATA,idx_combo,(long)device);
  510. if (driver->get_guid() == cfg_driver && device->get_guid() == cfg_device)
  511. {
  512. SendMessage(w,CB_SETCURSEL,idx_combo,0);
  513. ChangePort(wnd,device);
  514. }
  515. }
  516. }
  517. }
  518. w=_GetDlgItem(wnd,_IDC_WAVEIN);
  519. for(n=-1;n<(int)waveInGetNumDevs();n++)
  520. {
  521. WAVEINCAPS caps;
  522. if (waveInGetDevCaps((UINT)n,&caps,sizeof(caps))==MMSYSERR_NOERROR && caps.dwFormats!=0)
  523. {
  524. int idx=SendMessage(w,CB_ADDSTRING,0,(long)caps.szPname);
  525. SendMessage(w,CB_SETITEMDATA,idx,n);
  526. if (n==cfg_wavein_dev) SendMessage(w,CB_SETCURSEL,idx,0);
  527. }
  528. }
  529. cfgVisMix(wnd,cfg_wavein_dev);
  530. _SendDlgItemMessage(wnd,_IDC_WAVEIN_SRC,CB_SETCURSEL,cfg_wavein_src,0);
  531. w=_GetDlgItem(wnd,_IDC_PLAYBACK_METHOD);
  532. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(IDS_STREAMED));
  533. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(IDS_IMMEDIATE));
  534. SendMessage(w,CB_SETCURSEL,cfg_playback_mode,0);
  535. w=_GetDlgItem(wnd,_IDC_SYSEX_LIST);
  536. edit_sysex_table = cfg_sysex_table;
  537. {
  538. char temp[128] = {0};
  539. n=0;
  540. while(edit_sysex_table.print_preview(n++,temp)) SendMessage(w,LB_ADDSTRING,0,(long)temp);
  541. }
  542. w=_GetDlgItem(wnd,_IDC_EXTS_LIST);
  543. for(n=0;n<MIDI_core::FileTypes_GetNum();n++)
  544. {
  545. SendMessageA(w,LB_ADDSTRING,0,(long)MIDI_core::FileTypes_GetExtension(n)); // Must stay in ANSI
  546. if (cfg_ext_mask & (1<<n))
  547. SendMessage(w,LB_SETSEL,1,n);
  548. }
  549. SetDlgItemTextA(wnd,_IDC_EXTS_ED,cfg_extra_exts);
  550. w=_GetDlgItem(wnd,_IDC_VOLMODE);
  551. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(STRING_VOLUME_NONE));
  552. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(STRING_VOLUME_DRIVER_SPECIFIC));
  553. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(STRING_VOLUME_AUTO));
  554. {
  555. UINT id=0;
  556. UINT n_devz=mixerGetNumDevs();
  557. UINT dev;
  558. for(dev=0;dev<n_devz;dev++)
  559. {
  560. mixerGetID((HMIXEROBJ)dev,&id,MIXER_OBJECTF_MIXER);
  561. MIXERCAPSW capz;
  562. mixerGetDevCapsW(id,&capz,sizeof(capz));
  563. MIXERLINEW ml;
  564. memset(&ml,0,sizeof(ml));
  565. ml.cbStruct=sizeof(ml);
  566. ml.dwComponentType=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
  567. mixerGetLineInfoW((HMIXEROBJ)id,&ml,MIXER_GETLINEINFOF_COMPONENTTYPE|MIXER_OBJECTF_MIXER);
  568. UINT con;
  569. for(con=0;con<ml.cConnections;con++)
  570. {
  571. MIXERLINEW ml1;
  572. memset(&ml1,0,sizeof(ml1));
  573. ml1.cbStruct=sizeof(ml);
  574. ml1.dwSource=con;
  575. mixerGetLineInfoW((HMIXEROBJ)id,&ml1,MIXER_GETLINEINFOF_SOURCE|MIXER_OBJECTF_MIXER);
  576. if (n_devz==1) SendMessageW(w,CB_ADDSTRING,0,(long)ml1.szName);
  577. else
  578. {
  579. string_w temp;
  580. temp+=capz.szPname;
  581. temp+=ml1.szShortName;
  582. SendMessageW(w,CB_ADDSTRING,0,(long)(const wchar_t*)temp);
  583. }
  584. }
  585. }
  586. }
  587. SendMessage(w,CB_SETCURSEL,cfg_volmode,0);
  588. w=_GetDlgItem(wnd,_IDC_WAVEIN_CH);
  589. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(STRING_MONO));
  590. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(STRING_STEREO));
  591. SendMessage(w,CB_SETCURSEL,cfg_wavein_ch-1,0);
  592. w=_GetDlgItem(wnd,_IDC_WAVEIN_BPS);
  593. for(n=1;n<=4;n++)
  594. {
  595. wchar_t foo[32] = {0};
  596. wsprintfW(foo,WASABI_API_LNGSTRINGW(STRING_BIT_FMT),n<<3);
  597. SendMessageW(w,CB_ADDSTRING,0,(long)foo);
  598. }
  599. SendMessage(w,CB_SETCURSEL,(cfg_wavein_bps>>3)-1,0);
  600. w=_GetDlgItem(wnd,_IDC_WAVEIN_SR);
  601. for(n=0;n<sizeof(sr_tab)/sizeof(sr_tab[0]);n++)
  602. {
  603. char foo[8] = {0};
  604. _itoa(sr_tab[n],foo,10);
  605. SendMessageA(w,CB_ADDSTRING,0,(long)foo); // Must stay in ANSI mode
  606. }
  607. _SetDlgItemInt(wnd,_IDC_WAVEIN_SR,cfg_wavein_sr,0);
  608. w=_GetDlgItem(wnd,_IDC_HARDWARE_RESET);
  609. SendMessageW(w,CB_ADDSTRING,0,(long)WASABI_API_LNGSTRINGW(IDS_NONE));
  610. SendMessageW(w,CB_ADDSTRING,0,(long)L"GM (General MIDI)");
  611. SendMessageW(w,CB_ADDSTRING,0,(long)L"GS (Roland)");
  612. SendMessageW(w,CB_ADDSTRING,0,(long)L"XG (Yamaha)");
  613. SendMessageW(w,CB_SETCURSEL,cfg_hardware_reset,0);
  614. }
  615. // f_num=0;
  616. _SendDlgItemMessage(wnd,_IDC_EOF_DELAY_SPIN,UDM_SETRANGE,0,MAKELONG(0x7FFF,0));
  617. _SetDlgItemInt(wnd,_IDC_EOF_DELAY,cfg_eof_delay,0);
  618. return 1;
  619. case WM_NOTIFY:
  620. switch(wp)
  621. {
  622. case IDC_TAB:
  623. if (((NMHDR*)lp)->code==TCN_SELCHANGE)
  624. {
  625. UINT n;
  626. HWND hTab=((NMHDR*)lp)->hwndFrom;
  627. cfg_cur_tab=SendMessage(hTab,TCM_GETCURSEL,0,0);
  628. for(n=0;n<tabsize(child_dlgs);n++)
  629. {
  630. HWND w=cfgGetTab(IDC_CONFIG1+n);
  631. ShowWindow(w,n==cfg_cur_tab ? SW_SHOW : SW_HIDE);
  632. }
  633. }
  634. break;
  635. }
  636. break;
  637. case WM_CMDNOTIFY://WM_COMMAND from one of child dialogs
  638. if (wp>>16)
  639. {
  640. switch(lp)
  641. {
  642. case _IDC_SYSEX_LIST:
  643. if (wp>>16==LBN_DBLCLK)
  644. {
  645. CfgProc(wnd,WM_CMDNOTIFY,0,_IDC_SYSEX_EDIT);
  646. }
  647. break;
  648. case _IDC_WAVEIN:
  649. if (wp>>16==CBN_SELCHANGE)
  650. {
  651. int d=_SendDlgItemMessage(wnd,_IDC_WAVEIN,CB_GETCURSEL,0,0);
  652. if (d>=0) cfgVisMix(wnd,_SendDlgItemMessage(wnd,_IDC_WAVEIN,CB_GETITEMDATA,d,0));
  653. }
  654. break;
  655. case _IDC_PORT:
  656. if (wp>>16==CBN_SELCHANGE)
  657. {
  658. ChangePort(wnd,get_device(wnd));
  659. }
  660. break;
  661. }
  662. }
  663. else
  664. {
  665. switch(lp)
  666. {
  667. case _IDC_DLS_CB:
  668. {
  669. int checked = _SendDlgItemMessage(wnd,_IDC_DLS_CB,BM_GETCHECK,0,0);
  670. EnableWindow(_GetDlgItem(wnd,_IDC_DLS),checked);
  671. EnableWindow(_GetDlgItem(wnd,_IDC_DLS_B),checked);
  672. }
  673. break;
  674. case _IDC_IMP_F:
  675. if (edit_sysex_table.num_entries()>0)
  676. {
  677. char fn[MAX_PATH] = {0};
  678. if (DoOpenFile(wnd,fn,IDS_SYSEX_DATA,"SYX",0))
  679. {
  680. HANDLE f=CreateFileA(fn,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
  681. if (f!=INVALID_HANDLE_VALUE)
  682. {
  683. DWORD sz=GetFileSize(f,0);
  684. BYTE * temp=(BYTE*)malloc(sz);
  685. if (temp)
  686. {
  687. DWORD br = 0;
  688. ReadFile(f,temp,sz,&br,0);
  689. edit_sysex_table.add_entry(temp,sz,0);
  690. free(temp);
  691. }
  692. char tmp[128] = {0};
  693. edit_sysex_table.print_preview(edit_sysex_table.num_entries()-1,tmp);
  694. _SendDlgItemMessage(wnd,_IDC_SYSEX_LIST,LB_ADDSTRING,0,(long)tmp);
  695. CloseHandle(f);
  696. }
  697. else FILE_BLAH;
  698. }
  699. }
  700. break;
  701. case _IDC_IMP_PR:
  702. // if (!edit_sysex_table.is_empty())
  703. {
  704. char fn[MAX_PATH] = {0};
  705. fn[0]=0;
  706. if (DoOpenFile(wnd,fn,IDS_MIDI_HARDWARE_PRESETS,"MHP",0))
  707. {
  708. if (!edit_sysex_table.file_read(fn))
  709. {
  710. FILE_BLAH;
  711. }
  712. }
  713. }
  714. break;
  715. case _IDC_EXP_PR:
  716. if (!edit_sysex_table.is_empty())
  717. {
  718. char fn[MAX_PATH] = {0};
  719. fn[0]=0;
  720. if (DoOpenFile(wnd,fn,IDS_MIDI_HARDWARE_PRESETS,"MHP",1))
  721. {
  722. if (!edit_sysex_table.file_write(fn))
  723. {
  724. FILE_BLAH;
  725. }
  726. }
  727. }
  728. break;
  729. case _IDC_EXP_F:
  730. if (!edit_sysex_table.is_empty())
  731. {
  732. UINT ns=_SendDlgItemMessage(wnd,_IDC_SYSEX_LIST,LB_GETCURSEL,0,0);
  733. if (ns!=-1)
  734. {
  735. char fn[MAX_PATH] = {0};
  736. fn[0]=0;
  737. if (DoOpenFile(wnd,fn,IDS_SYSEX_DATA,"SYX",1))
  738. {
  739. HANDLE f=CreateFileA(fn,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
  740. if (f!=INVALID_HANDLE_VALUE)
  741. {
  742. BYTE * data;
  743. int size = 0;
  744. edit_sysex_table.get_entry(ns,&data,&size,0);
  745. DWORD bw = 0;
  746. WriteFile(f,data,size,&bw,0);
  747. CloseHandle(f);
  748. }
  749. else FILE_BLAH;
  750. }
  751. }
  752. }
  753. break;
  754. case _IDC_SYSEX_EDIT:
  755. if (!edit_sysex_table.is_empty())
  756. {
  757. HWND w=_GetDlgItem(wnd,_IDC_SYSEX_LIST);
  758. int n=SendMessage(w,LB_GETCURSEL,0,0);
  759. if (n!=-1 && n<edit_sysex_table.num_entries())
  760. {
  761. if (WASABI_API_DIALOGBOXPARAM(IDD_SYSEX,wnd,SysexProc,n))
  762. {
  763. SendMessage(w,LB_DELETESTRING,n,0);
  764. char tmp[128] = {0};
  765. edit_sysex_table.print_preview(n,tmp);
  766. SendMessage(w,LB_INSERTSTRING,n,(long)tmp);
  767. }
  768. }
  769. }
  770. break;
  771. case _IDC_SYSEX_ADD:
  772. // if (!edit_sysex_table.is_empty())
  773. {
  774. BYTE data[2]={0xF0,0xF7};
  775. edit_sysex_table.add_entry(data,2,0);
  776. char tmp[128] = {0};
  777. edit_sysex_table.print_preview(edit_sysex_table.num_entries()-1,tmp);
  778. _SendDlgItemMessage(wnd,_IDC_SYSEX_LIST,LB_ADDSTRING,0,(long)tmp);
  779. }
  780. break;
  781. case _IDC_SYSEX_DELETE:
  782. if (!edit_sysex_table.is_empty())
  783. {
  784. HWND w=_GetDlgItem(wnd,_IDC_SYSEX_LIST);
  785. int n=SendMessage(w,LB_GETCURSEL,0,0);
  786. if (n != LB_ERR)
  787. {
  788. SendMessage(w,LB_DELETESTRING,n,0);
  789. edit_sysex_table.remove_entry(n);
  790. }
  791. }
  792. break;
  793. case _IDC_SYSEX_UP:
  794. {
  795. HWND w=_GetDlgItem(wnd,_IDC_SYSEX_LIST);
  796. int ns=SendMessage(w,LB_GETCURSEL,0,0);
  797. if (ns==-1 || ns==0) break;
  798. int ns1=ns-1;
  799. BYTE * data;
  800. int size,time;
  801. edit_sysex_table.get_entry(ns,&data,&size,&time);
  802. edit_sysex_table.insert_entry(ns1,data,size,time);
  803. edit_sysex_table.remove_entry(ns+1);
  804. char tmp[128] = {0};
  805. SendMessage(w,LB_DELETESTRING,ns1,0);
  806. edit_sysex_table.print_preview(ns,tmp);
  807. SendMessage(w,LB_INSERTSTRING,ns,(long)tmp);
  808. }
  809. break;
  810. case _IDC_SYSEX_DOWN:
  811. {
  812. HWND w=_GetDlgItem(wnd,_IDC_SYSEX_LIST);
  813. int ns1=SendMessage(w,LB_GETCURSEL,0,0);
  814. if (ns1==-1 || ns1==edit_sysex_table.num_entries()-1) break;
  815. int ns=ns1+1;
  816. BYTE * data;
  817. int size,time;
  818. edit_sysex_table.get_entry(ns,&data,&size,&time);
  819. edit_sysex_table.insert_entry(ns1,data,size,time);
  820. edit_sysex_table.remove_entry(ns+1);
  821. char tmp[128] = {0};
  822. SendMessage(w,LB_DELETESTRING,ns,0);
  823. edit_sysex_table.print_preview(ns1,tmp);
  824. SendMessage(w,LB_INSERTSTRING,ns1,(long)tmp);
  825. }
  826. break;
  827. case _IDC_SAMPLING_ENABLED:
  828. cfgVisStatus(wnd);
  829. break;
  830. case _IDC_DLS_B:
  831. {
  832. char tmp[MAX_PATH] = {0};
  833. GetDlgItemTextA(wnd,_IDC_DLS,tmp,MAX_PATH);
  834. if (DoOpenFile(wnd,tmp,IDS_DLS_FILES,"DLS",0)) SetDlgItemTextA(wnd,_IDC_DLS,tmp);
  835. }
  836. break;
  837. }
  838. break;
  839. }
  840. break;
  841. case WM_COMMAND:
  842. switch(wp)
  843. {
  844. case IDRESET:
  845. if (MessageBoxW(wnd,WASABI_API_LNGSTRINGW(STRING_CONFIG_RESET),(wchar_t*)mod.description,
  846. MB_ICONWARNING|MB_YESNO)==IDYES)
  847. {
  848. edit_sysex_table.reset();
  849. if (g_theConfig==wnd) g_theConfig=0;
  850. EndDialog(wnd,666);
  851. }
  852. break;
  853. case IDCANCEL:
  854. edit_sysex_table.reset();
  855. if (g_theConfig==wnd) g_theConfig=0;
  856. EndDialog(wnd,0);
  857. break;
  858. case IDOK:
  859. {
  860. UINT n;
  861. for(n=0;n<NUM_BWNDS;n++)
  862. {
  863. *bWnds[n].var=!!_SendDlgItemMessage(wnd,bWnds[n].id,BM_GETCHECK,0,0);
  864. }
  865. }
  866. cfg_wavein_src=_SendDlgItemMessage(wnd,_IDC_WAVEIN_SRC,CB_GETCURSEL,0,0);
  867. cfg_playback_mode = _SendDlgItemMessage(wnd,_IDC_PLAYBACK_METHOD,CB_GETCURSEL,0,0);
  868. {
  869. MIDI_device * dev = get_device(wnd);
  870. if (dev)
  871. {
  872. cfg_driver = dev->get_driver()->get_guid();
  873. cfg_device = dev->get_guid();
  874. }
  875. }
  876. {
  877. int t=_SendDlgItemMessage(wnd,_IDC_WAVEIN,CB_GETCURSEL,0,0);
  878. if (t<0) cfg_wavein_dev=-1;
  879. else cfg_wavein_dev = _SendDlgItemMessage(wnd,_IDC_WAVEIN,CB_GETITEMDATA,t,0);
  880. }
  881. cfg_wavein_sr=_GetDlgItemInt(wnd,_IDC_WAVEIN_SR,0,0);
  882. cfg_wavein_ch=_SendDlgItemMessage(wnd,_IDC_WAVEIN_CH,CB_GETCURSEL,0,0)+1;
  883. cfg_wavein_bps=(_SendDlgItemMessage(wnd,_IDC_WAVEIN_BPS,CB_GETCURSEL,0,0)+1)<<3;
  884. cfg_loop_type=_SendDlgItemMessage(wnd,_IDC_LOOP,CB_GETCURSEL,0,0);
  885. cfg_loop_count=_GetDlgItemInt(wnd,_IDC_LOOP_T,0,0);
  886. cfg_loop_infinite=_SendDlgItemMessage(wnd,_IDC_INFINITE,BM_GETCHECK,0,0);
  887. {
  888. int t=_SendDlgItemMessage(wnd,_IDC_FREQ,CB_GETCURSEL,0,0);
  889. if (t<0) cfg_freq=22050;
  890. else cfg_freq=11025<<t;
  891. }
  892. cfg_dls_file.get_string().from_window(_GetDlgItem(wnd,_IDC_DLS));
  893. cfg_dls_active = _SendDlgItemMessage(wnd,_IDC_DLS_CB,BM_GETCHECK,0,0);
  894. cfg_sysex_table=edit_sysex_table;
  895. edit_sysex_table.reset();
  896. cfg_extra_exts.get_string().from_window(_GetDlgItem(wnd,_IDC_EXTS_ED));
  897. {
  898. int n;
  899. HWND w=_GetDlgItem(wnd,_IDC_EXTS_LIST);
  900. cfg_ext_mask=0;
  901. for(n=0;n<MIDI_core::FileTypes_GetNum();n++)
  902. if (SendMessage(w,LB_GETSEL,n,0)) cfg_ext_mask = (int)cfg_ext_mask | (1<<n);
  903. }
  904. cfg_volmode=_SendDlgItemMessage(wnd,_IDC_VOLMODE,CB_GETCURSEL,0,0);
  905. cfg_eof_delay=_GetDlgItemInt(wnd,_IDC_EOF_DELAY,0,0);
  906. cfg_hardware_reset=_SendDlgItemMessage(wnd,_IDC_HARDWARE_RESET,CB_GETCURSEL,0,0);
  907. if (g_theConfig==wnd) g_theConfig=0;
  908. EndDialog(wnd,1);
  909. break;
  910. }
  911. break;
  912. }
  913. return 0;
  914. }
  915. int MIDI_core::Config(HWND p)
  916. {
  917. int r;
  918. db:
  919. r=WASABI_API_DIALOGBOXW(IDD_CONFIG,p,CfgProc);
  920. if (r==666)
  921. {
  922. cfg_var::config_reset();
  923. goto db;
  924. }
  925. return r;
  926. }
  927. int DoAboutMessageBox(HWND parent, wchar_t* title, wchar_t* message)
  928. {
  929. MSGBOXPARAMSW msgbx = {sizeof(MSGBOXPARAMSW),0};
  930. msgbx.lpszText = message;
  931. msgbx.lpszCaption = title;
  932. msgbx.lpszIcon = MAKEINTRESOURCEW(102);
  933. msgbx.hInstance = GetModuleHandle(0);
  934. msgbx.dwStyle = MB_USERICON;
  935. msgbx.hwndOwner = parent;
  936. return MessageBoxIndirectW(&msgbx);
  937. }
  938. void About(HWND hwndParent)
  939. {
  940. wchar_t message[1024] = {0}, text[1024] = {0};
  941. WASABI_API_LNGSTRINGW_BUF(IDS_NULLSOFT_MIDI_PLAYER_OLD,text,1024);
  942. wsprintfW(message, WASABI_API_LNGSTRINGW(IDS_ABOUT_TEXT),
  943. mod.description, __DATE__);
  944. DoAboutMessageBox(hwndParent,text,message);
  945. }