Skip to content

Instantly share code, notes, and snippets.

@t-mat
Created December 2, 2014 10:21
Show Gist options
  • Save t-mat/d422d9e167b171050408 to your computer and use it in GitHub Desktop.
Save t-mat/d422d9e167b171050408 to your computer and use it in GitHub Desktop.
WIN32 : Enumerate MIDI Devices
// Enumerate MIDI Devices
#include <windows.h>
#include <stdio.h>
#include <locale.h>
#pragma comment(lib, "winmm.lib")
int main() {
setlocale(LC_ALL, "");
const UINT_PTR nMidiOut = midiOutGetNumDevs();
for(UINT_PTR iMidiOut = 0; iMidiOut < nMidiOut; ++iMidiOut) {
MIDIOUTCAPS moc {};
midiOutGetDevCaps(iMidiOut, &moc, sizeof(moc));
wprintf(L"MIDI Out#%2d [%s]\n", iMidiOut, moc.szPname);
}
const UINT_PTR nMidiIn = midiInGetNumDevs();
for(UINT_PTR iMidiIn = 0; iMidiIn < nMidiIn; ++iMidiIn) {
MIDIINCAPS mic {};
midiInGetDevCaps(iMidiIn, &mic, sizeof(mic));
wprintf(L"MIDI Inp#%2d [%s]\n", iMidiIn, mic.szPname);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment