aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Mar 26, 11, 23:30    Linux sound HOWTO for ALSA users
Try at own risk

:: Code ::

$ Means run the command as a local user please
# Means run with root powers


Goal First we need to know what devices your distro currently detects and their capabilities

A list your devides

$ aplay -l (lowercase L) to list current devices (normally internal devices)

eg
:: Code ::
$ aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: STAC92xx Digital [STAC92xx Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

(If I owned an USB devices this is where it would show)


List usb devices including webcams

and run
$ lsusb for USB devices

eg

:: Code ::
$ lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
Bus 001 Device 003: ID 046d:0990 Logitech, Inc. QuickCam Pro 9000
Bus 001 Device 004: ID 10d6:1101 Actions Semiconductor Co., Ltd D-Wave 2GB MP4 Player / AK1025 MP3/MP4 Player


C Determine our current device capabilities
$ aplay -L (note the upper case)

eg
:: Code ::
$ aplay -L

null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Intel
    HDA Intel, STAC92xx Analog
    Default Audio Device
front:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Analog
    Front speakers
surround40:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Intel,DEV=0
    HDA Intel, STAC92xx Digital
    IEC958 (S/PDIF) Digital Audio Output


D What our current mixer levels are

I suggest you install alsa-utils so you can run
$ alsamixer

or
$ alsamixer -c0
(means card zero or the device that currently has index=0

so
$ alsamixer -c1

will show the next card and so on

eg
Mixer levels muted with some volumes not raised high enough



Arrow to the right or left to get to each setting and press
M to Mute or M to unmute the relevant setting

Press Page up or Page down to fast raise or lower volumes or
Press Up or Down arrows to go slower up or down

as per


F What is your current ALSA version?

:: Code ::
$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.23.


Or use your File Manager or Text editor to view that file's contents

From time to time, your kernel may 'lag' behind the latest Alsa or you may need the development package.

View the current version at
alsa-project.org/main/index.php/Main_Page

Note that I am lagging behind the latest release due to my choice of kernel.

Depending on your distro, you can use
alsa.opensrc.org/Quick_Install

Or you could install a third party kernel run by damentz whose forum is right here folks at

techpatterns.com/forums/forum-34.html

But from time to time his version lags the latest as well.

:: Code ::
uname -a
Linux sid 2.6.38-2.dmz.1-liquorix-686 #1 ZEN SMP PREEMPT Tue Mar 29 01:06:56 UTC 2011 i686 GNU/Linux

$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.23


I just looked at running module assistant...commands of

:: Code ::
$ su (or sudo su)
m-a update
m-a prepare alsa
m-a a-i alsa


But I have build errors visible in /var/cache/modass and in particular it reports that
-----------------------
The alsa-drivers in this package are designed for the following kernels:

- Vanilla 2.6.29 or earlier
- Vanilla 2.4.31 or earlier
- Vanilla 2.2.26 or earlier

It's not guaranteed that they work with any newer version than above
or modified kernels by distributors.
--------------------------------------------------------

I am now investigating a new command I found called

:: Code ::

m-a auto-install


Currently a fail for me due to my restricted sources apt list. it attempts to grab all the module sources.

G Blacklisting your sound module--Part one

You may have an USB keyboard and unable to borrow a PS/2 kb to add USB legacy support to your bios, so unable to DISABLE onboard sound

or You may want to try out various tweaks to your sound device or
You wish to test an USB device

One method on Debian Distros is to find out the name of your module that loads your onboard or "target" device and then add an entry to blacklist it

eg

$ lsmod | grep snd or cat /proc/asound/modules

I find its .....snd_hda_intel so I add it with root powers to file called
/etc/modprobe.d/alsa-base-blacklist.conf and add line and save contents as

blacklist snd_hda_intel

reboot to test with command lsmod

--If that fails change the blacklist entry to
blacklist snd-hda-intel
and reboot to test lsmod again please

If test was successful but you want sound back without rebooting use root powers to

eg

# modprobe snd_hda_intel

Or add an index value or quirk (discussed later)

G Blacklisting your sound module--Part two
Tinycorelinux and maybe other distros have a cheatcode or bootcode that allows you to have
blacklist snd_hda_intel as a kernel parameter for the grub1/2 entry

H Testing out model=string

By now you may guess that I first blacklist my module then manually load the model with a value or quirk.

In this section, I assume you understand how to blacklist your target module and have done so.

Next we need to know what a STACK is.

Count the coloured input and outputs for your sound device.
This is your stack count.
However my device also has a additional motherboard connector to connect a case connector to S/PDIF also known as an optical connector.

In a Debian distro, compressed documents can be found at
/usr/share/doc/alsa-base/driver

YMMV

As I have an intel card I have to do a few things

Firstly I need to know codec....its is showing in the alsamixer pix but

:: Code ::
$ cat /proc/asound/card0/codec#0 | grep Codec
Codec: SigmaTel STAC9221 A2

and going into the compressed file called HD-audio-Models.txt I find a listing for

-------------------------
STAC9220/9221
=============
ref Reference board
3stack D945 3stack
5stack D945 5stack + SPDIF
intel-mac-v1 Intel Mac Type 1
intel-mac-v2 Intel Mac Type 2
intel-mac-v3 Intel Mac Type 3
intel-mac-v4 Intel Mac Type 4
intel-mac-v5 Intel Mac Type 5
intel-mac-auto Intel Mac (detect type according to subsystem id)
macmini Intel Mac Mini (equivalent with type 3)
macbook Intel Mac Book (eq. type 5)
macbook-pro-v1 Intel Mac Book Pro 1st generation (eq. type 3)
macbook-pro Intel Mac Book Pro 2nd generation (eq. type 3)
imac-intel Intel iMac (eq. type 2)
imac-intel-20 Intel iMac (newer version) (eq. type 3)
ecs202 ECS/PC chips
dell-d81 Dell (unknown)
dell-d82 Dell (unknown)
dell-m81 Dell (unknown)
dell-m82 Dell XPS M1210
auto BIOS setup (default)
___________________________________

also my motherboard is called

ECS 945GCT-M2/1333 = cheap

and so I have a match between the codec and the mobo string and the stack count....so my model is 5stack.

--Note that you do not need to confirm your device multiple ways as you are free to try each string in turn eg model=ecs202 etc

so with root powers I can now do

# modprobe snd_hda_intel model=5stack

and checking alsamixer I get



You may like to tweak those setting further if you are using surround sound.

Once you are happy that the model=string works manually, you need to fix it to automatic.

There are a number of ways of doing this.

One way is to keep the existing blacklist entry and add a fullpathway command to your /etc/rc.local

eg
/sbin/modprobe snd_hda_intel model=5stack

rather than tweak the Debian file called
/etc/modprobe.d/alsa-base.conf

However, if you have 2 sound or devices or more, the alsa-base file is more ideal as that is where options should go.

So the main way after testing is complete is actually to remove the line from the blacklist file and add an options entry in the alsa-base file so the only entry for my model issue would be
-----------------------------------------------

options snd-hda-intel model=5stack
-----------------------------------------------

However, you may have noticed that my lsmod results and modprobe stuff earlier used understems and now I have changed to hyphens.

Depending on your distro, YMMV but I can not explain it ATM

OK This post is large enough so post 2 will be the next bit

< Edited by aus9 :: Apr 10, 11, 20:42 >
aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Mar 28, 11, 1:36    
A Index Values----Part one

If you have one sound device you can skip this section

If you have one internal sound device and one external device that is USB there a number of issues to discuss

1) Which device is your preferred device? Some people prefer to use USB device at home and only use their onboard sound when travelling. This means they prefer their USB device to have index=0 and prefer the other device to have index=1. Unless the other device plays up and also needs index=0 setting

2) By not having index set, the computer detects devices as fast as it can but generally USB need to settle so are detected last.

