If audio data is captured on another device (ie we are NOT using
loopback mode), then allow alsabat to analyze that data, by passing
a filename reference on the command line.
Add the '--readcapture' option to the argument parser. When
this option is specified, avoid doing a local capture, and instead
just read the audio data from the indicated file, and analyze that.
Fixes: https://github.com/alsa-project/alsa-utils/pull/166
Signed-off-by: Tim Bird <tim.bird@sony.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Alsabat reports error when noise above threshold be detected.
Use either of the options below to designate the threshold. (e.g.
if the ratio of noise to signal is 5%, the snr is about 26dB.)
--snr-db <value in dB>
--snr-pc <value in %>
The noise detection is performed in time domain. On each period
of the sine wave being analyzed, alsabat substracts a clean sine
wave from the source, calculates the RMS value of the residual,
and compares the result with the threshold. At last, alsabat
returns the number of periods with noise above threshold. 0 is
returned when the source is clean.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Aligning the data type of fftw analyzer, sample converter and other
components on float, because:
1. avoid unnecessary data type conversion;
2. using float is more efficient than using double;
3. the extra double accuracy is not required.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Audio latency is the time delay as an audio signal passes through
a system. There are many kinds of audio latency metrics. One useful
metric is the round trip latency, which is the sum of output latency
and input latency.
The measurement step works like below:
1. Listen and measure the average loudness of the environment for
one second;
2. Create a threshold value 16 decibels higher than the average
loudness;
3. Begin playing a ~1000 Hz sine wave and start counting the samples
elapsed;
4. Stop counting and playing if the input's loudness is higher than
the threshold, as the output wave is probably coming back;
5. Calculate the audio latency value in milliseconds.
Signed-off-by: Zhang Vivian <vivian.zhang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add buffer size and period size settings in alsabat.
With -E and -B options, alsabat performs the test with
specified buffer size and period size
Signed-off-by: Zhang Vivian <vivian.zhang@intel.com>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
In loopback test, alsabat use pthread_join(pthread_t thread, **retval)
to wait for the capture thread to terminate. If the capture thread was
canceled, PTHREAD_CANCELED is placed in *retval, and the access to the
**retval will fail. Add status check to prevent illegal access to the
**retval.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use "configure --enable-alsabat-backend-tiny" for alsabat to use
tinyalsa as backend lib. On a system that has both ALSA and tinyalsa
installed, alsabat will use ALSA library by default.
The intention is for alsabat to run on tinyalsa platforms such as
Android or some Internet of Things(IoT) devices.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Move all alsa callings to a single block (alsa.c), so other blocks
such as the main structure, the signal process and the data analysis
modules will be independent to alsa, and new modules such as a
tinyalsa interface can be easily embedded into alsabat.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
All files should be opened in either "rb" or "wb" in current
usage.
Remove incorrect and unneccesary prints.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Preserve errno value before use, since the value might be
changed by another library call.
Add "#include <errno.h>" and remove redundant include.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add support for standalone mode where alsabat will run on a
different machine to the one being tested.
In standalone mode, the alsabat just generates, playback and
capture sound data like in normal mode, but does not analyze.
The alsabat being built without libfftw3 support is always work
in standalone mode.
The alsabat in normal mode can also bypass data analysis using
option "--standalone".
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add default name for the playback and capture devices, in case
they were not set by user through '-D', '-P' or '-C' options.
Previously, if no device be specified, the alsabat will start
a playback thread and a capture thread, and then exit the
threads with error log.
If only one of playback and capture is specified, the alsabat
will work on single line mode as before, where only one thread
(playback or capture) will be started.
The patch was tested on Ubuntu and Chrome OS.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
alsa-utils as well as bareos-bat (as well a some Bacula packages)
all contain a program called /usr/bin/bat, which causes conflicts on
various distributions ("basic audio tester" vs "bareos administration
tool"("bacula administration tool")).
Rename to avoid conflict.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Missing include became apparent when -O3 was not specified.
Added the header to remove error messages during debug compile.
Signed-off-by: Caleb Crome <caleb@crome.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use dynamic temp file instead of fixed temp file to store recorded
wav data, for better security.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
1. Change comment strings to make the descriptions more clear;
2. Add indent for option lines that have no indent;
3. Use a const string instead of argv[0] as program name.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use colon instead of comma to separate frequency parameters, for
in several locale comma may be handled as decimal point.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Cutting down 6 message strings to 2, as translators need to work
on each different variant.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add main entrance, command line parsing, parameter initiating and
thread initiating functions for BAT.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>