Rockchip · AI & Linux Hub

Display & audio

ArmSoM audio tuning: gain calibration, loopback and Rockit VQE

Calibrate clean audio output, capture sweeps, set ADC gain and inspect Rockit VQE signals, with six diagrams, complete commands and the AI noise-reduction JSON.

Audio tuning starts with the acoustics and the capture/playback path, then moves to algorithms. Clipped input, a mismatched echo reference or a distorted loudspeaker cannot be solved reliably by repeatedly changing noise-reduction settings. This guide proceeds from product requirements through clean output calibration, sweep recording, ADC gain, VQE configuration and diagnostic data.

The technical content follows the supplied Rockchip Audio Algorithm Effect Tuning Guide V1.0.0 (2024-08-12), retaining all six technical figures, commands, configuration fields and parameter examples. Commands describe the source’s RV1106/RV1103 + Rockit setup. Other ArmSoM projects can use the workflow, but control names, paths and gain mappings are not default configurations for P2 Pro or other boards. Oscilloscope and recording results are source examples, not new ArmSoM hardware measurements.

1. Define the product and tuning targets

Identify whether the product is an IPC, conference pickup system or another voice device, how many microphones and loudspeakers it needs, and whether it supports two-way calls. The source describes IPCs typically using no more than two microphones and conference systems using more; these are examples, not limits. For four microphones, specify a linear or circular topology.

Item Source guidance and project record  
Pickup and playback Define pickup range, for example 3–10 m, and playback loudness. This is a requirement example, not a board capability claim.  
Microphones Identify analog or digital microphones. The source discusses electret analog microphones and far-field pickup select parts using component data and assembled-system tests.
Component metrics The source suggests microphone SNR normally ≥65 dB and analog sensitivity ≥−32 dBV for pickup beyond 5 m. Check datasheet reference conditions this is not the assembled-system SNR test.
Loudspeaker Record power and load, for example 2 W @ 8 Ω.  
Structure and reference Record MIC port diameter, MIC/SPK positions, spacing and distribution. Identify hardware or software reference capture the source notes software capture is common.
Sample rate Typical source settings are 8 kHz or 16 kHz. Its AI noise reduction and crying detection require 16 kHz or higher.  

The source’s preference for analog microphones in far-field work is application guidance, not proof that every analog microphone outperforms every digital one. Evaluate sensitivity, component noise, front-end gain and acoustics together.

2. Understand AEC: near end, far end and reference

Figure 1: acoustic echo cancellation workflow

Figure 1: acoustic echo cancellation workflow

Relative to the device under test, a person speaking into its MIC is the near-end input, sent over the network to the remote device. Speech from the remote participant is played by the local loudspeaker. A software or hardware capture of that playback data enters another recording channel as the AEC reference. Near-end speech must not be mistaken for the echo to remove.

Scenario Device state and check  
Far-end single-talk Near end is silent, device plays remote speech and MIC receives echo plus noise. Speak naturally into the remote phone/intercom in a separate room and listen there for returned speech. Check this first after validating the path.  
Near-end single-talk Remote participant and local loudspeaker are silent. MIC captures near-end speech and environment check speech retention and noise reduction.
Double-talk Both participants speak. The source notes possible adaptive-filter divergence and weaker echo cancellation. Validate this alongside both single-talk cases.  

3. Calibrate maximum clean playback output

3.1 Measure with a 0 dBFS, 1 kHz sine wave

First establish loudspeaker power and impedance, disable AO VQE and play the unprocessed test signal. Measure the PA or speaker-terminal voltage with an oscilloscope. Class-D output contains a carrier of several hundred kHz; its switching peaks are not the audio amplitude. The source uses a first-order 500 Ω + 10 nF RC low-pass in each measurement branch, with cutoff around 32 kHz, to reduce the carrier above the approximately 20 kHz audible range.

Figure 2: differential loudspeaker measurement and RC branches

Figure 2: differential loudspeaker measurement and RC branches

The RC network is in the measurement branches, not a 500 Ω resistor in series with the speaker load. Both P/N terminals of a bridged output may be driven. Verify oscilloscope grounding and the differential measurement arrangement before connecting; grounding a driven terminal can short it. Start at low output and increase to the target.

rk_mpi_ao_test -i /data/sine1000_16khz_2ch.wav --sound_card_name=hw:0,0 \
  --device_ch=2 --device_rate=16000 --input_rate=16000 --input_ch=2

The source also provides this alternative for systems with ALSA tools. Use one playback path, not several players simultaneously:

aplay -Dhw:0,0 /data/sine1000_16khz_2ch.wav -r 16000 -c 2 -f S16_LE

The original tinyplay command is retained for version comparison:

tinyplay /data/sine1000_16khz_2ch.wav -r 16000 -c 2 -b 2 -D 0

Current TinyALSA source defines -b as bit depth; -b 2 is not a general 16-bit setting. WAV format comes from its header. Check local help and card selection before using:

