Audio function

This document provides a concise guide to operating the Linux audio system. We adopt a dual-architecture audio backend with ALSA and PulseAudio, providing a complete audio solution from bottom level to application layer. In terms of hardware, external microphone input (via external SH1.0-4P audio to headset interface) and external speaker output are supported, enabling full-duplex communication for headset playback and microphone input. On the software side, the following audio configuration commands are provided to ensure optimal audio output. Through this document, you will learn how to use basic command-line tools to quickly complete daily operations such as audio device checking, recording and playback, volume control, etc., solving most audio-related issues without delving into complex configurations.

Hardware interface

  • External SH1.0-4P audio to headset interface
  • Onboard MEMS microphone
image-1766049231497 image-1766049716332

View sound card information

  • Enter the following command in the terminal to check the sound card mounting status:

    cat /proc/asound/cards
    

  • Enter the following command in the terminal to view the assigned pcm stream list:

    cat /proc/asound/pcm
    

  • If there is no sound card information and pcm stream list, both ALSA and PulseAudio functions will be unavailable.

Function usage

Audio recording

Linux needs to modify the configuration /etc/backend_conf.xml on the smart single-board computer first, which is configured by default.

<device name="CODEC_DMA-LPAIF_RXTX-TX-3" rate="48000" ch="2" bits="16" />

Android environment is configured by default.

Onboard microphone recording

On Linux, you must stop the PulseAudio service before recording:

systemctl stop pulseaudio
tinymix "TX DEC0 MUX" "SWR_MIC" 
tinymix "ADC2 ChMap" "SWRM_TX2_CH1" 
tinymix "TX SMIC MUX0" "SWR_MIC4" 
tinymix "TX_AIF1_CAP Mixer DEC0"  "1" 
tinymix "ADC2_MIXER Switch"  "1" 
tinymix "ADC2 MUX"  "INP3" 
tinymix 'TX_AIF1_CAP Mixer DEC2' '1'
agmcap /data/testMic3.wav -D 100 -d 101 -c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3"

On Android:

tinymix "TX DEC0 MUX" "SWR_MIC" 
tinymix "ADC2 ChMap" "SWRM_TX2_CH1" 
tinymix "TX SMIC MUX0" "SWR_MIC4" 
tinymix "TX_AIF1_CAP Mixer DEC0"  "1" 
tinymix "ADC2_MIXER Switch"  "1" 
tinymix "ADC2 MUX"  "INP3" 
tinymix 'TX_AIF1_CAP Mixer DEC2' '1'
agmcap ./testMic3.wav -D 100 -d 101 -c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3"

Press Ctrl + Z to stop recording:

alt text

Headset recording

Linux:

systemctl stop pulseaudio
tinymix  "TX DEC0 MUX" "SWR_MIC"
tinymix  "TX SMIC MUX0" "SWR_MIC5"
tinymix  "DEC0_BCS Switch" "1"
tinymix  "TX_AIF1_CAP Mixer DEC0" "1"
tinymix  "ADC2 ChMap" "SWRM_TX2_CH2"
tinymix  "MBHC ChMap" "SWRM_TX3_CH3"
tinymix  "ADC2_MIXER Switch" "1"
tinymix  "ADC2 MUX" "INP2"
tinymix  "BCS Channel" "CH10"
agmcap /data/rec2.wav -D 100 -d 101 -c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3"

Android:

tinymix  "TX DEC0 MUX" "SWR_MIC"
tinymix  "TX SMIC MUX0" "SWR_MIC5"
tinymix  "DEC0_BCS Switch" "1"
tinymix  "TX_AIF1_CAP Mixer DEC0" "1"
tinymix  "ADC2 ChMap" "SWRM_TX2_CH2"
tinymix  "MBHC ChMap" "SWRM_TX3_CH3"
tinymix  "ADC2_MIXER Switch" "1"
tinymix  "ADC2 MUX" "INP2"
tinymix  "BCS Channel" "CH10"
agmcap ./rec2.wav -D 100 -d 101 –c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3"

Note: Make sure you have write permissions for the current directory during operation.

Audio playback

The onboard speaker is not soldered, please use the external headset channel for playback.

Headset playback

To play audio using a 3.5mm headset, execute the following commands:

Linux:

systemctl stop pulseaudio
tinymix "RX_MACRO RX0 MUX" "AIF1_PB"
tinymix "RX_MACRO RX1 MUX" "AIF1_PB"
tinymix "RX INT0_1 MIX1 INP0" "RX0"
tinymix "RX INT1_1 MIX1 INP0" "RX1"
tinymix "RX INT0 DEM MUX" "CLSH_DSM_OUT"
tinymix "RX INT1 DEM MUX" "CLSH_DSM_OUT"
tinymix "RX_COMP1 Switch" "1"
tinymix "RX_COMP2 Switch" "1"
tinymix "HPHL Switch" "1"
tinymix "HPHR Switch" "1"
tinymix "HPHL_RDAC Switch" "1"
tinymix "HPHR_RDAC Switch" "1"
agmplay /data/vvdn_ring.wav -D 100 -d 100 -i CODEC_DMA-LPAIF_RXTX-RX-0 -dkv 0xA2000002

Android:

adb root
adb shell
cd /data/local/tmp
tinymix "RX_MACRO RX0 MUX" "AIF1_PB"
tinymix "RX_MACRO RX1 MUX" "AIF1_PB"
tinymix "RX INT0_1 MIX1 INP0" "RX0"
tinymix "RX INT1_1 MIX1 INP0" "RX1"
tinymix "RX INT0 DEM MUX" "CLSH_DSM_OUT"
tinymix "RX INT1 DEM MUX" "CLSH_DSM_OUT"
tinymix "RX_COMP1 Switch" "1"
tinymix "RX_COMP2 Switch" "1"
tinymix "HPHL_RDAC Switch" "1"
tinymix "HPHR_RDAC Switch" "1"
agmplay ./vvdn_ring.wav -D 100 -d 100 -i CODEC_DMA-LPAIF_RXTX-RX-0 -dkv 0xA2000002

alt text

Troubleshooting

Issue Possible causes
Recording file not generated 1. Check if setting commands are correct.
2. Check if the operating directory has read/write permissions.
Audio playback failed 1. Check if the playback file exists.
2. Check if the playback command is correct, pay attention to the difference between Chinese and English symbols for "-".

Resources and support