有没有同学用过 RtAudio这个库?关于 getDefaultInput的请教

25 views
Skip to first unread message

Marco

unread,
Jul 30, 2014, 12:57:39 AM7/30/14
to shlug
如题, 在一个多声卡的环境下, alsa已经配置好, 让其中一个声卡成为默认, alsa自己的程序比如 arecord已经默认启用对应的设备录音。

但是现在用RtAudio写代码, 使用其 getDefaultInput(), 获取设备, 查看它的源代码, 永远返回0的。。。。

请问, 如何将alsa的默认声卡的默认capture转换为 RtAudio使用的设备ID?

谢谢!



--
LinuX
Violin
Canon EOS

Marco

unread,
Jul 30, 2014, 1:21:17 AM7/30/14
to shlug
好吧, 我先在 /proc/asound/ 里做点儿字符串处理, 然后再传递进去好了

Ben Luo

unread,
Jul 30, 2014, 1:35:02 AM7/30/14
to shlug

如果是realtime,还是考虑
RtAudio 对JACK的支持。JACK自己会处理和ALSA的交互吧。实时的音频,JACK应该是首选吧。

--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛中的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问https://groups.google.com/d/optout

Marco

unread,
Jul 30, 2014, 1:46:31 AM7/30/14
to shlug
怎么处理? 没接触过jack

Marco

unread,
Jul 30, 2014, 1:46:58 AM7/30/14
to shlug
def search_rtaudio_id_by_usbid(vid='0d8c', pid='000c'):
    card = None
    for c in glob('/proc/asound/card[0-9]'):
        f = c + '/usbid'
        if os.path.isfile(f):
            usbid = open(f).read().strip()
            if usbid == vid + ':' + pid:
                card = c[-1]
                break
    
    if not card:
        print 'no such CARD'
        return False
    
    card = '%02d' %(int(card))
    for no, line in enumerate(open('/proc/asound/pcm').readlines()):
        if line[:2] == card:
            return no
    
    return False
Reply all
Reply to author
Forward
0 new messages