tinyplay /data/sine1000_16khz_2ch.wav -D 0 -d 0

3.2 Calculate power from differential voltage

Figure 3: maximum clean sine wave after RC filtering

Figure 3: maximum clean sine wave after RC filtering

Yellow and green are the P/N terminal waveforms; pink is their difference calculated by the oscilloscope. The source uses approximately 9.8 V peak-to-peak into 8 Ω to check a 1.5 W design target. For a sine wave:

Vrms = Vpp / (2 × sqrt(2))
P = Vrms² / R = Vpp² / (8 × R)
P = 9.8² / (8 × 8) ≈ 1.50 W

Do not insert peak-to-peak voltage directly into V²/R. This calculation explains the illustrated sine wave and load, not average power for arbitrary program audio or a completed thermal/reliability test.

4. Sweep playback/recording and Codec gain

4.1 Configure RV1106/RV1103 digital loopback

These examples enable the SoC’s internal digital loopback. Confirm that the firmware exposes the control, then use either tool. Do not assume Mode2 applies to other platforms. The source refers to Rockchip_Developer_Guide_Linux_RV1106_ACodec_CN.pdf for the path details.

rk_mpi_amix_test --control "I2STDM Digital Loopback Mode" --value "Mode2"
tinymix set "I2STDM Digital Loopback Mode" "Mode2"

Match the tinymix syntax to the installed version as well. With processing disabled, use the sweep to adjust hardware ADC/DAC gain for the largest clean recording amplitude, rather than forcing every waveform to full scale.

4.2 Save the unprocessed recording

The source notes a 1 MB limit for the default Rockit example output /tmp/cap_out.pcm. For a longer recording, set the dump path in the environment used to launch capture, then start capture without VQE. Confirm available /tmp space and stop after obtaining the required segment.

export rt_debug_cap_file=/tmp/dbg_capin.pcm
rk_mpi_ai_test --sound_card_name=hw:0,0 --device_rate 16000 --device_ch 2 \
  --out_rate 16000 --out_ch 2 --output /tmp

In another terminal, play the 0 dBFS sweep with AO VQE still disabled:

rk_mpi_ao_test -i /data/sweep_16k_20_8000_16b_2ch.wav --sound_card_name=hw:0,0 \
  --device_ch=2 --device_rate=16000 --input_rate=16000 --input_ch=2

Figure 4: self-playback sweep in time and frequency domains

Figure 4: self-playback sweep in time and frequency domains

The example recording has 2ch: left is MIC capture and right is digital loopback. In this setup the reference PCM matches the PCM sent for playback. This ordering belongs to the example; verify mapping again on other images.

Figure 5: clipping in the sweep recording

Figure 5: clipping in the sweep recording

Figure 6: magnified clipped waveform

Figure 6: magnified clipped waveform

Clipping discards waveform information that later processing cannot restore. First confirm clean playback, then reduce the Codec’s front-end analog gain as described in the source and repeat the measurement.

4.3 ADC ALC gain: read, adjust and repeat

rk_mpi_amix_test --control "ADC ALC Left Volume"

Source output example:

cmd parse result:
sound control id     : 0
control name         : ADC ALC Left Volume
control value        : (null)
list controls        : 0
list contents        : 0
Get current control value: 22
List the control values:
22 (range 0->31)

In the source’s RV1106 ACodec mapping, 22 → +24 dB, with 1.5 dB steps. Reducing to 14 → +12 dB lowers gain by 12 dB and removes clipping in that example. Value 14 is a calibration result, not a universal hardware recommendation.

rk_mpi_amix_test --control "ADC ALC Left Volume" --value "14"
cmd parse result:
sound control id     : 0
control name         : ADC ALC Left Volume
control value        : 14
list controls        : 0
list contents        : 0

5. Check VQE libraries, JSON and the AI noise model

Integrate processing after obtaining a clean input. The source SDK uses these default paths; file existence alone does not prove matching versions, ABI or configuration.

/oem/usr/lib/librkaudio_vqe.so
/oem/usr/lib/librkaudio_common.so
/oem/usr/share/vqefiles/config_aivqe.json

For AI noise reduction, the actual model file must match ainr.model_path in config_aivqe.json. The following retains every field and value of the source’s ainr object, with outer braces to form a valid JSON example. It is not a replacement for the entire configuration file.

