Proper audio setup?

Hello there!

I'm new to Archlinux and this is my first post on this forum. I've been using Ubuntu for about 2 years but I learned nothing about Linux. Now I have fast system where I installed only those things I wanted and I feel I accomplished something. I was able to setup my internet connection, installed X11 and then Openbox with some themes and icons. I also installed Tint2 and Dropbox which shows on it nicely and managed to install Pacaur which manages AUR packages nicely. I was even clever enough to mount my Windows and Ubuntu partitions and copy-pasted script which pops-up when USB drive is inserted. All in all I have now fairly well performing system and I would be ready to run cfdisk and delete my Ubuntu partition if there weren't one big annoyance: SOUND.

In every situation I presented above I was complete noob but with Google and magnificent Archwiki I learned everything I needed to overcome all problems. Even though there's still much work to do, I have at least a glimpse on what is it about and where should I look for help. But one thing I'm completely lost in is sound configuration.According to alsamixer I have 3 devices:0. Lexicon Alpha (USB sound card)1. HDA Intel2. HDA ATI HDMI

Since I have my speakers plugged into Lexicon Alpha, and plan to use it solely, I don't care about the two others. I have ALSA (default from installation) and I also installed pulseaudio in an effort to solve my sound issues. Here's a list of features I expect to get from my sound setup (sorted by priority):1. Play music & videos via VLC and Youtube.2. Record basic input from my microphone.3. Complete audio workstation: MIDI sequencing by Rosegarden with soundfonts provided by Qsynth (or something else), drum writing done in Hydrogen, everything synchronized via Jack and put it into Ardour where I can record other sound from outside.

Right now, I'm trying to get point 1 working. VLC seems to work after I directly told it to use ALSA. Youtube randomly works. Right now it's fine but sometimes it works only after reinstallation of flashplugin and sometimes not at all. But my goal is not only to get something working. I'd like to know what I'm doing. Are there any configuration files where I could easily tell my system what soundcards to run (or not to)? How to tell Firefox to use one particular driver or sound card? Is it neccessary to have Pulseaudio installed? If possible I'd love to get rid of it. I'm totally lost and know nothing about how sound works on linux. I remember that I was able to run all 3 points in my Ubuntu days but I was as lost as I'm now and it had stopped working some time ago as well.

And yes, I read ALSA Archwiki, Pulseaudio documentation and various Google results. I found solutions like copy-paste this to get that working but none of them helped me in terms of understanding my sound system. Most of them I didn't onderstand. Here's a summary of what I'm trying to accomplish:

- Get point 1 working at 100% (other points are not that important and I think I should be able to figure them out once I know how to do the rest).- Know whether Pulseaudio is neccessary for point 1, 2 and 3.- Know how to configure my system to use only Lexicon Alpha (but with an option to take it back).- Overall Improve my knowledge of audio in Linux to the point where I'm able to determine what to Google for.

I'd be glad if someone helped me out or at least point me at a reasonable source of information.

Re: Proper audio setup?

Kubouch wrote:

3. Complete audio workstation: MIDI sequencing by Rosegarden with soundfonts provided by Qsynth (or something else), drum writing done in Hydrogen, everything synchronized via Jack and put it into Ardour where I can record other sound from outside.

Re: Proper audio setup?

Thanks, breps, this is helpful. I'll look into the file, it seems to be very well descripted. Also good to know Pulseaudio isn't necessary. I like to keep things as small as possible.

breps wrote:

Kubouch wrote:

Complete audio workstation

Ah, in that case you probably want a realtime kernel, or maybe the BFS scheduler with threadirqs will be sufficient. Maybe Gentoo Studio has good ideas.

I'm aware of realtime kernels but I'd rather solve my basic issues first, then delete Ubuntu and after that I can play with kernels. I'll look into it, eventually, when the right time comes.

2ManyDogs wrote:

Kubouch wrote:

3. Complete audio workstation: MIDI sequencing by Rosegarden with soundfonts provided by Qsynth (or something else), drum writing done in Hydrogen, everything synchronized via Jack and put it into Ardour where I can record other sound from outside.

As I replied to breps, my main priority is to get my bearings, set up my sound to work reliably and then fiddle with recording. But LinuxBBQ is another distro, isn't it? I'd rather not reinstall my system once again. But thanks for the reply, anyway. I can at least look at the list of applications to broaden my horizons.

Re: Proper audio setup?

Kubouch wrote:

As I replied to breps, my main priority is to get my bearings, set up my sound to work reliably and then fiddle with recording. But LinuxBBQ is another distro, isn't it? I'd rather not reinstall my system once again. But thanks for the reply, anyway. I can at least look at the list of applications to broaden my horizons.

Yes, it's another distro. But it's already set up with the applications on your list and a real-time kernel, so installing it would probably be easier than installing and configuring everything in Arch. But hey, it's your system. Just trying to show you some options.

