Seitenleiste


Access to information is restricted depending on your login. Request login-information through our contact form.

service:linux:aappnote:use_audio

Using Audio in Linux

Play Sound

To play a sound (i.e. test.wav) to the current audio-output:

$ aplay test.wav

See options with 'aplay -h'

Record Sound

To record sound from the current audio-input source to test.wav:

$ arecord test.wav

Stop recording by pressing 'CTRL-C'.
See options with 'arecord -h'.

Configure Audio Device

Before using audio you might need to do some configuration; i.e. un-mute audio-output or select the audio input source.
In Linux this can be done by the Advanced Linux Sound Architecture (ALSA): https://www.alsa-project.org

AlsaMixer

The AlsaMixer utility provides an easy way to modify audio-settings using a graphical interface.

$ alsamixer

Press 'F1' for details on how to use it.
Usually you will use:

  1. the left and right arrow key to move between the controls
  2. up and down keys change volume setting of a control
  3. 'm'-key to toggle 'mute' setting or enable/disable a switch setting.

AMixer

AMixer is a command-line utility to view and modify audio settings.
Use

$ amixer help

to view available options.

View Available Controls

To have a look at available controls use:

$ amixer scontrols
Simple mixer control 'Headphone',0
Simple mixer control 'Headphone Playback ZC',0
Simple mixer control 'Speaker',0
Simple mixer control 'Speaker Boost',0
Simple mixer control 'Speaker Inversion',0
Simple mixer control 'Speaker Playback ZC',0
Simple mixer control 'Aux Bypass',0
Simple mixer control 'Playback',0
Simple mixer control 'Capture',0
Simple mixer control 'Capture PGA',0
Simple mixer control 'Capture PGA Boost',0
Simple mixer control 'Capture PGA ZC',0
Simple mixer control '3D Depth',0

Get Value of Control

I.e. to get the current headphone volume use:

$ amixer get Headphone
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 63
  Mono:
  Front Left: Playback 37 [59%] [-20.00dB] [off]
  Front Right: Playback 37 [59%] [-20.00dB] [off]

Set Value of Control

$ amixer set Headphone 10
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 63
  Mono:
  Front Left: Playback 10 [16%] [-47.00dB] [off]
  Front Right: Playback 10 [16%] [-47.00dB] [off]

Mute/Unmute Control

Unmute Headphone output:

$ amixer set Headphone unmute
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 63
  Mono:
  Front Left: Playback 10 [16%] [-47.00dB] [on]
  Front Right: Playback 10 [16%] [-47.00dB] [on]

Mute Headphone output:

$ amixer set Headphone mute
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 63
  Mono:
  Front Left: Playback 10 [16%] [-47.00dB] [off]
  Front Right: Playback 10 [16%] [-47.00dB] [off]

Setup ALSA

ALSA can be configured through /etc/asound.conf.
Below is an excerpt of the asound.conf of Trizeps VIII Yocto image:

pcm.dmix_48000{
type dmix
ipc_key 5678293
ipc_key_add_uid yes
slave{
pcm "hw:0,0"
period_time 40000
format S16_LE
rate 48000
}
}

pcm.!dsnoop_48000{
type dsnoop
ipc_key 5778293
ipc_key_add_uid yes
slave{
pcm "hw:0,0"
period_time 40000
format S16_LE
rate 48000
}
}

pcm.asymed{
type asym
playback.pcm "dmix_48000"
capture.pcm "dsnoop_48000"
}

pcm.!default{
type plug
route_policy "average"
slave.pcm "asymed"
}

'pcm.!default' is the standard entry, which is used by all programs to route their audio-data – unless otherwise told.
'slave.pcm' tells to route audio to pcm.asymed, which will use dmix_48000 configuration for playback and dsnoop_48000 for capture.

Cookies helfen bei der Bereitstellung von Inhalten. Durch die Nutzung dieser Seiten erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Rechner gespeichert werden. Weitere Information
service/linux/aappnote/use_audio.txt · Zuletzt geändert: 2019/04/25 18:04 von