{
  "ainr": {
    "status": "enable",
    "mode": 1,
    "datrs_optm": 2,
    "pregain": "float:8.00",
    "mini_gain": "float:0.006",
    "alpha1": "float:0.6",
    "alpha2": "float:0.8",
    "preserve1": "float:1.05",
    "preserve2": "float:5.0",
    "preserve3": "float:0.6",
    "preserve4": "float:0.95",
    "sfs_enable": 1,
    "Sup_Freq1": 6000,
    "Sup_Freq2": -3588,
    "Sup_Energy1": "float:100000.0",
    "Sup_Energy2": "float:100000.0",
    "eq_enable": 1,
    "speech_eq": 1,
    "eq_frqs_hz": "0 800 1500 4000 4100 4200 8000 -1 -1 -1 -1",
    "eq_gains": "1.0 1.0 1.0 1.0 0.36 0.1786 0.1786 0 0 0 0",
    "model_path": "/oem/usr/share/vqefiles/rkaudio_model_ainr.rknn"
  }
}

Sup_Freq2: -3588, the float: strings and EQ arrays are retained as supplied. Do not infer valid ranges from field names or silently change values. The actual model path is:

/oem/usr/share/vqefiles/rkaudio_model_ainr.rknn

6. Dump signals and runtime parameters

Set variables before launching the application. Choose those supported by the Rockit/library version; legacy path variables and newer automatic naming need not both be enabled. Explanations originally following // are moved into prose so the shell does not treat them as extra arguments.

6.1 Legacy Rockit dump paths

export rt_debug_cap_file=/tmp/dbg_capin.pcm
export rt_debug_skv_out_file=/tmp/dbg_skvout.pcm
export rt_debug_skv_ao_out_file=/tmp/dbg_ao_skvout.pcm
export rt_debug_playback_file=/tmp/dbg_playback_out.pcm
Variable Exported signal
rt_debug_cap_file Capture before processing.
rt_debug_skv_out_file Capture after AI VQE.
rt_debug_skv_ao_out_file Data after AO VQE.
rt_debug_playback_file Data after all AO processing, expected to match digital loopback in the source setup.

6.2 Parameter logs and newer dumps

export rt_dump_skv_param=true
export RKAUDIO_SKV_DUMP_CONF=true
export rt_dump_skv_inout=true
export rt_dump_skv_ao_inout=true

The source lists rt_dump_skv_param for general Rockit AI VQE parameter logging and RKAUDIO_SKV_DUMP_CONF for newer algorithm libraries. Newer Rockit uses rt_dump_skv_inout and rt_dump_skv_ao_inout for AI and AO input/output dumps in /tmp, with these example filenames:

/tmp/dbg-skv-in-2ch-16000.pcm
/tmp/dbg-skv-out-1ch-16000.pcm
/tmp/dbg-skv-ao-in-2ch-16000.pcm
/tmp/dbg-skv-ao-out-1ch-16000.pcm

7. Enable AI VQE and check AO playback

Here AI means Audio Input and AO means Audio Output; “AI VQE” does not automatically mean neural-network noise reduction. The example takes two channels and outputs one, hence --out_ch 1:

rk_mpi_ai_test --sound_card_name=hw:0,0 --device_rate 16000 --device_ch 2 \
  --out_rate 16000 --out_ch 1 --output /tmp --vqe_enable 1 \
  --vqe_cfg /oem/usr/share/vqefiles/config_aivqe.json

At the same time, play the prepared remote speech on the playback side. Choose one of the following: the first leaves AO VQE disabled; the second enables its playback configuration.

rk_mpi_ao_test -i /userdata/remote_voice.wav --sound_card_name=hw:0,0 \
  --device_ch=2 --device_rate=16000 --input_rate=16000 --input_ch=2
rk_mpi_ao_test -i /userdata/remote_voice.wav --sound_card_name=hw:0,0 \
  --device_ch=2 --device_rate=16000 --input_rate=16000 --input_ch=2 \
  --vqe_cfg /oem/usr/share/vqefiles/config_aovqe.json --vqe_enable=1

Save parameter logs together with PCM before and after AI/AO processing. Import it into Audacity with the actual sample rate, channel count and sample format. PCM has no WAV header, so wrong import settings can distort speed, pitch or channel interpretation. Mark problem timestamps and compare reference, raw MIC and processed output for residual echo, damaged near-end speech and double-talk suppression.

8. Make tuning reproducible in an ArmSoM project

Voice projects such as those based on P2 Pro can follow the sequence acoustics/hardware → raw capture/playback → reference → processing. Check product interfaces and BSP before choosing the capture framework. The RV1106/RV1103 ADC ALC mapping and Rockit paths here do not replace board-specific configuration. Test audio, models and libraries are not embedded in this PDF; obtain the matching SDK resources.

Change one parameter group per iteration and record hardware/image versions, speaker and microphones, gains, JSON, model version, environment variables, raw files and failure timestamps. Retest near-end single-talk, far-end single-talk and double-talk. One call with no audible echo is not a complete acceptance test. Continue with the microphone-array guide below for acoustic acceptance checks.

Products and development resources

Check the hardware revision, carrier, image and interfaces in the product documentation. An article association is not evidence that a configuration has been tested.

These models are linked for further platform reading; the examples are not claimed to be ported to them.

Explore this topic → · Learning paths →