BAT

From AlsaProject
Jump to: navigation, search

Basic Audio Tester (BAT) is a simple command line utility intended to automate audio driver and sound server QA testing with no human interaction. It is also intended for anyone developing audio driver or sound server software or firmware under Linux.

BAT works by playing an audio stream and capturing the same stream in either a digital or analog loop back, and then analyzes the captured data to determine if the test case passes or fails. BAT can also records and analyzes audio stream that generated by a target device, and therefore no need to install and run BAT on the target device.

BAT supports ALSA/tinyalsa/PulseAudio/Cras backend. Therefore BAT can runs on embedded Linux, Linux distributions (e.g. Ubuntu/Fedora) and Chromium OS.

The wiki page gives a brief introduction for BAT. For more information, please refer to the man page (man alsabat) and wiki of alsabat project (alsabat wiki).

Contents

Infrastructure

The BAT (binary name: alsabat) consists of 3 components: playback, capture and analysis. Each of the components can be enabled and disabled independently though command options.

playback thread 
generates single tone signal and playback. The source comes from either a internal sine wave generator or a local wav (RIFF) file.
capture thread 
records signal and save as a wav (RIFF) file in /tmp.
analysis module 
analyzes a wav (RIFF) file in frequency domain and time domain. Return 0 if the data is clear. Return error code if frequency deviation, harmonic distortion or noise be found.

Work modes

BAT supports 5 working modes: loopback, single line playback, single line capture, local and standalone mode.

  • loopback - execute playback, capture and analysis in a loopback connection.
 $ alsabat -Dplughw:0,0
  • single line playback - playback without capture and analysis.
 $ alsabat -Pplughw:0,0
  • single line capture - capture and analyze data from another source.
 $ alsabat -Cplughw:0,0
  • local - analyze a local wav (RIFF) file directly without playback/capture.
 $ alsabat --local --file test.wav
  • standalone - bypass analysis. The option is used when instant FFT analysis is not necessary.
 $ alsabat -Cplughw:0,0 --standalone

Features

BAT supports 3 basic features that help audio driver testing: frequency detection, roundtrip latency measurement and noise detection. More features are in develop schedule.

  • frequency detection - to detect frequency of each channel, and report error code when frequency deviation or harmonic distortion be detected.
 $ alsabat -Dplughw:0,0 -c2 -F997:12000
  • roundtrip latency measurement - to measure roundtrip latency of target machine.
 $ alsabat --roundtriplatency
  • noise detection - to detect noise of each channel, and report error code when noise level is higher than threshold.
 $ alsabat --snr-db 50

Command options

A typical BAT command and output is:

 $ alsabat -Ddefault -c1 -r44100 -fS16_LE -F997 -n2.0s
 alsa-utils version 1.1.1
 
 Entering playback thread (ALSA).
 Get period size: 2756  buffer size: 22050
 Playing generated audio sine wave
 Entering capture thread (ALSA).
 Get period size: 2756  buffer size: 22050
 Recording ...
 Playback completed.
 Capture completed.
 
 BAT analysis: signal has 65536 frames at 44100 Hz, 1 channels, 2 bytes per sample.
 
 Channel 1 - Checking for target frequency 997.00 Hz
 Amplitude: 9782.7; Percentage: [29]
 Detected peak at 997.26 Hz of 35.74 dB
  Total 41.5 dB from 985.14 to 1008.70 Hz
  PASS: Peak detected at target frequency
 Detected at least 1 signal(s) in total
 
 Return value is 0
 $ 

The options above configures the playback device (default), the capture device (default), channel number (1), sample rate (44100), data format (S16_LE), frequency of single tone signal (997Hz), and signal period (2.0 seconds).

The command above is equivalent to command below, since some options are initialized by default:

 $ alsabat

Use "default" device to select audio server. For instance, "alsabat -Ddefault" is equivalent to "alsabat -Dpulse" on Ubuntu, or "alsabat -Dcras" on Chromium OS.

For detailed usage of command options, please refer to man page (man alsabat) and embedded test script (/usr/sbin/alsabat-test.sh).

Custom Search
Personal tools
Namespaces

Variants
Actions
Navigation
wiki
Toolbox