ALSA

From LinuxReviews
Jump to navigationJump to search

Advanced Linux Sound Architecture (ALSA) is a user-space sound system for GNU/Linux system. It was developed as an alternative to OSS when that system was temporarily made non-free software.

Modern use[edit]

It is a very commonly used sound-system present on nearly all GNU/Linux systems but it is rarely in practice. Most GNU/Linux distributions have submitted to an abstraction layer called PulseAudio which is run on top of ALSA. The increased latency and problems this causes is totally worth it since .. well.. yes.

If you need low-latency audio then OSS and/or Jack may be a better choice.

Configuration[edit]

ALSA is configured in the file /etc/asound.conf. How you are supposed to configure this file to make sound work great on your soundcard is a good question since the documentation for ALSA was eaten by a hungry bear at some point.

The following configuration file appears to work fine with this card:

00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)

# ~/.asoundrc or /etc/asound.conf
# ALSA configuration file

pcm.!default {
  type plug
## Uncomment the following to use (unmixed) "analog" by default
#  slave.pcm "analog-hw"
## Uncomment the following to use "mixed-analog" by default
#  slave.pcm "dmix-analog"
## Uncomment the following to use (unmixed) "digital" by default
#  slave.pcm "digital-hw"
## Uncomment the following to use "mixed-digital" by default
  slave.pcm "dmix-digital"
}

# Control device (mixer, etc.) for the card
ctl.!default {
  type hw
  card 0
}

pcm.analog {
  type plug
  slave.pcm "analog-hw"
  hint {
    show on
    description "Analog Output - Use analog outputs, converting samples, format, and rate as necessary."
  }
}

# Control device (mixer, etc.) for the card
ctl.analog {
  type hw
  card 0
}

# Alias for (converted) mixed analog output on the card
# - This will accept audio input--regardless of rate--and convert to the rate
# required for the dmix plugin (in this case 48000Hz)
# - Note that as of ALSA 1.0.9, "software" sound card definitions redefine
# "default" to do mixing, meaning this device is identical to "default" for
# "software" sound cards.
pcm.mixed-analog {
  type plug
  slave.pcm "dmix-analog"
  hint {
    show on
    description "Mixed Analog Output - Use analog outputs, converting samples, format, and rate as necessary. Allows mixing with system sounds."
  }
}

# Control device (mixer, etc.) for the card
ctl.mixed-analog {
  type hw
  card 0
}

# Alias for (converted) digital (S/PDIF) output on the card
# - This will accept audio input--regardless of rate--and convert to the rate
# required for the S/PDIF hardware (in this case 48000Hz)
pcm.digital {
  type plug
  slave.pcm "digital-hw"
  hint {
    show on
    description "Digital Output - Use digital outputs, converting samples, format, and rate as necessary."
  }
}

# Control device (mixer, etc.) for the card
ctl.digital {
  type hw
  card 0
}

# Alias for mixed (converted) digital (S/PDIF) output on the card
#  - This will accept audio input--regardless of rate--and convert to the rate
#  required for the S/PDIF hardware (in this case 48000Hz)
pcm.mixed-digital {
  type plug
  slave.pcm "dmix-digital"
  hint {
    show on
    description "Mixed Digital Output - Use digital outputs, converting samples, format, and rate as necessary. Allows mixing with system sounds."
  }
}

# Control device (mixer, etc.) for the card
ctl.mixed-digital {
  type hw
  card 0
}

pcm.analog-hw {
  type hw
  card 0
# The default value for device is 0, so no need to specify
#  - Uncomment one of the below or create a new "device N" line as appropriate
#    for your sound card
#  device 1
#  device 4
}

# Control device (mixer, etc.) for the card
ctl.analog-hw {
  type hw
  card 0
}

# Alias for digital (S/PDIF) output on the card
# Do not use this directly--it requires specific rate, channels, and format
pcm.digital-hw {
  type hw
  card 0
  device 1
}
# Control device (mixer, etc.) for the card
ctl.digital-hw {
  type hw
  card 0
  device 1
}

# Direct software mixing plugin for analog output on the card
# Do not use this directly--it requires specific rate, channels, and format
pcm.dmix-analog {
  type dmix
  ipc_key 1234
  slave {
    pcm "analog-hw"
    period_time 0
    period_size 1024
    buffer_size 4096
    rate 48000
  }
}

# Control device (mixer, etc.) for the card
ctl.dmix-analog {
  type hw
  card 0
}

# Direct software mixing plugin for digital (S/PDIF) output on the card
# Do not use this directly--it requires specific rate, channels, and format
pcm.dmix-digital {
  type dmix
  ipc_key 1235
  ipc_key_add_uid false
  ipc_perm 0666
  slave {
     pcm "digital-hw"
     period_time 0
     period_size 1024
     buffer_size 4096
     rate 48000
#     rate 96000
  }
}

# Control device (mixer, etc.) for the card
ctl.dmix-digital {
  type hw
  card 0
}

# for 5.1 speakers
pcm.ch51dup {
         slave.pcm "digital-hw"
         slave.channels 6
         type route
         ttable.0.0 1
         ttable.1.1 1
         ttable.0.2 1
         ttable.1.3 1
         ttable.0.4 0.5
         ttable.1.4 0.5
         ttable.0.5 0.5
         ttable.1.5 0.5
}

# for 4.1 speakers
pcm.ch41dup {
         type route
         slave.pcm surround41
         slave.channels 5
         ttable.0.0 1
         ttable.1.1 1
         ttable.0.2 1
         ttable.1.3 1
         ttable.0.4 0.5
         ttable.1.4 0.5
}

never got pcm.ch51dup or pcm.ch41dup to actually work but you can't have everything now can you