Commit graph

19 commits

Author SHA1 Message Date
Lu, Han
380c9fa444 alsabat: truncate sample frames for faster FFT analysis
Truncate the sample frames to powers of 2, since the FFTW algorithm
runs especially fast in this case, and other sizes may be computed
by means of a slow, general-purpose algorithm.
In my test environment applying the patch, a sound clip of 33072
frames is cut off to 32768 frames before analysis, and the time
cost is reduced from 6.128s to 0.224s.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-01 10:31:00 +01:00
Lu, Han
9fa7f6fd06 alsabat: rename to avoid naming conflict
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>
2016-02-03 08:49:53 +01:00
Takashi Iwai
ed0cce1b60 bat: Don't pass incompatible function pointers to pthread_cleanup_push()
pthread_cleanup_push() takes a function pointer for void (void *).
Although it may work in most cases, we shouldn't pass an incompatible
function pointer there, as some old gcc complains:
  alsa.c:560: warning: initialization from incompatible pointer type
  alsa.c:562: warning: initialization from incompatible pointer type

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-09 14:09:50 +01:00
Takashi Iwai
3bf8e79c3b bat: Avoid local signal.h file
The local header file named as "signal.h" causes mysterious compile
error when built with an old glibc.
 signal.h:27: error: conflicting types for 'sin_generator_init'
 ./signal.h:27: error: previous declaration of 'sin_generator_init' was here
 signal.h:28: error: conflicting types for 'sin_generator_next_sample'
 ./signal.h:28: error: previous declaration of 'sin_generator_next_sample' was here
 ....

This turned out to be the conflict of signal.h; namely, pthread.h that
is included before our local signal.h also includes "pthread.h".
Since our local "signal.h" has a higher priority, it gets loaded
instead of the expected pthread's one.  Then we load it again, and it
screws up.

Although it's basically a bug of pthread, it's anyway not good to have
a header file conflicting with the standard header file.  So, let's
name it more explicitly as specific to BAT, bat-signal.h, for avoiding
such a conflict.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-09 14:04:11 +01:00
Jaroslav Kysela
47e668f453 bat: add all headers to noinst_HEADERS
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2015-10-27 17:32:51 +01:00
Jaroslav Kysela
bc352dfba9 bat: don't link all binaries with fftw library, add missing header
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2015-10-27 17:15:58 +01:00
Caleb Crome
0960094905 BAT: Add missing locale.h header
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>
2015-10-24 09:43:26 +02:00
Lu, Han
73f9dd149e BAT: Add man page
Add more information about BAT utility, including design intent,
principles, use mode, hardware connection, options, example and
return value.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-21 09:29:52 +02:00
Lu, Han
2abee9c5b4 BAT: Use dynamic temp file
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>
2015-10-20 11:06:24 +02:00
Lu, Han
5a48606d94 BAT: Change comments and interface of usage()
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>
2015-10-20 11:06:24 +02:00
Lu, Han
8c910830f0 BAT: Use colon instead of comma for separation
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>
2015-10-20 11:06:24 +02:00
Lu, Han
2d0a124674 BAT: Remove redundant message strings
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>
2015-10-20 11:06:23 +02:00
Lu, Han
226ad884d2 BAT: Add Makefile and configures
Add Makefile and configures that enable BAT on alsa-utils

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>
2015-10-02 12:42:03 +02:00
Lu, Han
d727c9d90e BAT: Add spectrum analysis functions
Add functions that detecting signal frequency through spectrum
analyzing.

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>
2015-10-02 12:42:03 +02:00
Lu, Han
6c4c5e51fa BAT: Add converting functions
Add functions that converting audio samples to double data for analysis,
and functions that converting float data to audio samples for playback.

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>
2015-10-02 12:42:02 +02:00
Lu, Han
34e9ae911f BAT: Add signal generator
Add function that generates sine waveform through math lib.
The waveform can be used as source for playback or analysis.

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: Caleb Crome <caleb@crome.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 12:42:02 +02:00
Lu, Han
05850912b8 BAT: Add playback and record functions
Add functions as main loop of playback thread and record thread.
The functions access pcm hardware through ALSA APIs.

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>
2015-10-02 12:42:01 +02:00
Lu, Han
cba9050edf BAT: Add common definitions and functions
Add common definitions of macros and data structures; Add functions
that used by multiple components, such as wav file reading and writing.

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>
2015-10-02 12:42:01 +02:00
Lu, Han
c7e0c35661 BAT: Add initial functions
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>
2015-10-02 12:42:00 +02:00