A Index Values----Part two

Set USB device as 0 as internal device to be given index of 1

Modify your /etc/modprobe.d/alsa-base.conf so it reads
eg
-----------------------------------------------
options snd-usb-audio index=0

options snd-hda-intel model=5stack
options snd-hda-intel index=1
-------------------------------------------------

You do not need to have USB inserted at boot, the internal will never grab index=0

A Index Values----Part three

If your testing shows there are no issues with internal being on index of 1 you do not need to mention the USB device in the conf so your conf reads
---------------------------------------------
options snd-hda-intel model=5stack
options snd-hda-intel index=1
-----------------------------------------------

This leaves index=0 available to the next device which is the USB
ok?

A Index Values----Part four

for those who test and find they need whichever device they are using needs to have index=0 then just edit your conf file and put a # symbol in front of the line for the index=1

eg
---------------------------------------------
options snd-hda-intel model=5stack
# options snd-hda-intel index=1
-----------------------------------------------

On reboot your internal get index of 0 and the USB if inserted will get a higher number but you only do this setting because you want the internal to regain index=0

B Quirks

snd-intel8x0 may depending on your ALSA version require a quirk as the hardware plays up from time to time.

We set this in /etc/modprobe.d/alsa-base.conf
eg
-----------------------------------------------
options snd-intel8x0 ac97_quirk
--------------------------------------------------

C Which config file should I use?

Alsa-project mentions various files and in the old sidux Hubi and I and others mentioned various files

Here is one way to check. Locate your ALSA executable called alsa

:: Code ::
$ sudo su
# find / -name alsa

--> /usr/sbin/alsa

# less /usr/sbin/alsa


On a Debian distro you will see

-------------/etc/modprobe.d/alsa-base.conf

(On Tinycore its called alsasound)


D Home Entertainment

Some users report that their sound device does not give them sound to their TV connected through a HDMI cable

If you fall into this camp please try the following

1) Relook at your your alsamixer image and make sure you can see a S/PDIF setting.

If not read the documents relevant to your device to force S/PDIF through setting your correct model=string

However, you may like to try a different model=string as I can not test as I do not have my sound connected to tv or to a hdmi cable.

2) unmuting that setting for SPDIF

You do not have anything connected to it.....just unmute it.

3) Now consider this output from what we have learnt?

