problem: MIDI sound heard on wrong playback device
Hello,
I recently got an M-Audio MobilePRE USB audio capture box. It works very nicely. It can record audio into Audacity, or into Ardour and Rosegarden via JACK. Playback from the same programs or with Amarok also works well. As does playback with Hydrogen via JACK. I therefore set it as the default soundcard using Quote:
The problem is MIDI sound is not being sent to this new card. For example, in Rosegarden, the Audio tracks are played on the USB device but all the MIDI sounds are played back on the on-board soundcard. I would like to hear both on the USB device. The searching I've done on the subject has only confused me more. It must be the way ALSA, Timidity or JACK are configured on my system, but I don't know what to look for. In JACK, I have experimented by connecting the General MIDI device output from Rosegarden to each of the four Timidity ports to no avail. I am using Kubuntu 8.04.1 "Hardy" with Linux version 2.6.24-22-generic (buildd@vernadsky) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Mon Nov 24 18:32:42 UTC 2008. The PC is a ThinkPad R40. Timidity is started at boot time as: Quote:
The output from "cat /proc/asound/cards" is: Quote:
Quote:
Quote:
Thanks! opc |
configure ALSA to route MIDI to USB sound device
Update: Rosegarden with QSynth works, however there is the following error:
Code:
ALSA lib pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave The following is heard on the USB audio device: Code:
aplay test.wav Code:
aplaymidi -p 128:0 test.mid Code:
Port Client name Port name I just don't understand ALSA. As stated above, I used the asoundconf command to set the default card, but the files in /proc/asound show the original order. Such as the contents of /proc/asound/cards shown above. Nowhere in /etc/modprobe.d is there a reference to "major-116", so I don't know where the default card gets set. So I guess my new question is if anybody knows where I can find a single source that can explain how ALSA works. I am unable to piece together a "big-picture" from what I've found so far. There are many disparate sources of information, some more than 5 years old. I would gladly RTFM, I just can't find it. I'll keep plugging away. -opc |
Update:
I now understand that when the default card is set using `asoundconf set-default-card <Card name>`, the change is made locally, at the user level. So when the system starts, the default card is not set to the USB device until the user logs in. The impact is that the Timidity daemon is started during the boot process so it gets "fixed" to the original sound card, which in my case is the on-board card. When I log in once the boot process has completed, the default card is changed per the commands in ~/.asoundrc and ~/.asoundrc.asoundconf, but timidity is oblivious to this change. Hence why MIDI tracks are heard via the on-board sound device, and all other audio is heard on the USB device. The temporary work around: The quick work-around is to restart the timidity daemon after logging in. Code:
sudo /etc/init.d/timidity restart Somewhat more permanent solution: Per the advice from https://help.ubuntu.com/community/SoundTroubleshooting, I updated /etc/modprobe.d/alsa-base so that my preferred sound card had index 0. I used Code:
cat /proc/asound/modules Code:
cat /proc/asound/cards Code:
options snd_usb_audio index=3 The only limitation is that the order is not fixed. If I remove or replace the web cam, or introduce another USB audio device like say a USB microphone, the order will change and this file will need to be manually changed again. For all intents and purposes I was able to solve my problem. Through my frustration I have grown a little and learned a few things. But I still feel that I am lacking knowledge of the fundamentals of ALSA. I just need time and continued tinkering, I guess. The next step is to get Rosegarden to work with Timidity, but this is beyond the scope of this thread. Some of the links that helped: http://alsa.opensrc.org/index.php/FAQ http://www.thepenguin.org.uk/alsa/ http://alsa.opensrc.org/index.php/.asoundrc http://ubuntuforums.org/showthread.php?t=619638 http://ubuntuforums.org/showthread.p...=disable+sound Hope some of this may be useful to others. -opc |
The easy answer is the re-index your soundcard modules so that the mobile pre is card 0. 0 is always default for applications that do not use alsa natively. And other apps that just don't know any better.
Answer B is to use the defaults.pcm.card 2 in your .asoundrc (which it sounds like alsaconf probably setup). Although if it's just Midi you're worried about, you can run Timidity to use Jack. Easier said than done in some cases. I had to recompile timidity for that option on my distro (debian). # timidity -iA -Oj (and maybe some other options) |
To simplify
If you don't use it, you might also go into your BIOS and see if you can disable the on board sound chip. My mother board manual recommends this if I install a sound card. Thereafter there's only one source for linux to deal with. |
Thanks for the replies. My system module died so I've been out of commission for a couple of weeks. I'm borrowing a laptop with Ubuntu Hardy. Not surprisingly, the same problem exists.
Nonetheless, I do have a fix for using Timidity with Rosegarden. As Shadow7 states in his post, Timidity must be run with the Jack option '-Oj'. Here is what I do now every time I log in: 1. sudo killall timidity 2. ... 3. qjackctl & 4. ALT-F2 and then type in the command 'timidity -iA -B2,8 -Oj -s 48000' I run all audio applications with a sample rate of 48000 Hz because I read somewhere that this and setting the periods per buffer to 3 are optimal for USB sound devices. Note: I am now running Linux kernel 2.6.24-23-rt #1 SMP PREEMPT RT Thu Nov 27 20:37:26 UTC 2008 i686. For the second issue regarding re-indexing the sound cards, the challenge is that I have multiple devices with the same module name. The M-Audio and the Webcam have the snd-usb-audio module name. Maybe there is a way to rename modules for easier boot-time manipulation. This will be the subject of different thread. The current solution is to limit the devices that register as snd-usb-audio to one. Thanks for the tip thorkelljarl. Alas, I cannot disable the on-board sound card in the bios. Cheers, -opc EDIT: There is no need to kill pulseaudio (step 2 above). This step was left over from some of the troubleshooting I was doing. Everything works fine with pulseaudio running. |
All times are GMT -5. The time now is 12:09 AM. |