从C ++的MIDI设备获取ID [英] Get ID from MIDI devices in C++
问题描述
我既是音乐家又是程序员,并且想创建自己的程序来制作音乐. 在制作GUI之前,我将从C ++中的控制台应用程序开始.
I'm a musician and a programmer and would like to create my own program to make music. I'll start with a console application in C++ before I make a GUI.
我是C/C ++的新手,并且知道如何制作基本的控制台应用程序,并已阅读有关Win32 API的信息.
I'm quiet new to C/C++ and know how to make a basic console application and have read about the Win32 API.
我正在研究Win32应用程序中用于多媒体的MSDN,但发现了很多MIDI功能: http://msdn.microsoft.com/en-us/library/dd798495(VS.85).aspx
I was looking into MSDN for multimedia in Win32 applications and I found a lot of functions for MIDI: http://msdn.microsoft.com/en-us/library/dd798495(VS.85).aspx
我可以通过这种方式接收到多少MIDI设备:
I can receive how many MIDI devices are plugged in this way:
#include <windows.h>
#include <iostream>
using namespace std;
int main() {
cout << midiInGetNumDevs();
cout << " MIDI devices connected" << endl;
return 0;
}
但是现在我想用我认为的midiInGetID
函数和while
循环来查找这些设备的调用方式.有人可以帮我吗?该函数需要一个HMIDIIN
参数,而且由于几乎所有MIDI函数都使用此参数,因此我不知道该如何获取.
But now i want to find out how these devices are called, with the midiInGetID
function I think and a while
loop. Can somebody help me with this? The function requires a HMIDIIN
parameter and I don't know how I can get one since almost all the MIDI functions use this parameter.
我知道这不是最明显的话题,但是如果有人可以帮助我,那就太好了.
I know this is not the most obvious topic but it would be great if someone could help me.
谢谢:)
推荐答案
要获取信息,请循环调用 MIDIINCAPS 结构(您通过调用该函数时指向该结构的指针)以及有关第N个设备的信息.要打开设备并填充其他呼叫所需的HMIDIIN,请致电
To get information, you loop calling midiInGetDevCaps, with a first parameter varying from 0 included to the result of midiInGetNumDevs
excluded. Each call fills a MIDIINCAPS struct (you pass a pointer to the struct when you call the function) with information about the Nth device. To open a device, and fill the HMIDIIN needed for other calls, you call midiInOpen with the device number (again, 0 to N-1 included) as the second parameter.
除了输出名称用Out
代替In
(对于结构OUT
代替IN
)之外,相同的概念也适用于输出设备.
The same concept applies to output devices, except that the names have Out
instead of In
(and for the structures OUT
instead of IN
).
这篇关于从C ++的MIDI设备获取ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!