:: Code ::
 aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC272X Analog [ALC272X Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


If you need hdmi we need to run

alsamixer -c1 or while in card0 press F6 to select card1 and then enable S/PDIF

E Webcam mic

Most webcams do not have a sound OUT but do have a mic

If you run alsamixer and then press F6 you should be able to configure your webcam

In below image I have raised volume

De-activate by pressing the space bar

By the way you can press TAB key to scroll through playback or input for each device



F Microphone or Capture device

Part One

I will stick with alsamixer screenshots but highly recommend you consider the xfce4-micer (a GUI mixer)

Firstly I have only one mic a part of a VOIP headset and it has the orange 3.5 mm jack for mic and green or lime for hearing.

Secondly I have onboard sound with rear mic and a connector to front of desktop to front mic and front out.

Lets look at some screenshots and discuss the issues

By running alsamixer and pressing F4 or the TAB key we get to capture settings



The first control I have pressed the SPACE BAR to activate the capture device and pressed page up or down and the the arrow up or down keys to NOT use 100%. If I use 100 I am likely to get distortion. If you have analog sound in....use this please.

Capture1 device has been zeroed and de-activated

Digital has been raised but not set to 100 for same reason. use this if your sound capture allows digital input.

But if you know your device is digital, I found I still need to activate the first setting so maybe digital on this card has no off/on so needs the analog on/off?

Input source (0) has been set using the up or down arrows to get to front mic

Input Src1 has been set to Line meaning I could connect an external mp3 player etc and import the sound....example only

Mux (0) has been arrowed to...to show pink but I have not raised it.
It means MIC BOOST and be wary of using it unless your mic is low volume. Sound distortion is likely as well but you can play with all levels to test that out.

Mux1 is for the rear mic (at this setting )

Now lets look at the next image



This sound card has a mic setting on the OUTPUT page. It allows you to make the mic in.....into a sound device connection but I have set it to mic only.

Press the right arrow to get to the mic settings and then press up or down arrows to change.

If you have only one mic then its called mic but if you have a rear mic and front mic then they are tagged as such.

mic connectors can therefore be used for 5.1 or higher channel sound out but need to be made out and not mic.

Part 2

How to test

:: Code ::
$ arecord -d 5 -f cd test.wav

aplay test.wav


Will record if mic is in correct hole and mixer correctly set
- a 5 second test of your voice
- using cd quality
-using name of file test.wav

Use aplay or vlc etc to play it.

Part 3

show other issues maybe skype?

Z Online Documents


www.kernel.org/doc/Documentation/sound/alsa/ALSA-Configuration.txt

www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt

www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt

www.kernel.org/doc/Documentation/sound/alsa/Audiophile-Usb.txt

www.kernel.org/doc/Documentation/sound/alsa/alsa-parameters.txt

www.kernel.org/doc/Documentation/sound/alsa/hda_codec.txt

Troubleshooting
alsa.opensrc.org/TroubleShooting

soundcards
alsa.opensrc.org/Sound_cards

Testing
www.alsa-project.org/main/index.php/SoundcardTesting

< Edited by aus9 :: Apr 10, 11, 22:25 >
hubi
Status: Interested
Joined: 08 Sep 2008
Posts: 16
Location: Vienna, AT
Back to top
Posted: Mar 28, 11, 12:18    
Greetings aus9!

Nice to read you again!

Since my laptop is set up now for ages and still works as advertized, I have forgotten a lot, so it's good to read your how-to.

Keep up your spirit!

hubi
aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Mar 28, 11, 14:11    
hi hubi

nice to see you here

feel free to point out anything by post or private message.
GoinEasy9
Status: Contributor
Joined: 28 Jun 2008
Posts: 81
Location: Manorville, New York
Back to top
Posted: Mar 28, 11, 19:26    
This is great stuff aus9. Even though I come to Techpatterns often, I've got this thread bookmarked under sound. Nice.
aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Mar 29, 11, 2:09    
GoinEasy9

hi and thanks

I changed subject from wiki to HOWTO to reflect that others can not edit this howto.
aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Jan 15, 12, 21:32    
I have been googling HDMI audio out and it appears that

:: Code ::

cat /proc/asound/devices

or

cat /proc/asound/pcm


will give you a card list and a device list.

You may have more than one hdmi device showing.

Then create a .asoundrc in home folder or a system wide /etc/asound.conf

using the formula

pcm.!default {
type hw
card <number>
device <number>
}

Google suggests you may still need to turn off and then on S/PDIF if you still have no sound out

but anyhow I have not had any feedback from another distro's forum on whether the above is correct or not.

If anyone here cares to share feel free

good luck
aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Jan 17, 12, 23:52    
pulseaudio is now split to new howto here

techpatterns.com/forums/about2179.html

< Edited by aus9 :: Aug 29, 12, 2:34 >
aus9
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Back to top
Posted: Aug 28, 12, 15:41    
I have just found out that I have mod powers,
thanks TechAdmin

so I will clean up page one and probably split this post into alsa and PA

while I will remove this post, heh heh I declare that
I have a desktop
with 2 speakers so no need for PA
but the skills to mod it might come in handy if I buy another pc.
Display posts from previous:   

All times are GMT - 8 Hours