ALSA

Notes about ALSA.

Mixer

To show mixer with controls for all devices:

alsamixer -V all

Set default microphone

I have ALSA with Pulseaudio, but after much searching on the Internet I couldn’t determine where to set the default input source.

Instead, I run amixer at startup to set the default input source, buy adding the following to ~/.xinitrc:

amixer -c0 sset 'Input Source' 'Rear Mic'

Note that I determined which controls were available by looking at the mixer controls available for card 0, as follows:

me@pc> amixer -c0
...
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Rear Mic' 'Front Mic' 'Line'
  Item0: 'Rear Mic'
Simple mixer control 'Input Source',1
  Capabilities: cenum
  Items: 'Rear Mic' 'Front Mic' 'Line'
  Item0: 'Rear Mic'
...

Checked the name of the control as follows:

me@pc ~ $ amixer -c0 sget 'Input Source'
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Rear Mic' 'Front Mic' 'Line'
  Item0: 'Rear Mic'

Then tested changing it, which worked just fine:

me@pc ~ $ amixer -c0 sset 'Input Source' 'Front Mic'
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Rear Mic' 'Front Mic' 'Line'
  Item0: 'Front Mic'
me@pc ~ $ amixer -c0 sset 'Input Source' 'Rear Mic'
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Rear Mic' 'Front Mic' 'Line'
  Item0: 'Rear Mic'

Mic testing

This will record a 3 second file called test-mic.wav. The second command plays it back.

me@pc ~/tmp $ arecord -d 3 test-mic.wav
Recording WAVE 'test-mic.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
me@pc ~/tmp $ aplay test-mic.wav
Playing WAVE 'test-mic.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono

Speaker (front, stereo) testing

This will alternate between sounding the left and right speakers:

me@pc ~ $ speaker-test -Dplug:front -c2

speaker-test 1.0.24.2

Playback device is plug:front
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 16384
Period size range from 32 to 8192
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
 0 - Front Left
 1 - Front Right
Time per period = 5.632449
 0 - Front Left
 1 - Front Right
Time per period = 5.974285
 0 - Front Left
 1 - Front Right

Mute / unmute

You’ll need pulseaudio for this:

amixer -D pulse set Master 1+ toggle

Reference: How do I toggle sound with amixer?

Equalizer

Note: These notes are old - they could have been written around 2010! I don’t use this config any more (as of 2013).

Install alsaequal plugin.

Add to the end of /usr/share/alsa/alsa.conf:

ctl.equal {
  type equal;
}

pcm.plugequal {
  type equal;

  # Modify the line below if you don't
  # want to use sound card 0.
  #slave.pcm "plughw:0,0";

  # We're running sound through dmix, to allow sound from multiple apps.
  slave.pcm "plug:dmix";
}

pcm.equal {
  # Or if you want the equalizer to be your
  # default soundcard uncomment the following
  # line and comment the above line.
# pcm.!default {

  # On 64 bit system we can't yet use alsaequal as default because some apps (e.g. skype) require 32 bit lib which we won't have.
  type plug;
  slave.pcm plugequal;
}

Restart alsasound

You can then use the equalizer via e.g. alsamixergui -D equal

Run an application through the equalizer by specifying the audio device it uses e.g. alsaplayer -d equal

References

Last modified: 09/08/2015 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top