Ubuntuとサウンドカード
結構有名らしいけど、Linuxで複数のサウンドカードをつないでいると、認識の順番がコロコロと変わる。うちのマシンはマザーボードに積まれているやつ、USB Audio(音楽鑑賞用)、USB Midiが認識されていて、/proc/asound/modulesは3つ表示される。
0 snd_hda_intel 1 snd_usb_audio 2 snd_usb_audio
で、この順番がコロコロ変わるのだ。mplayerなどでの演奏なら、番号が変わっても、大した問題ではない。aplay -lでデバイスの名前を見て、
**** ハードウェアデバイス PLAYBACK のリスト **** カード 0: Intel [HDA Intel], デバイス 0: ALC883 Analog [ALC883 Analog] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 0: Intel [HDA Intel], デバイス 1: ALC883 Digital [ALC883 Digital] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 1: Audio [YAMAHA DP-U50 USB Audio], デバイス 0: USB Audio [USB Audio] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 1: Audio [YAMAHA DP-U50 USB Audio], デバイス 1: USB Audio [USB Audio #1] サブデバイス: 1/1 サブデバイス #0: subdevice #0
この"Intel"とか"Audio"という名前を使えば良い。
mplayer -ao alsa:device=hw=Intel no08-1.mp3
問題は、YouTubeみたいにブラウザから直接ストリーミングで再生するようなケースで、これはデバイス番号0決め打ちのようで、設定ができない。で、腰を据えてちょっと調べてみた。
このあたりの情報によると、/etc/modprobe.d/soundにデバイスごとにindexを書いてやれば、その順番に認識されるとある。しかし、今回はusb-audioが2つあって、色々試してみたけど、うまくいかなかった。
そういう場合についてはMultipleUSBAudioDevicesに書いてあった。まずlsusbで、USBの情報を表示する。
Bus 001 Device 006: ID 0424:2228 Standard Microsystems Corp. Bus 001 Device 005: ID 0424:2503 Standard Microsystems Corp. Bus 001 Device 003: ID 0424:2504 Standard Microsystems Corp. Bus 001 Device 001: ID 0000:0000 Bus 008 Device 003: ID 152d:2338 Bus 008 Device 001: ID 0000:0000 Bus 007 Device 001: ID 0000:0000 Bus 002 Device 002: ID 046d:c51a Logitech, Inc. Bus 002 Device 001: ID 0000:0000 Bus 003 Device 002: ID 0499:3102 Yamaha Corp. Bus 003 Device 001: ID 0000:0000 Bus 005 Device 004: ID 0582:0009 Roland Corp. Bus 005 Device 001: ID 0000:0000 Bus 006 Device 001: ID 0000:0000 Bus 004 Device 001: ID 0000:0000
IDの後にあるのが、デバイス識別用のベンダIDと、プロダクトIDだ。YamahaがUSBオーディオで、RolandがMIDIなので、0499:3102, 0582:0009がそれになる。
で、USBのドライバの情報をmodinfo snd-usb-audioで表示すると、最後の方にパラメータの説明が表示される。
parm: index:Index value for the USB audio adapter. (array of int) parm: id:ID string for the USB audio adapter. (array of charp) parm: enable:Enable USB audio adapter. (array of bool) parm: vid:Vendor ID for the USB audio device. (array of int) parm: pid:Product ID for the USB audio device. (array of int) parm: nrpacks:Max. number of packets per URB. (int) parm: async_unlink:Use async unlink mode. (bool) parm: device_setup:Specific device setup (if needed). (array of int)
これまで見た説明はindexを使用したものだったけど、これ以外にもvidとpidでベンダIDとプロダクトIDを指定できることが分かる。そこで、/etc/modprobe.d/soundを以下のように編集。
options snd_hda_intel index=0 options snd_usb_audio index=1,2 vid=0x0499,0x0582 pid=0x3102,0x0009
めでたく、3つのデバイスが思った通りの順序で認識されるようになった... ように見える。今のところ。しばらくは、これで様子見だな。





