英文:
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);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论