Re: Proper audio setup?

I progressed. According to ALSA Archwiki instructions, in ~/.asoundrc I defined Lexicon Alpha to be my default sound card. Then I installed alsaequal and copy-pasted the script into ~/.asoundrc. After running alsamixer -D equal, sound is on. If I don't install system-wide equalizer, sound in Youtube doesn't work even though I have specified my default sound card already. Isn't that wierd? Isn't equalizer only responsible for controlling volume levels, muting channels and such? In alsamixer my USB sound card has no options avaliable to change so it would be pointless to use it if its absence didn't prevent me playing videos on Youtube.

Re: Proper audio setup?

Thanks for response, litemotiv. I have both alsa-lib and alsa-utils. Does it mean that only these two packages (and their dependencies ofc) are required for successful playback both from system and flashplugin?

Here's what I currently have in .asoundrc:

defaults.pcm.card 1defaults.pcm.device 0defaults.ctl.card 1

ctl.equal { type equal;}

pcm.plugequal { type equal; # Modify the line below if you do not # want to use sound card 0. #slave.pcm "plughw:0,0"; #by default we want to play from more sources at time: slave.pcm "plug:dmix";}#pcm.equal { # If you don't want the equalizer to be your # default soundcard comment the following # line and uncomment the above line. (You can # choose it as the output device by addressing # it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)pcm.!default { type plug; slave.pcm plugequal;}

The first three lines should define Lexicon Alpha to be the default soundcard.Next comes the script which - as I understand it - makes me use system-wide equalizer. I don't really understand what it is and what it is good for but if it isn't necessary, I'll probably get rid of it.

I don't really know what 'dmix' is so I don't think I use it unless it's default part of my system. When I do

Re: Proper audio setup?

Kubouch wrote:

Thanks for response, litemotiv. I have both alsa-lib and alsa-utils. Does it mean that only these two packages (and their dependencies ofc) are required for successful playback both from system and flashplugin?

Yes it's really quite simple, if the Lexicon is card 1 then this should be enough to use it from any application:

defaults.pcm.card 1
defaults.pcm.device 0
defaults.ctl.card 1

However, by default this only allows 1 program at a time to use the audio output. To work around this you need an audiocard with hardware mixing (which your card doesn't do i think), or you can enable dmix to do the mixing in software.

To achieve this install the "alsa-plugins" package and use this .asoundrc:

Re: Proper audio setup?

So right now, everything works quite fine. I have uninstalled flashplugin which apparently helped a lot. Right now I have only alsa-lib, alsa-utils and alsamixer installed. In .asoundrc I have only the first three lines.

litemotiv wrote:

However, by default this only allows 1 program at a time to use the audio output. To work around this you need an audiocard with hardware mixing (which your card doesn't do i think), or you can enable dmix to do the mixing in software....

I can play music from PC and internet sounds at the same time so there's probably no issue.

On rare occasions, however, I don't get sound from Firefox and need to restart. If that happens and I open alsamixer, I see that my default card is set to Intel for some reason. This happens mostly when I play Youtube video right after boot. It doesn't happen often, though.

All in all, I can live with the playback setup I have right now. The only thing which troubles me a bit is why sometimes after starting Firefox my default sound is changed to the wrong one. I think the real fun will begin when I decide to record something :-).

Re: Proper audio setup?

Card numbering may not be consistent between boots. I prefer to use the naming scheme - I don't remember off the top of my head how it works, but it's in the docs.

I just wanted to add that I learned quite a bit from breb's example asoundrc a while back (thanks BTW), but I also found the alsa wiki to be a great info source - not the alsa page on the arch wiki, though that is good, but the alsa-project wiki (which for some odd reason is very low on the results list whenever I search for it):

Re: Proper audio setup?

If the points in your list are thus far all that you care about when it comes to audio i would propose another setup that simplified things for me a lot.

You could:1. Start you're jackserver at startup via systemd using your prefered soundcard.2. Use jack-plugins for VLC and flash.

This would avoid using pulseaudio which is in my opinion a pita when you also want to do some recording and playing with hydrogen etc.It would still be possible to dynamically load other soundcards at startup if your primary is not available via a simple script and fixed slots for each soundcard in /etc/modprobe.d/alsa-base.conf .

Edit:Getting basic setup working is probably a good idea, nevertheless i learned that compiling a realtime kernel is a breeze on arch, there is an excellent linux-rt package in the aur.

Re: Proper audio setup?

I think the easiest solution today is route pulseaudio to jack when I use recording software. If you use the jack2-dbus you can even playing sound with pulseaudio, start jack realese alsa from pulseaudio, and plug in the soundstream from pulseaudio in jack instead, without loosing the soundstream you playing.

Re: Proper audio setup?

I used the index method (there's also a "slot" method, see alsa website) to make sure that my usb card was always hw0:0 (default card). Without the index assignment, my onboard intel audio would sometimes become default.