-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMIDI.c
48 lines (41 loc) · 928 Bytes
/
MIDI.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Created by patryk on 28.06.16.
*/
#include "MIDI.h"
UINT MIDI_listDevices(HWND list) {
UINT count, i, lcnt;
MIDIOUTCAPS device;
MMRESULT res;
count = midiOutGetNumDevs();
if(!count) {
SendMessage(list, LB_ADDSTRING, 0, (LPARAM) TEXT("No MIDI devices found."));
}
else {
for(i = lcnt = 0; i < count; i++) {
res = midiOutGetDevCaps(i, &device, sizeof device);
if(res == MMSYSERR_NOERROR) {
SendMessageW(list, LB_ADDSTRING, 0, (LPARAM) device.szPname);
SendMessageW(list, LB_SETITEMDATA, lcnt++, (LPARAM) i);
}
}
}
return count;
}
INT32 MIDI_getDeviceByName(LPWSTR name) {
UINT count, i;
MIDIOUTCAPS device;
MMRESULT res;
count = midiOutGetNumDevs();
if(!count) {
return -1;
}
else {
for(i = 0; i < count; i++) {
res = midiOutGetDevCaps(i, &device, sizeof device);
if(res == MMSYSERR_NOERROR && !lstrcmp(name, device.szPname)) {
return i;
}
}
}
return -1;
}