Linux Audio record play: Difference between revisions

From Variscite Wiki
No edit summary
(Update instructions to set L/R inverting mux)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default
<!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release|RELEASE_SUMO_V1.0_DART-MX8M}}}} <!--
--> {{INIT_RELEASE_PARAM|RELEASE_SUMO_V1.0_DART-MX8M}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#vardefine:SUPPORT_WM8904_DRC | <!--
--> {{#vardefine:SUPPORT_WM8904_DRC | <!--
-->    {{#switch:{{#var:HARDWARE_NAME}} | <!--
-->    {{#switch:{{#var:HARDWARE_NAME}} | <!--
Line 9: Line 10:
-->    }} <!--
-->    }} <!--
--> }} <!--
--> }} <!--
    # Add ARECORD_EXTRA_ARGS for AM62
    # See: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/08_06_00_42/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Audio.html?highlight=arecord#potential-issues
--> {{#switch: {{#var:SOC_SERIES}}
    | am6={{#vardefine: ARECORD_EXTRA_ARGS | -r 48000 --period-size=64}}
    |#default=
    }}<!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} Audio Record/Play}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{PageHeader|{{#var:HARDWARE_NAME}} Audio Record/Play}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
= Get information on the Sound Cards =
= Get information on the Sound Cards =
Line 28: Line 37:
     Default Audio Device
     Default Audio Device
</pre>
</pre>
 
{{#varexists:DEBIAN_NAME|
For the upcoming, the tool amixer is used to control the audio. Please consider stopping the PulseAudio server to avoid conflicts:
# systemctl stop pulseaudio
}}
= Audio Playback =
= Audio Playback =
Set PCM volume (main volume of audio codec), range :0-63
Set PCM volume (main volume of audio codec), range :0-63
Line 40: Line 52:
Example:
Example:
<pre>
<pre>
# amixer set set Headphone 35
# amixer set Headphone 35
Simple mixer control 'Headphone',0
Simple mixer control 'Headphone',0
   Capabilities: volume pswitch
   Capabilities: volume pswitch
Line 57: Line 69:
<pre>
<pre>
# amixer set Headphone 35
# amixer set Headphone 35
</pre>
Set L/R capture inverting mux inputs to IN2
<pre>
# amixer set 'Left Capture Inverting Mux' IN2L
# amixer set 'Right Capture Inverting Mux' IN2R
</pre>
</pre>
Set capture input source to ADC
Set capture input source to ADC
Line 67: Line 84:
</pre>
</pre>
Record CD quality audio for 10 seconds into file test.wav
Record CD quality audio for 10 seconds into file test.wav
<pre>
# arecord {{#var:ARECORD_EXTRA_ARGS}} -f cd -d 10 test.wav
# arecord -f cd -d 10 test.wav
</pre>
Play the recorded file
Play the recorded file
<pre>
<pre>
Line 75: Line 90:
</pre>
</pre>
Example:
Example:
<pre>
 
# amixer set set Headphone 35
# amixer set Headphone 35
Simple mixer control 'Headphone',0
Simple mixer control 'Headphone',0
  Capabilities: volume pswitch
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Limits: 0 - 63
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
# amixer set 'Capture Input' ADC
# amixer set 'Left Capture Inverting Mux' IN2L
Simple mixer control 'Capture Input',0
Simple mixer control 'Left Capture Inverting Mux',0
  Capabilities: enum
  Capabilities: enum
  Items: 'ADC' 'DMIC'
  Items: 'IN1L' 'IN2L' 'IN3L'
  Item0: 'ADC'
  Item0: 'IN2L'
# amixer set 'DMIC Mux' DMIC2
# amixer set 'Right Capture Inverting Mux' IN2R
Simple mixer control 'DMIC Mux',0
Simple mixer control 'Right Capture Inverting Mux',0
  Capabilities: enum
  Capabilities: enum
  Items: 'DMIC1' 'DMIC2'
  Items: 'IN1R' 'IN2R' 'IN3R'
  Item0: 'DMIC2'
  Item0: 'IN2R'
# arecord -f cd -d 10 test.wav
# amixer set 'Capture Input' ADC
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Simple mixer control 'Capture Input',0
# aplay test.wav
  Capabilities: enum
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
  Items: 'ADC' 'DMIC'
</pre>
  Item0: 'ADC'
# amixer set 'DMIC Mux' DMIC2
Simple mixer control 'DMIC Mux',0
  Capabilities: enum
  Items: 'DMIC1' 'DMIC2'
  Item0: 'DMIC2'
# arecord {{#var:ARECORD_EXTRA_ARGS}} -f cd -d 10 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo


= Audio Record and Play, DMIC =
= Audio Record and Play, DMIC =
Line 114: Line 138:
</pre>
</pre>
Record CD quality audio for 10 seconds into file test.wav
Record CD quality audio for 10 seconds into file test.wav
<pre>
# arecord {{#var:ARECORD_EXTRA_ARGS}} -f cd -d 10 test.wav
# arecord -f cd -d 10 test.wav
</pre>
Play the recorded file
Play the recorded file
<pre>
<pre>
Line 122: Line 144:
</pre>
</pre>
Example:
Example:
<pre>
 
# amixer set set Headphone 35
# amixer set Headphone 35
Simple mixer control 'Headphone',0
Simple mixer control 'Headphone',0
  Capabilities: volume pswitch
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Limits: 0 - 63
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
# amixer set 'Capture Input' DMIC
# amixer set 'Capture Input' DMIC
Simple mixer control 'Capture Input',0
Simple mixer control 'Capture Input',0
  Capabilities: enum
  Capabilities: enum
  Items: 'ADC' 'DMIC'
  Items: 'ADC' 'DMIC'
  Item0: 'DMIC'
  Item0: 'DMIC'
# amixer set 'DMIC Mux' DMIC1
# amixer set 'DMIC Mux' DMIC1
Simple mixer control 'DMIC Mux',0
Simple mixer control 'DMIC Mux',0
  Capabilities: enum
  Capabilities: enum
  Items: 'DMIC1' 'DMIC2'
  Items: 'DMIC1' 'DMIC2'
  Item0: 'DMIC1'
  Item0: 'DMIC1'
# arecord -f cd -d 10 test.wav
# arecord {{#var:ARECORD_EXTRA_ARGS}} -f cd -d 10 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
# aplay test.wav
# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
</pre>


= Advanced Controls =
= Advanced Controls =
Line 262: Line 283:


= Save/restore system's audio settings =
= Save/restore system's audio settings =
alsactl store stores all alsamixer settings into a file<br>
alsactl store stores all alsamixer settings into a file.<br>
alsctl
Options:
Options:
<pre>
<pre>

Latest revision as of 15:47, 23 October 2023

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_SUMO_V1.0_DART-MX8M.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
DART-MX8M Audio Record/Play

Get information on the Sound Cards

Installed devices:

# cat /proc/asound/cards
 0 [wm8904audio      ]: wm8904-audio - wm8904-audio
                      wm8904-audio

List device names for playback:

# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=wm8904audio
    wm8904-audio, 
    Default Audio Device

Audio Playback

Set PCM volume (main volume of audio codec), range :0-63

# amixer set Headphone 35

Play audio:

# aplay /usr/share/sounds/alsa/Front_Center.wav

Example:

# amixer set Headphone 35
Simple mixer control 'Headphone',0
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]

# aplay /usr/share/sounds/alsa/Front_Center.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

Audio Record and Play, Line-in Jack

Set PCM volume (main volume of audio codec), range :0-63

# amixer set Headphone 35

Set L/R capture inverting mux inputs to IN2

# amixer set 'Left Capture Inverting Mux' IN2L
# amixer set 'Right Capture Inverting Mux' IN2R

Set capture input source to ADC

# amixer set 'Capture Input' ADC

Set DMIC Mux to DMIC2

# amixer set 'DMIC Mux' DMIC2

Record CD quality audio for 10 seconds into file test.wav

# arecord  -f cd -d 10 test.wav

Play the recorded file

# aplay test.wav 

Example:

# amixer set Headphone 35
Simple mixer control 'Headphone',0
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
# amixer set 'Left Capture Inverting Mux' IN2L
Simple mixer control 'Left Capture Inverting Mux',0
  Capabilities: enum
  Items: 'IN1L' 'IN2L' 'IN3L'
  Item0: 'IN2L'
# amixer set 'Right Capture Inverting Mux' IN2R
Simple mixer control 'Right Capture Inverting Mux',0
  Capabilities: enum
  Items: 'IN1R' 'IN2R' 'IN3R'
  Item0: 'IN2R'
# amixer set 'Capture Input' ADC
Simple mixer control 'Capture Input',0
  Capabilities: enum
  Items: 'ADC' 'DMIC'
  Item0: 'ADC'
# amixer set 'DMIC Mux' DMIC2
Simple mixer control 'DMIC Mux',0
  Capabilities: enum
  Items: 'DMIC1' 'DMIC2'
  Item0: 'DMIC2'
# arecord  -f cd -d 10 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

Audio Record and Play, DMIC

Set Headphones volume, range :0-63

# amixer set Headphone 35

Set capture input source to DMIC

# amixer set 'Capture Input' DMIC

Set DMIC Mux to DMIC1

# amixer set 'DMIC Mux' DMIC1

Record CD quality audio for 10 seconds into file test.wav

# arecord  -f cd -d 10 test.wav

Play the recorded file

# aplay test.wav 

Example:

# amixer set Headphone 35
Simple mixer control 'Headphone',0
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
# amixer set 'Capture Input' DMIC
Simple mixer control 'Capture Input',0
  Capabilities: enum
  Items: 'ADC' 'DMIC'
  Item0: 'DMIC'
# amixer set 'DMIC Mux' DMIC1
Simple mixer control 'DMIC Mux',0
  Capabilities: enum
  Items: 'DMIC1' 'DMIC2'
  Item0: 'DMIC1'
# arecord  -f cd -d 10 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

Advanced Controls

amixer without a parameter will show all available controls. For example:

# amixer
Simple mixer control 'Headphone',0
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Front Left: 35 [56%] [-22.00dB] Playback [on]
  Front Right: 35 [56%] [-22.00dB] Playback [on]
Simple mixer control 'Headphone ZC',0
  Capabilities: pswitch
  Playback channels: Front Left - Front Right
  Mono:
  Front Left: Playback [on]
  Front Right: Playback [on]
Simple mixer control 'Line Output',0
  Capabilities: volume pswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 63
  Front Left: 57 [90%] [0.00dB] Playback [on]
  Front Right: 57 [90%] [0.00dB] Playback [on]
Simple mixer control 'Line Output ZC',0
  Capabilities: pswitch
  Playback channels: Front Left - Front Right
  Mono:
  Front Left: Playback [on]
  Front Right: Playback [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 31
  Front Left: Capture 24 [77%] [on]
  Front Right: Capture 24 [77%] [on]
Simple mixer control 'Capture Input',0
  Capabilities: enum
  Items: 'ADC' 'DMIC'
  Item0: 'DMIC'
...

Options:

amixer   sset sID P      set contents for one mixer simple control
amixer   sget sID        get contents for one mixer simple control

For example:

# amixer sget 'Capture'
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 31
  Front Left: Capture 24 [77%] [on]
  Front Right: Capture 24 [77%] [on]
# amixer sset 'Capture' 25
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 31
  Front Left: Capture 25 [81%] [on]
  Front Right: Capture 25 [81%] [on]

Capture currently now set to 81%.


Save/restore system's audio settings

alsactl store stores all alsamixer settings into a file.
Options:

  store     <card>  save current driver setup for one or each soundcards
                      to configuration file
  restore   <card>  load current driver setup for one or each soundcards
                      from configuration file

Example:

# alsactl store -f 123.conf
# alsactl restore -f 123.conf