如何获取适用于`snd_rawmidi_open()`的正确设备编号?

huangapple go评论64阅读模式
英文:

How to get correct device number for snd_rawmidi_open()?

问题

使用 amidi -l 命令,我得到了一些卡片的结果:

Dir 设备     名称
IO  hw:2,0,0  CLASSIC ORGAN CMK3 CLASSIC ORGA
IO  hw:3,0,0  CLASSIC ORGAN CMK3 CLASSIC ORGA
IO  hw:4,0,0  CLASSIC ORGAN CMK3 CLASSIC ORGA
IO  hw:5,0,0  Wireless USB Midi Tranceiver MI

我可以通过迭代声卡并使用 snd_card_get_longname() 比较卡片的名称来识别无线设备。但这些函数返回名称,而 snd_rawmidi_open 需要一个设备,即 hw:5,0,0。我如何迭代地确定无线收发器的设备号,以便在 snd_rawmidi_open 函数中使用它?

英文:

Using amidi -l I get a few card results:

Dir Device    Name
IO  hw:2,0,0  CLASSIC ORGAN CMK3 CLASSIC ORGA
IO  hw:3,0,0  CLASSIC ORGAN CMK3 CLASSIC ORGA
IO  hw:4,0,0  CLASSIC ORGAN CMK3 CLASSIC ORGA
IO  hw:5,0,0  Wireless USB Midi Tranceiver MI

I am able to identify the wireless device through iterating through sound cards using snd_card_next(), and then comparing the names of the cards using snd_card_get_longname().
But these return names, whereas snd_rawmidi_open needs a Device, i.e. hw:5,0,0. How can I iteratively determine the device number for the Wireless Transceiver, so I can use it for the snd_rawmidi_open function?

答案1

得分: 1

解决方案是简单地收集从snd_card_next获取的卡索引,并将其转换为形式为hw:card_index, 0, 0的条目,即:

sprintf(name, "hw:%d, 0,0", card_index);
英文:

The solution is to simply collect the card index taken from snd_card_next, and turn it into an entry of the form hw:card_index, 0, 0, i.e.

sprintf(name, "hw:%d, 0,0", card_index);

huangapple
  • 本文由 发表于 2023年6月16日 02:23:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76484513.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定