ALSABAT(1)

โœจ ALSABAT(1) โ€” the ALSA Basic Audio Tester ๐ŸŽ€

Okay so bestie, this is the manual for alsabat ๐Ÿฆ‹, a command-line sound tester for the ALSA sound card driver. It's your little helper for alsabat [flags] ๐Ÿ’…


๐Ÿ’– NAME

alsabat - command-line sound tester for ALSA sound card driver ๐Ÿ”Š

๐ŸŒธ SYNOPSIS

alsabat [flags]

๐Ÿงš DESCRIPTION

Okay so ALSABAT (short for ALSA Basic Audio Tester) is a simple command-line utility made to automate audio driver and sound server testing with barely any human involvement โœจ It's lowkey perfect for testing audio quality, stress testing features, and checking audio before and after PM state changes ๐Ÿ˜ญ

Here's the vibe: ALSABAT plays an audio stream and captures that same stream through either a digital or analog loopback ๐ŸŽง Then it compares the captured stream to the original using an FFT to figure out whether the test case passes or fails. Iconic, no cap ๐Ÿ”ฅ

ALSABAT can run wholly on the machine being tested (that's standalone mode ๐Ÿ ). Or it can run in client/server mode, where the alsabat client sits on the target and the server runs on a separate tester machine ๐Ÿซถ Client/server mode still needs a bit of manual synchronization, but it's actively being developed for future releases ๐ŸŒˆ

The hardware setup might need an analog cable going from the target to the tester machine ๐Ÿ”Œ Or a cable to create an analog loopback, if the sound hardware you're testing has no loopback mode. An analog loopback cable connects the "line in" jack to the "line out" jack to make a loopback ๐Ÿ’œ If you only have headphone and mic jacks (or a combo jack), this simple circuit can be used to create an analog loopback :-

https://source.android.com/devices/audio/loopback.html

If tinyalsa is installed on the system, you can choose tinyalsa as the backend lib of alsabat with the configure option --enable-alsabat-backend-tiny ๐Ÿ“

๐ŸŽ€ OPTIONS

  • -h, --help โ€” Help! Shows the syntax ๐Ÿ™ˆ
  • -D โ€” Picks the sound card to be tested, by name ๐ŸŽต
  • -P โ€” Picks the playback PCM device ๐Ÿ”ˆ
  • -C โ€” Picks the capture PCM device ๐ŸŽ™๏ธ
  • -f โ€” Sample format ๐Ÿ’…
    • Recognized sample formats are: U8 S16_LE S24_3LE S32_LE ๐ŸŒˆ
    • Some of these might not be available on your hardware, bestie ๐Ÿ˜ญ
    • The format shortcuts are:
      • -f cd (16 bit little endian, 44100, stereo) [-f S16_LE -c2 -r44100] ๐Ÿ’ฟ
      • -f dat (16 bit little endian, 48000, stereo) [-f S16_LE -c2 -r48000] ๐Ÿ“ผ
    • If you don't give a format, S16_LE is used โœจ
  • -c โ€” The number of channels. Default is one channel ๐Ÿฆ‹ Valid values right now are 1 or 2 ๐Ÿ‘‘
  • -r โ€” Sampling rate in Hertz ๐ŸŽถ The default rate is 44100 Hertz. Valid values depend on what your hardware supports ๐Ÿ’œ
  • -n โ€” Duration of the generated signal ๐Ÿ•ฐ๏ธ It can be either of two forms:
    1. A decimal integer, meaning number of frames ๐Ÿงฎ
    2. A floating point with the suffix s, meaning number of seconds โฑ๏ธ

The default is 2 seconds โญ

  • -k โ€” Sigma k value for analysis ๐Ÿง  Here's the tea: the analysis function reads data from a WAV file, runs an FFT on it to get the magnitude of the frequency vectors, then calculates the average value and standard deviation of those vectors ๐Ÿ“Š After that, it defines a threshold:
threshold = k * standard_deviation + mean_value

Frequencies with an amplitude larger than the threshold get recognized as a peak, and the frequency with the largest peak value is recognized as the detected frequency ๐Ÿ† ALSABAT then compares the detected frequency to the target frequency to decide if the test passes or fails ๐Ÿ’– The default value is 3.0 โœจ

  • -F โ€” Target frequency for signal generation and analysis, in Hertz ๐ŸŽฏ The default is 997.0 Hertz. Valid range is (DC_THRESHOLD, 40% * Sampling rate) ๐ŸŒธ
  • -p โ€” Total number of periods to play or capture ๐Ÿ”
  • --log=# โ€” Writes stderr and stdout output to this log file ๐Ÿ“
  • --file=# โ€” Input WAV file for playback ๐ŸŽž๏ธ
  • --saveplay=# โ€” Target WAV file to save the capture test content ๐Ÿ’พ
  • --local โ€” Internal loopback mode ๐Ÿ”’ Playback, capture, and analysis all stay internal to ALSABAT. This is meant for developers testing new ALSABAT features, since no audio gets routed outside of ALSABAT ๐Ÿง‘โ€๐Ÿ’ป
  • --standalone โ€” Adds support for standalone mode, where ALSABAT runs on a different machine from the one being tested ๐Ÿ๏ธ In standalone mode, sound data can be generated, played back, and captured just like in normal mode, but it won't be analyzed ๐Ÿ™…โ€โ™€๏ธ An ALSABAT built without libfftw3 support is always in standalone mode ๐Ÿ˜ญ The normal-mode ALSABAT can also skip data analysis using the option --standalone ๐Ÿ’…
  • --roundtriplatency โ€” Round trip latency test โณ Audio latency is the time delay as an audio signal passes through a system. There are lots of kinds of audio latency metrics, and one useful one is round trip latency, which is the sum of output latency and input latency ๐Ÿ”„
  • --snr-db=# โ€” Noise detection threshold in SNR (dB) ๐Ÿ“‰ 26dB indicates 5% noise in amplitude. ALSABAT will return an error if the signal SNR is smaller than the threshold ๐Ÿšจ
  • --snr-pc=# โ€” Noise detection threshold as a percentage of noise amplitude (%) ๐Ÿ“ˆ ALSABAT will return an error if the noise amplitude is larger than the threshold ๐Ÿฅ€

๐ŸŒˆ EXAMPLES

alsabat -P plughw:0,0 -C plughw:0,0 -c 2 -f S32_LE -F 250

Generates and plays a sine wave of 250 Hertz with 2 channels and S32_LE format, then captures and analyzes it ๐ŸŽถ

alsabat -P plughw:0,0 -C plughw:0,0 --file 500Hz.wav

Plays the RIFF WAV file "500Hz.wav", which contains 500 Hertz waveform LPCM data, then captures and analyzes it ๐Ÿฆ‹

๐Ÿ‘‘ RETURN VALUE

On success, it returns 0 โœจ If no peak is detected, it returns -1001 ๐Ÿ™ƒ If only DC is detected, it returns -1002 ๐Ÿ˜ญ If the peak frequency doesn't match the target frequency, it returns -1003 ๐Ÿ’€

๐Ÿ”— SEE ALSO

๐Ÿ› BUGS

Currently only RIFF WAV format with PCM data is supported. Please report any bugs to the alsa-devel mailing list ๐Ÿ™ˆ

๐Ÿซถ AUTHOR

alsabat is by Liam Girdwood <liam.r.girdwood@linux.intel.com>, Bernard Gautier <bernard.gautier@intel.com> and Han Lu <han.lu@intel.com>. This document is by Liam Girdwood <liam.r.girdwood@linux.intel.com> and Han Lu <han.lu@intel.com> ๐Ÿ’œ


Okay bestie, that's the whole ALSABAT tea ๐ŸŒˆ๐Ÿ’– Your sound testing era is about to be iconic โœจ Stay slay, stay curious, and I'll see you in the next manpage ๐Ÿฆ‹๐Ÿซถ