f@0
|
1 #include "app_main.h"
|
f@0
|
2
|
f@0
|
3 #ifdef OS_WIN
|
f@0
|
4 #include "asio.h"
|
f@0
|
5 #endif
|
f@0
|
6
|
f@0
|
7 const int kNumIOVSOptions = 9;
|
f@0
|
8 const int kNumSIGVSOptions = 7;
|
f@0
|
9
|
f@0
|
10 const std::string kIOVSOptions[kNumIOVSOptions] = {"32", "64", "128", "256", "512", "1024", "2048", "4096", "8192" };
|
f@0
|
11 const std::string kSIGVSOptions[kNumSIGVSOptions] = {"16", "32", "64", "128", "256", "512", "1024" };
|
f@0
|
12
|
f@0
|
13 // check the input and output devices, find matching srs
|
f@0
|
14 void PopulateSampleRateList(HWND hwndDlg, RtAudio::DeviceInfo* inputDevInfo, RtAudio::DeviceInfo* outputDevInfo)
|
f@0
|
15 {
|
f@0
|
16 char buf[20];
|
f@0
|
17
|
f@0
|
18 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR,CB_RESETCONTENT,0,0);
|
f@0
|
19
|
f@0
|
20 std::vector<int> matchedSRs;
|
f@0
|
21
|
f@0
|
22 for (int i=0; i<inputDevInfo->sampleRates.size(); i++)
|
f@0
|
23 {
|
f@0
|
24 for (int j=0; j<outputDevInfo->sampleRates.size(); j++)
|
f@0
|
25 {
|
f@0
|
26 if(inputDevInfo->sampleRates[i] == outputDevInfo->sampleRates[j])
|
f@0
|
27 matchedSRs.push_back(inputDevInfo->sampleRates[i]);
|
f@0
|
28 }
|
f@0
|
29 }
|
f@0
|
30
|
f@0
|
31 for (int k=0; k<matchedSRs.size(); k++)
|
f@0
|
32 {
|
f@0
|
33 wsprintf(buf,"%i",matchedSRs[k]);
|
f@0
|
34 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
35 }
|
f@0
|
36
|
f@0
|
37 LRESULT sridx = SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR, CB_FINDSTRINGEXACT, -1, (LPARAM)gState->mAudioSR);
|
f@0
|
38 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR,CB_SETCURSEL, sridx, 0);
|
f@0
|
39 }
|
f@0
|
40
|
f@0
|
41 void PopulateAudioInputList(HWND hwndDlg, RtAudio::DeviceInfo* info)
|
f@0
|
42 {
|
f@0
|
43 char buf[20];
|
f@0
|
44
|
f@0
|
45 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_L,CB_RESETCONTENT,0,0);
|
f@0
|
46 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_RESETCONTENT,0,0);
|
f@0
|
47
|
f@0
|
48 int i;
|
f@0
|
49
|
f@0
|
50 for (i=0; i<info->inputChannels -1; i++)
|
f@0
|
51 {
|
f@0
|
52 // for (int i=0; i<info.inputChannels; i++) {
|
f@0
|
53 wsprintf(buf,"%i",i+1);
|
f@0
|
54 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_L,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
55 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
56 }
|
f@0
|
57
|
f@0
|
58 // TEMP
|
f@0
|
59 wsprintf(buf,"%i",i+1);
|
f@0
|
60 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
61
|
f@0
|
62 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_L,CB_SETCURSEL, gState->mAudioInChanL - 1, 0);
|
f@0
|
63 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_SETCURSEL, gState->mAudioInChanR - 1, 0);
|
f@0
|
64 }
|
f@0
|
65
|
f@0
|
66 void PopulateAudioOutputList(HWND hwndDlg, RtAudio::DeviceInfo* info)
|
f@0
|
67 {
|
f@0
|
68 char buf[20];
|
f@0
|
69
|
f@0
|
70 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_L,CB_RESETCONTENT,0,0);
|
f@0
|
71 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_RESETCONTENT,0,0);
|
f@0
|
72
|
f@0
|
73 int i;
|
f@0
|
74
|
f@0
|
75 // for (int i=0; i<info.outputChannels; i++) {
|
f@0
|
76 for (i=0; i<info->outputChannels -1; i++)
|
f@0
|
77 {
|
f@0
|
78
|
f@0
|
79 wsprintf(buf,"%i",i+1);
|
f@0
|
80 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_L,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
81 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
82 }
|
f@0
|
83
|
f@0
|
84 // TEMP
|
f@0
|
85 wsprintf(buf,"%i",i+1);
|
f@0
|
86 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
87
|
f@0
|
88 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_L,CB_SETCURSEL, gState->mAudioOutChanL - 1, 0);
|
f@0
|
89 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_SETCURSEL, gState->mAudioOutChanR - 1, 0);
|
f@0
|
90 }
|
f@0
|
91
|
f@0
|
92 // This has to get called after any change to audio driver/in dev/out dev
|
f@0
|
93 void PopulateDriverSpecificControls(HWND hwndDlg)
|
f@0
|
94 {
|
f@0
|
95 #ifdef OS_WIN
|
f@0
|
96 int driverType = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_DRIVER, CB_GETCURSEL, 0, 0);
|
f@0
|
97 if(driverType) //ASIO
|
f@0
|
98 {
|
f@0
|
99 ComboBox_Enable(GetDlgItem(hwndDlg, IDC_COMBO_AUDIO_IN_DEV), FALSE);
|
f@0
|
100 Button_Enable(GetDlgItem(hwndDlg, IDC_BUTTON_ASIO), TRUE);
|
f@0
|
101 }
|
f@0
|
102 else
|
f@0
|
103 {
|
f@0
|
104 ComboBox_Enable(GetDlgItem(hwndDlg, IDC_COMBO_AUDIO_IN_DEV), TRUE);
|
f@0
|
105 Button_Enable(GetDlgItem(hwndDlg, IDC_BUTTON_ASIO), FALSE);
|
f@0
|
106 }
|
f@0
|
107 #endif
|
f@0
|
108
|
f@0
|
109 int indevidx = 0;
|
f@0
|
110 int outdevidx = 0;
|
f@0
|
111
|
f@0
|
112 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_RESETCONTENT,0,0);
|
f@0
|
113 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_DEV,CB_RESETCONTENT,0,0);
|
f@0
|
114
|
f@0
|
115 for (int i = 0; i<gAudioInputDevs.size(); i++)
|
f@0
|
116 {
|
f@0
|
117 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_ADDSTRING,0,(LPARAM)GetAudioDeviceName(gAudioInputDevs[i]).c_str());
|
f@0
|
118
|
f@0
|
119 if(!strcmp(GetAudioDeviceName(gAudioInputDevs[i]).c_str(), gState->mAudioInDev))
|
f@0
|
120 indevidx = i;
|
f@0
|
121 }
|
f@0
|
122
|
f@0
|
123 for (int i = 0; i<gAudioOutputDevs.size(); i++)
|
f@0
|
124 {
|
f@0
|
125 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_DEV,CB_ADDSTRING,0,(LPARAM)GetAudioDeviceName(gAudioOutputDevs[i]).c_str());
|
f@0
|
126
|
f@0
|
127 if(!strcmp(GetAudioDeviceName(gAudioOutputDevs[i]).c_str(), gState->mAudioOutDev))
|
f@0
|
128 outdevidx = i;
|
f@0
|
129 }
|
f@0
|
130
|
f@0
|
131 #ifdef OS_WIN
|
f@0
|
132 if(driverType)
|
f@0
|
133 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_SETCURSEL, outdevidx, 0);
|
f@0
|
134 else
|
f@0
|
135 #endif
|
f@0
|
136 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_SETCURSEL, indevidx, 0);
|
f@0
|
137
|
f@0
|
138 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_DEV,CB_SETCURSEL, outdevidx, 0);
|
f@0
|
139
|
f@0
|
140 RtAudio::DeviceInfo inputDevInfo = gDAC->getDeviceInfo(gAudioInputDevs[indevidx]);
|
f@0
|
141 RtAudio::DeviceInfo outputDevInfo = gDAC->getDeviceInfo(gAudioOutputDevs[outdevidx]);
|
f@0
|
142
|
f@0
|
143 PopulateAudioInputList(hwndDlg, &inputDevInfo);
|
f@0
|
144 PopulateAudioOutputList(hwndDlg, &outputDevInfo);
|
f@0
|
145 PopulateSampleRateList(hwndDlg, &inputDevInfo, &outputDevInfo);
|
f@0
|
146 }
|
f@0
|
147
|
f@0
|
148 void PopulateAudioDialogs(HWND hwndDlg)
|
f@0
|
149 {
|
f@0
|
150 PopulateDriverSpecificControls(hwndDlg);
|
f@0
|
151
|
f@0
|
152 if (gState->mAudioInIsMono)
|
f@0
|
153 {
|
f@0
|
154 SendDlgItemMessage(hwndDlg,IDC_CB_MONO_INPUT,BM_SETCHECK, BST_CHECKED,0);
|
f@0
|
155 }
|
f@0
|
156 else
|
f@0
|
157 {
|
f@0
|
158 SendDlgItemMessage(hwndDlg,IDC_CB_MONO_INPUT,BM_SETCHECK, BST_UNCHECKED,0);
|
f@0
|
159 }
|
f@0
|
160
|
f@0
|
161 //Populate IOVS combobox
|
f@0
|
162 for (int i = 0; i< kNumIOVSOptions; i++)
|
f@0
|
163 {
|
f@0
|
164 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IOVS,CB_ADDSTRING,0,(LPARAM)kIOVSOptions[i].c_str());
|
f@0
|
165 }
|
f@0
|
166
|
f@0
|
167 LRESULT iovsidx = SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IOVS, CB_FINDSTRINGEXACT, -1, (LPARAM)gState->mAudioIOVS);
|
f@0
|
168 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IOVS, CB_SETCURSEL, iovsidx, 0);
|
f@0
|
169
|
f@0
|
170 //Populate SIGVS combobox
|
f@0
|
171 for (int i = 0; i< kNumSIGVSOptions; i++)
|
f@0
|
172 {
|
f@0
|
173 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SIGVS,CB_ADDSTRING,0,(LPARAM)kSIGVSOptions[i].c_str());
|
f@0
|
174 }
|
f@0
|
175
|
f@0
|
176 LRESULT sigvsidx = SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SIGVS, CB_FINDSTRINGEXACT, -1, (LPARAM)gState->mAudioSigVS);
|
f@0
|
177 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SIGVS, CB_SETCURSEL, sigvsidx, 0);
|
f@0
|
178 }
|
f@0
|
179
|
f@0
|
180 bool PopulateMidiDialogs(HWND hwndDlg)
|
f@0
|
181 {
|
f@0
|
182 if ( !gMidiIn || !gMidiOut )
|
f@0
|
183 return false;
|
f@0
|
184 else
|
f@0
|
185 {
|
f@0
|
186 for (int i=0; i<gMIDIInputDevNames.size(); i++ )
|
f@0
|
187 {
|
f@0
|
188 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_DEV,CB_ADDSTRING,0,(LPARAM)gMIDIInputDevNames[i].c_str());
|
f@0
|
189 }
|
f@0
|
190
|
f@0
|
191 LRESULT indevidx = SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_DEV,CB_FINDSTRINGEXACT, -1, (LPARAM)gState->mMidiInDev);
|
f@0
|
192
|
f@0
|
193 // if the midi port name wasn't found update the ini file, and set to off
|
f@0
|
194 if(indevidx == -1)
|
f@0
|
195 {
|
f@0
|
196 strcpy(gState->mMidiInDev, "off");
|
f@0
|
197 UpdateINI();
|
f@0
|
198 indevidx = 0;
|
f@0
|
199 }
|
f@0
|
200
|
f@0
|
201 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_DEV,CB_SETCURSEL, indevidx, 0);
|
f@0
|
202
|
f@0
|
203 for (int i=0; i<gMIDIOutputDevNames.size(); i++ )
|
f@0
|
204 {
|
f@0
|
205 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_DEV,CB_ADDSTRING,0,(LPARAM)gMIDIOutputDevNames[i].c_str());
|
f@0
|
206 }
|
f@0
|
207
|
f@0
|
208 LRESULT outdevidx = SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_DEV,CB_FINDSTRINGEXACT, -1, (LPARAM)gState->mMidiOutDev);
|
f@0
|
209
|
f@0
|
210 // if the midi port name wasn't found update the ini file, and set to off
|
f@0
|
211 if(outdevidx == -1)
|
f@0
|
212 {
|
f@0
|
213 strcpy(gState->mMidiOutDev, "off");
|
f@0
|
214 UpdateINI();
|
f@0
|
215 outdevidx = 0;
|
f@0
|
216 }
|
f@0
|
217
|
f@0
|
218 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_DEV,CB_SETCURSEL, outdevidx, 0);
|
f@0
|
219
|
f@0
|
220 // Populate MIDI channel dialogs
|
f@0
|
221
|
f@0
|
222 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_CHAN,CB_ADDSTRING,0,(LPARAM)"all");
|
f@0
|
223 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_CHAN,CB_ADDSTRING,0,(LPARAM)"all");
|
f@0
|
224
|
f@0
|
225 char buf[20];
|
f@0
|
226
|
f@0
|
227 for (int i=0; i<16; i++)
|
f@0
|
228 {
|
f@0
|
229 wsprintf(buf,"%i",i+1);
|
f@0
|
230 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_CHAN,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
231 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_CHAN,CB_ADDSTRING,0,(LPARAM)buf);
|
f@0
|
232 }
|
f@0
|
233
|
f@0
|
234 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_CHAN,CB_SETCURSEL, (LPARAM)gState->mMidiInChan, 0);
|
f@0
|
235 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_CHAN,CB_SETCURSEL, (LPARAM)gState->mMidiOutChan, 0);
|
f@0
|
236
|
f@0
|
237 return true;
|
f@0
|
238 }
|
f@0
|
239 }
|
f@0
|
240
|
f@0
|
241 #ifdef OS_WIN
|
f@0
|
242 void PopulatePreferencesDialog(HWND hwndDlg)
|
f@0
|
243 {
|
f@0
|
244 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)"DirectSound");
|
f@0
|
245 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)"ASIO");
|
f@0
|
246 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_SETCURSEL, gState->mAudioDriverType, 0);
|
f@0
|
247
|
f@0
|
248 PopulateAudioDialogs(hwndDlg);
|
f@0
|
249 PopulateMidiDialogs(hwndDlg);
|
f@0
|
250 }
|
f@0
|
251
|
f@0
|
252 #elif defined OS_OSX
|
f@0
|
253 void PopulatePreferencesDialog(HWND hwndDlg)
|
f@0
|
254 {
|
f@0
|
255 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)"CoreAudio");
|
f@0
|
256 //SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)"Jack");
|
f@0
|
257 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_SETCURSEL, gState->mAudioDriverType, 0);
|
f@0
|
258
|
f@0
|
259 PopulateAudioDialogs(hwndDlg);
|
f@0
|
260 PopulateMidiDialogs(hwndDlg);
|
f@0
|
261 }
|
f@0
|
262 #endif
|
f@0
|
263
|
f@0
|
264 WDL_DLGRET PreferencesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
f@0
|
265 {
|
f@0
|
266 int v = 0;
|
f@0
|
267 switch(uMsg)
|
f@0
|
268 {
|
f@0
|
269 case WM_INITDIALOG:
|
f@0
|
270
|
f@0
|
271 PopulatePreferencesDialog(hwndDlg);
|
f@0
|
272 memcpy(gTempState, gState, sizeof(AppState)); // copy state to temp state
|
f@0
|
273
|
f@0
|
274 return TRUE;
|
f@0
|
275
|
f@0
|
276 case WM_COMMAND:
|
f@0
|
277 switch (LOWORD(wParam))
|
f@0
|
278 {
|
f@0
|
279 case IDOK:
|
f@0
|
280 if(memcmp(gActiveState, gState, sizeof(AppState)) != 0) // if state is different try to change audio
|
f@0
|
281 {
|
f@0
|
282 TryToChangeAudio();
|
f@0
|
283 }
|
f@0
|
284 EndDialog(hwndDlg, IDOK); // INI file will be changed see MainDialogProc
|
f@0
|
285 break;
|
f@0
|
286 case IDAPPLY:
|
f@0
|
287 TryToChangeAudio();
|
f@0
|
288 break;
|
f@0
|
289 case IDCANCEL:
|
f@0
|
290 EndDialog(hwndDlg, IDCANCEL);
|
f@0
|
291
|
f@0
|
292 // if state has been changed reset to previous state, INI file won't be changed
|
f@0
|
293 if (!AudioSettingsInStateAreEqual(gState, gTempState)
|
f@0
|
294 || !MIDISettingsInStateAreEqual(gState, gTempState))
|
f@0
|
295 {
|
f@0
|
296 memcpy(gState, gTempState, sizeof(AppState));
|
f@0
|
297
|
f@0
|
298 TryToChangeAudioDriverType();
|
f@0
|
299 ProbeAudioIO();
|
f@0
|
300 TryToChangeAudio();
|
f@0
|
301 }
|
f@0
|
302
|
f@0
|
303 break;
|
f@0
|
304
|
f@0
|
305 case IDC_COMBO_AUDIO_DRIVER:
|
f@0
|
306 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
307 {
|
f@0
|
308
|
f@0
|
309 v = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_DRIVER, CB_GETCURSEL, 0, 0);
|
f@0
|
310
|
f@0
|
311 if(v != gState->mAudioDriverType)
|
f@0
|
312 {
|
f@0
|
313 gState->mAudioDriverType = v;
|
f@0
|
314
|
f@0
|
315 TryToChangeAudioDriverType();
|
f@0
|
316 ProbeAudioIO();
|
f@0
|
317
|
f@0
|
318 strcpy(gState->mAudioInDev,GetAudioDeviceName(gAudioInputDevs[0]).c_str());
|
f@0
|
319 strcpy(gState->mAudioOutDev,GetAudioDeviceName(gAudioOutputDevs[0]).c_str());
|
f@0
|
320
|
f@0
|
321 // Reset IO
|
f@0
|
322 gState->mAudioOutChanL = 1;
|
f@0
|
323 gState->mAudioOutChanR = 2;
|
f@0
|
324
|
f@0
|
325 PopulateAudioDialogs(hwndDlg);
|
f@0
|
326 }
|
f@0
|
327 }
|
f@0
|
328 break;
|
f@0
|
329
|
f@0
|
330 case IDC_COMBO_AUDIO_IN_DEV:
|
f@0
|
331 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
332 {
|
f@0
|
333 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_DEV, CB_GETCURSEL, 0, 0);
|
f@0
|
334 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_DEV, CB_GETLBTEXT, idx, (LPARAM) gState->mAudioInDev);
|
f@0
|
335
|
f@0
|
336 // Reset IO
|
f@0
|
337 gState->mAudioInChanL = 1;
|
f@0
|
338 gState->mAudioInChanR = 2;
|
f@0
|
339
|
f@0
|
340 PopulateDriverSpecificControls(hwndDlg);
|
f@0
|
341 }
|
f@0
|
342 break;
|
f@0
|
343
|
f@0
|
344 case IDC_COMBO_AUDIO_OUT_DEV:
|
f@0
|
345 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
346 {
|
f@0
|
347 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_DEV, CB_GETCURSEL, 0, 0);
|
f@0
|
348 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_DEV, CB_GETLBTEXT, idx, (LPARAM) gState->mAudioOutDev);
|
f@0
|
349
|
f@0
|
350 // Reset IO
|
f@0
|
351 gState->mAudioOutChanL = 1;
|
f@0
|
352 gState->mAudioOutChanR = 2;
|
f@0
|
353
|
f@0
|
354 PopulateDriverSpecificControls(hwndDlg);
|
f@0
|
355 }
|
f@0
|
356 break;
|
f@0
|
357
|
f@0
|
358 case IDC_COMBO_AUDIO_IN_L:
|
f@0
|
359 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
360 {
|
f@0
|
361 gState->mAudioInChanL = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_L, CB_GETCURSEL, 0, 0) + 1;
|
f@0
|
362
|
f@0
|
363 //TEMP
|
f@0
|
364 gState->mAudioInChanR = gState->mAudioInChanL + 1;
|
f@0
|
365 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_SETCURSEL, gState->mAudioInChanR - 1, 0);
|
f@0
|
366 //
|
f@0
|
367 }
|
f@0
|
368 break;
|
f@0
|
369
|
f@0
|
370 case IDC_COMBO_AUDIO_IN_R:
|
f@0
|
371 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
372 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_SETCURSEL, gState->mAudioInChanR - 1, 0); // TEMP
|
f@0
|
373 // gState->mAudioInChanR = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_R, CB_GETCURSEL, 0, 0);
|
f@0
|
374 break;
|
f@0
|
375
|
f@0
|
376 case IDC_COMBO_AUDIO_OUT_L:
|
f@0
|
377 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
378 {
|
f@0
|
379 gState->mAudioOutChanL = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_L, CB_GETCURSEL, 0, 0) + 1;
|
f@0
|
380
|
f@0
|
381 //TEMP
|
f@0
|
382 gState->mAudioOutChanR = gState->mAudioOutChanL + 1;
|
f@0
|
383 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_SETCURSEL, gState->mAudioOutChanR - 1, 0);
|
f@0
|
384 //
|
f@0
|
385 }
|
f@0
|
386 break;
|
f@0
|
387
|
f@0
|
388 case IDC_COMBO_AUDIO_OUT_R:
|
f@0
|
389 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
390 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_SETCURSEL, gState->mAudioOutChanR - 1, 0); // TEMP
|
f@0
|
391 // gState->mAudioOutChanR = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_R, CB_GETCURSEL, 0, 0);
|
f@0
|
392 break;
|
f@0
|
393
|
f@0
|
394 case IDC_CB_MONO_INPUT:
|
f@0
|
395 if (SendDlgItemMessage(hwndDlg,IDC_CB_MONO_INPUT, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
f@0
|
396 gState->mAudioInIsMono = 1;
|
f@0
|
397 else
|
f@0
|
398 gState->mAudioInIsMono = 0;
|
f@0
|
399 break;
|
f@0
|
400
|
f@0
|
401 case IDC_COMBO_AUDIO_IOVS: // follow through
|
f@0
|
402 case IDC_COMBO_AUDIO_SIGVS:
|
f@0
|
403 //TODO: FIX
|
f@0
|
404 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
405 {
|
f@0
|
406 int iovsidx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IOVS, CB_GETCURSEL, 0, 0);
|
f@0
|
407 int sigvsidx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SIGVS, CB_GETCURSEL, 0, 0);
|
f@0
|
408
|
f@0
|
409 if (atoi(kIOVSOptions[iovsidx].c_str()) < atoi(kSIGVSOptions[sigvsidx].c_str())) // if iovs < sigvs
|
f@0
|
410 {
|
f@0
|
411 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IOVS, CB_GETLBTEXT, iovsidx, (LPARAM) gState->mAudioIOVS);
|
f@0
|
412 strcpy(gState->mAudioSigVS, kSIGVSOptions[0].c_str()); // set sigvs to minimum
|
f@0
|
413 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SIGVS, CB_SETCURSEL, -1, 0);
|
f@0
|
414 }
|
f@0
|
415 else
|
f@0
|
416 {
|
f@0
|
417 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IOVS, CB_GETLBTEXT, iovsidx, (LPARAM) gState->mAudioIOVS);
|
f@0
|
418 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SIGVS, CB_GETLBTEXT, sigvsidx, (LPARAM) gState->mAudioSigVS);
|
f@0
|
419 }
|
f@0
|
420 }
|
f@0
|
421 break;
|
f@0
|
422 case IDC_COMBO_AUDIO_SR:
|
f@0
|
423 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
424 {
|
f@0
|
425 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SR, CB_GETCURSEL, 0, 0);
|
f@0
|
426 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SR, CB_GETLBTEXT, idx, (LPARAM) gState->mAudioSR);
|
f@0
|
427 }
|
f@0
|
428 break;
|
f@0
|
429
|
f@0
|
430 case IDC_BUTTON_ASIO:
|
f@0
|
431 if (HIWORD(wParam) == BN_CLICKED)
|
f@0
|
432 #ifdef OS_OSX
|
f@0
|
433 system("open \"/Applications/Utilities/Audio MIDI Setup.app\"");
|
f@0
|
434 #elif defined OS_WIN
|
f@0
|
435 if( gState->mAudioDriverType == DAC_ASIO && gDAC->isStreamRunning()) // TODO: still not right
|
f@0
|
436 ASIOControlPanel();
|
f@0
|
437 #endif
|
f@0
|
438 break;
|
f@0
|
439
|
f@0
|
440 case IDC_COMBO_MIDI_IN_DEV:
|
f@0
|
441 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
442 {
|
f@0
|
443 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_IN_DEV, CB_GETCURSEL, 0, 0);
|
f@0
|
444 SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_IN_DEV, CB_GETLBTEXT, idx, (LPARAM) gState->mMidiInDev);
|
f@0
|
445 ChooseMidiInput( gState->mMidiInDev );
|
f@0
|
446 }
|
f@0
|
447 break;
|
f@0
|
448
|
f@0
|
449 case IDC_COMBO_MIDI_OUT_DEV:
|
f@0
|
450 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
451 {
|
f@0
|
452 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_OUT_DEV, CB_GETCURSEL, 0, 0);
|
f@0
|
453 SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_OUT_DEV, CB_GETLBTEXT, idx, (LPARAM) gState->mMidiOutDev);
|
f@0
|
454 ChooseMidiOutput( gState->mMidiOutDev );
|
f@0
|
455 }
|
f@0
|
456 break;
|
f@0
|
457
|
f@0
|
458 case IDC_COMBO_MIDI_IN_CHAN:
|
f@0
|
459 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
460 gState->mMidiInChan = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_IN_CHAN, CB_GETCURSEL, 0, 0);
|
f@0
|
461 break;
|
f@0
|
462
|
f@0
|
463 case IDC_COMBO_MIDI_OUT_CHAN:
|
f@0
|
464 if (HIWORD(wParam) == CBN_SELCHANGE)
|
f@0
|
465 gState->mMidiOutChan = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_OUT_CHAN, CB_GETCURSEL, 0, 0);
|
f@0
|
466 break;
|
f@0
|
467
|
f@0
|
468 default:
|
f@0
|
469 break;
|
f@0
|
470 }
|
f@0
|
471 break;
|
f@0
|
472 default:
|
f@0
|
473 return FALSE;
|
f@0
|
474 }
|
f@0
|
475 return TRUE;
|
f@0
|
476 }
|
f@0
|
477
|
f@0
|
478 #ifdef _WIN32
|
f@0
|
479 void ClientResize(HWND hWnd, int nWidth, int nHeight)
|
f@0
|
480 {
|
f@0
|
481 RECT rcClient, rcWindow;
|
f@0
|
482 POINT ptDiff;
|
f@0
|
483 int screenwidth, screenheight;
|
f@0
|
484 int x, y;
|
f@0
|
485
|
f@0
|
486 screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
f@0
|
487 screenheight = GetSystemMetrics(SM_CYSCREEN);
|
f@0
|
488 x = (screenwidth / 2) - (nWidth/2);
|
f@0
|
489 y = (screenheight / 2) - (nHeight/2);
|
f@0
|
490
|
f@0
|
491 GetClientRect(hWnd, &rcClient);
|
f@0
|
492 GetWindowRect(hWnd, &rcWindow);
|
f@0
|
493 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
|
f@0
|
494 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
|
f@0
|
495 MoveWindow(hWnd, x, y, nWidth + ptDiff.x, nHeight + ptDiff.y, FALSE);
|
f@0
|
496 }
|
f@0
|
497 #endif
|
f@0
|
498
|
f@0
|
499 WDL_DLGRET MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
f@0
|
500 {
|
f@0
|
501 switch (uMsg)
|
f@0
|
502 {
|
f@0
|
503 case WM_INITDIALOG:
|
f@0
|
504
|
f@0
|
505 gHWND=hwndDlg;
|
f@0
|
506
|
f@0
|
507 if(!AttachGUI()) printf("couldn't attach gui\n");
|
f@0
|
508
|
f@0
|
509 #ifdef _WIN32
|
f@0
|
510 ClientResize(hwndDlg, GUI_WIDTH, GUI_HEIGHT);
|
f@0
|
511 //SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1)));
|
f@0
|
512 //SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1)));
|
f@0
|
513
|
f@0
|
514 #else // OSX
|
f@0
|
515 CenterWindow(hwndDlg);
|
f@0
|
516 #endif
|
f@0
|
517
|
f@0
|
518 ShowWindow(hwndDlg,SW_SHOW);
|
f@0
|
519 return 1;
|
f@0
|
520 case WM_DESTROY:
|
f@0
|
521 gHWND=NULL;
|
f@0
|
522
|
f@0
|
523 #ifdef _WIN32
|
f@0
|
524 PostQuitMessage(0);
|
f@0
|
525 #else
|
f@0
|
526 SWELL_PostQuitMessage(hwndDlg);
|
f@0
|
527 #endif
|
f@0
|
528
|
f@0
|
529 return 0;
|
f@0
|
530 case WM_CLOSE:
|
f@0
|
531 DestroyWindow(hwndDlg);
|
f@0
|
532 return 0;
|
f@0
|
533 // case WM_GETDLGCODE: {
|
f@0
|
534 // LPARAM lres;
|
f@0
|
535 // lres = CallWindowProc(/*TODO GET PROC */, hWnd, WM_GETDLGCODE, wParam, lParam);
|
f@0
|
536 // if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN && wParam == VK_LEFT) {
|
f@0
|
537 // lres |= DLGC_WANTMESSAGE;
|
f@0
|
538 // }
|
f@0
|
539 // return lres;
|
f@0
|
540 // }
|
f@0
|
541 case WM_COMMAND:
|
f@0
|
542 switch (LOWORD(wParam))
|
f@0
|
543 {
|
f@0
|
544 case ID_QUIT:
|
f@0
|
545 DestroyWindow(hwndDlg);
|
f@0
|
546 return 0;
|
f@0
|
547 case ID_ABOUT:
|
f@0
|
548 if(!gPluginInstance->HostRequestingAboutBox())
|
f@0
|
549 {
|
f@0
|
550 char version[50];
|
f@0
|
551 sprintf(version, BUNDLE_MFR"\nBuilt on " __DATE__);
|
f@0
|
552 MessageBox(hwndDlg,version, BUNDLE_NAME, MB_OK);
|
f@0
|
553 }
|
f@0
|
554 return 0;
|
f@0
|
555 case ID_PREFERENCES:
|
f@0
|
556 {
|
f@0
|
557 INT_PTR ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_PREF), hwndDlg, PreferencesDlgProc);
|
f@0
|
558
|
f@0
|
559 if(ret == IDOK)
|
f@0
|
560 {
|
f@0
|
561 UpdateINI();
|
f@0
|
562 }
|
f@0
|
563
|
f@0
|
564 return 0;
|
f@0
|
565 }
|
f@0
|
566 }
|
f@0
|
567 return 0;
|
f@0
|
568 }
|
f@0
|
569 return 0;
|
f@0
|
570 }
|