Skip to content
Snippets Groups Projects
Commit d1efed8b authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#958] Make libspeexdsp a required dependency

parent 158543bc
No related branches found
No related tags found
No related merge requests found
...@@ -341,17 +341,19 @@ AC_ARG_WITH([speex], ...@@ -341,17 +341,19 @@ AC_ARG_WITH([speex],
AS_IF([test "x$with_speex" != xno], AS_IF([test "x$with_speex" != xno],
[AC_CHECK_HEADER([speex/speex.h], , AC_MSG_FAILURE([Unable to find the libspeex headers (you may need to install the dev package). You may use --without-speex to compile without speex codec support.]))] [AC_CHECK_HEADER([speex/speex.h], , AC_MSG_FAILURE([Unable to find the libspeex headers (you may need to install the dev package). You may use --without-speex to compile without speex codec support.]))]
[AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Unable to find the libspeexdsp headers (you may need to install the libspeexdsp-dev package). You may use --without-speex to compile without speex codec support.]))]
[AC_CHECK_LIB([speex], [speex_decode_int], [AC_CHECK_LIB([speex], [speex_decode_int],
[], [],
[AC_MSG_FAILURE( [AC_MSG_FAILURE(
[libspeex link test failed. You may use --without-speex to compile without speex codec support.])] [libspeex link test failed. You may use --without-speex to compile without speex codec support.])]
) )
] ]
dnl More advanced check in case the libspeexdsp is not installed # dnl More advanced check in case the libspeexdsp is not installed
AC_SEARCH_LIBS(speex_preprocess_run, speexdsp, HAVE_SPEEXDSP="yes", HAVE_SPEEXDSP="no", []) # AC_SEARCH_LIBS(speex_preprocess_run, speexdsp, HAVE_SPEEXDSP="yes", HAVE_SPEEXDSP="no", [])
) )
dnl check in case the libspeexdsp is not installed
AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Unable to find the libspeexdsp headers (you may need to install the libspeexdsp-dev package) used for Noise Suppression and Automatic Gain Control.]))
AC_CHECK_LIB(speexdsp, speex_preprocess_run, [], [], [])
AC_DEFINE([HAVE_SPEEX], test "x$with_speex" = "xyes", [Define if you have libspeex]) AC_DEFINE([HAVE_SPEEX], test "x$with_speex" = "xyes", [Define if you have libspeex])
AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" ) AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" )
AM_CONDITIONAL(ENABLE_SPEEXDSP, test $HAVE_SPEEXDSP = yes) AM_CONDITIONAL(ENABLE_SPEEXDSP, test $HAVE_SPEEXDSP = yes)
......
...@@ -4,6 +4,10 @@ noinst_LTLIBRARIES = libaudio.la ...@@ -4,6 +4,10 @@ noinst_LTLIBRARIES = libaudio.la
SUBDIRS = codecs audiortp sound alsa pulseaudio SUBDIRS = codecs audiortp sound alsa pulseaudio
# if ENABLE_SPEEXDSP
# SPEEXDSP=-DHAVE_SPEEXDSP_LIB
# endif
libaudio_la_SOURCES = \ libaudio_la_SOURCES = \
audioloop.cpp \ audioloop.cpp \
ringbuffer.cpp \ ringbuffer.cpp \
......
...@@ -13,10 +13,6 @@ libcodec_gsm_so_LDFLAGS = --shared -lc -lgsm ...@@ -13,10 +13,6 @@ libcodec_gsm_so_LDFLAGS = --shared -lc -lgsm
INSTALL_GSM_RULE = install-libcodec_gsm_so INSTALL_GSM_RULE = install-libcodec_gsm_so
endif endif
if ENABLE_SPEEXDSP
SPEEXDSP=-DHAVE_SPEEXDSP_LIB
endif
if BUILD_SPEEX if BUILD_SPEEX
SPEEX_NB_LIB = libcodec_speex_nb.so SPEEX_NB_LIB = libcodec_speex_nb.so
libcodec_speex_nb_so_SOURCES = speexcodec_nb.cpp libcodec_speex_nb_so_SOURCES = speexcodec_nb.cpp
......
...@@ -45,8 +45,7 @@ class Speex : public AudioCodec ...@@ -45,8 +45,7 @@ class Speex : public AudioCodec
_speex_enc_bits(), _speex_enc_bits(),
_speex_dec_state(), _speex_dec_state(),
_speex_enc_state(), _speex_enc_state(),
_speex_frame_size(), _speex_frame_size() {
_preprocess_state() {
_clockRate = 8000; _clockRate = 8000;
_frameSize = 160; // samples, 20 ms at 8kHz _frameSize = 160; // samples, 20 ms at 8kHz
_channel = 1; _channel = 1;
...@@ -77,32 +76,6 @@ class Speex : public AudioCodec ...@@ -77,32 +76,6 @@ class Speex : public AudioCodec
speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size); speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size);
/*
#ifdef HAVE_SPEEXDSP_LIB
int enable = 1;
int quality = 10;
int complex = 10;
int attenuation = -10;
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_VAD, &enable);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_DTX, &enable);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_VBR_QUALITY, &quality);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_COMPLEXITY, &complex);
// Init the decoder struct
speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size);
// Init the preprocess struct
_preprocess_state = speex_preprocess_state_init (_speex_frame_size,_clockRate);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &enable);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &attenuation);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_VAD, &enable);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_AGC, &enable);
#endif
*/
} }
~Speex() { ~Speex() {
...@@ -119,9 +92,6 @@ class Speex : public AudioCodec ...@@ -119,9 +92,6 @@ class Speex : public AudioCodec
speex_bits_destroy (&_speex_enc_bits); speex_bits_destroy (&_speex_enc_bits);
speex_encoder_destroy (_speex_enc_state); speex_encoder_destroy (_speex_enc_state);
_speex_enc_state = 0; _speex_enc_state = 0;
speex_preprocess_state_destroy( _preprocess_state);
_preprocess_state = NULL;
} }
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
...@@ -137,13 +107,6 @@ class Speex : public AudioCodec ...@@ -137,13 +107,6 @@ class Speex : public AudioCodec
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) {
speex_bits_reset (&_speex_enc_bits); speex_bits_reset (&_speex_enc_bits);
/*
#ifdef HAVE_SPEEXDSP_LIB
speex_preprocess_run (_preprocess_state, src);
#endif
*/
speex_encode_int (_speex_enc_state, src, &_speex_enc_bits); speex_encode_int (_speex_enc_state, src, &_speex_enc_bits);
int nbBytes = speex_bits_write (&_speex_enc_bits, (char*) dst, size); int nbBytes = speex_bits_write (&_speex_enc_bits, (char*) dst, size);
...@@ -157,7 +120,6 @@ class Speex : public AudioCodec ...@@ -157,7 +120,6 @@ class Speex : public AudioCodec
void *_speex_dec_state; void *_speex_dec_state;
void *_speex_enc_state; void *_speex_enc_state;
int _speex_frame_size; int _speex_frame_size;
SpeexPreprocessState *_preprocess_state;
}; };
// the class factories // the class factories
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "audiocodec.h" #include "audiocodec.h"
#include <cstdio> #include <cstdio>
#include <speex/speex.h> #include <speex/speex.h>
#include <speex/speex_preprocess.h>
class Speex : public AudioCodec class Speex : public AudioCodec
{ {
...@@ -45,8 +44,7 @@ class Speex : public AudioCodec ...@@ -45,8 +44,7 @@ class Speex : public AudioCodec
_speex_enc_bits(), _speex_enc_bits(),
_speex_dec_state(), _speex_dec_state(),
_speex_enc_state(), _speex_enc_state(),
_speex_frame_size(), _speex_frame_size() {
_preprocess_state() {
_clockRate = 32000; _clockRate = 32000;
_frameSize = 640; // 20 ms at 32 kHz _frameSize = 640; // 20 ms at 32 kHz
_channel = 1; _channel = 1;
...@@ -78,30 +76,6 @@ class Speex : public AudioCodec ...@@ -78,30 +76,6 @@ class Speex : public AudioCodec
speex_encoder_ctl (_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate); speex_encoder_ctl (_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate);
speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size); speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size);
/*
#ifdef HAVE_SPEEXDSP_LIB
int enable = 1;
int complex = 10;
int attenuation = -10;
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_VAD, &enable);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_DTX, &enable);
// speex_encoder_ctl(_speex_enc_state, SPEEX_SET_VBR_QUALITY, &quality);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_COMPLEXITY, &complex);
// Init the decoder struct
speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_frameSize);
// Init the preprocess struct
_preprocess_state = speex_preprocess_state_init (_frameSize,_clockRate);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &enable);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &attenuation);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_VAD, &enable);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_AGC, &enable);
#endif
*/
} }
~Speex() { ~Speex() {
...@@ -119,8 +93,6 @@ class Speex : public AudioCodec ...@@ -119,8 +93,6 @@ class Speex : public AudioCodec
speex_encoder_destroy (_speex_enc_state); speex_encoder_destroy (_speex_enc_state);
_speex_enc_state = 0; _speex_enc_state = 0;
speex_preprocess_state_destroy( _preprocess_state);
_preprocess_state = NULL;
} }
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
...@@ -136,13 +108,6 @@ class Speex : public AudioCodec ...@@ -136,13 +108,6 @@ class Speex : public AudioCodec
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) {
speex_bits_reset (&_speex_enc_bits); speex_bits_reset (&_speex_enc_bits);
/*
#ifdef HAVE_SPEEXDSP_LIB
speex_preprocess_run (_preprocess_state, src);
#endif
*/
speex_encode_int (_speex_enc_state, src, &_speex_enc_bits); speex_encode_int (_speex_enc_state, src, &_speex_enc_bits);
speex_bits_nbytes (&_speex_enc_bits); speex_bits_nbytes (&_speex_enc_bits);
int nbBytes = speex_bits_write (&_speex_enc_bits, (char*) dst, size); int nbBytes = speex_bits_write (&_speex_enc_bits, (char*) dst, size);
...@@ -157,7 +122,6 @@ class Speex : public AudioCodec ...@@ -157,7 +122,6 @@ class Speex : public AudioCodec
void *_speex_dec_state; void *_speex_dec_state;
void *_speex_enc_state; void *_speex_enc_state;
int _speex_frame_size; int _speex_frame_size;
SpeexPreprocessState *_preprocess_state;
}; };
// the class factories // the class factories
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "audiocodec.h" #include "audiocodec.h"
#include <cstdio> #include <cstdio>
#include <speex/speex.h> #include <speex/speex.h>
#include <speex/speex_preprocess.h>
class Speex : public AudioCodec class Speex : public AudioCodec
{ {
...@@ -45,8 +44,7 @@ class Speex : public AudioCodec ...@@ -45,8 +44,7 @@ class Speex : public AudioCodec
_speex_enc_bits(), _speex_enc_bits(),
_speex_dec_state(), _speex_dec_state(),
_speex_enc_state(), _speex_enc_state(),
_speex_frame_size(), _speex_frame_size() {
_preprocess_state() {
_clockRate = 16000; _clockRate = 16000;
_frameSize = 320; // 20 ms at 16 kHz _frameSize = 320; // 20 ms at 16 kHz
_channel = 1; _channel = 1;
...@@ -77,31 +75,6 @@ class Speex : public AudioCodec ...@@ -77,31 +75,6 @@ class Speex : public AudioCodec
speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size); speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size);
/*
#ifdef HAVE_SPEEXDSP_LIB
int enable = 1;
int quality = 10;
int complex = 10;
int attenuation = -10;
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_VAD, &enable);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_DTX, &enable);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_VBR_QUALITY, &quality);
speex_encoder_ctl (_speex_enc_state, SPEEX_SET_COMPLEXITY, &complex);
// Init the decoder struct
speex_decoder_ctl (_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size);
// Init the preprocess struct
_preprocess_state = speex_preprocess_state_init (_speex_frame_size,_clockRate);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &enable);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &attenuation);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_VAD, &enable);
speex_preprocess_ctl (_preprocess_state, SPEEX_PREPROCESS_SET_AGC, &enable);
#endif
*/
} }
~Speex() { ~Speex() {
...@@ -119,8 +92,6 @@ class Speex : public AudioCodec ...@@ -119,8 +92,6 @@ class Speex : public AudioCodec
speex_encoder_destroy (_speex_enc_state); speex_encoder_destroy (_speex_enc_state);
_speex_enc_state = 0; _speex_enc_state = 0;
speex_preprocess_state_destroy( _preprocess_state);
_preprocess_state = NULL;
} }
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
...@@ -137,13 +108,6 @@ class Speex : public AudioCodec ...@@ -137,13 +108,6 @@ class Speex : public AudioCodec
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) {
speex_bits_reset (&_speex_enc_bits); speex_bits_reset (&_speex_enc_bits);
/*
#ifdef HAVE_SPEEXDSP_LIB
speex_preprocess_run (_preprocess_state, src);
#endif
*/
//printf ("Codec::codecEncode() size %i\n", size); //printf ("Codec::codecEncode() size %i\n", size);
speex_encode_int (_speex_enc_state, src, &_speex_enc_bits); speex_encode_int (_speex_enc_state, src, &_speex_enc_bits);
int nbBytes = speex_bits_write (&_speex_enc_bits, (char*) dst, size); int nbBytes = speex_bits_write (&_speex_enc_bits, (char*) dst, size);
...@@ -158,7 +122,6 @@ class Speex : public AudioCodec ...@@ -158,7 +122,6 @@ class Speex : public AudioCodec
void *_speex_dec_state; void *_speex_dec_state;
void *_speex_enc_state; void *_speex_enc_state;
int _speex_frame_size; int _speex_frame_size;
SpeexPreprocessState *_preprocess_state;
}; };
// the class factories // the class factories
......
...@@ -90,7 +90,6 @@ EchoCancel::EchoCancel(int smplRate, int frameLength) : _samplingRate(smplRate), ...@@ -90,7 +90,6 @@ EchoCancel::EchoCancel(int smplRate, int frameLength) : _samplingRate(smplRate),
_spkrHistoryLength = SPKR_LENGTH / SEGMENT_LENGTH; _spkrHistoryLength = SPKR_LENGTH / SEGMENT_LENGTH;
_nbSegmentPerFrame = _frameLength / SEGMENT_LENGTH; _nbSegmentPerFrame = _frameLength / SEGMENT_LENGTH;
// #ifdef HAVE_SPEEXDSP_LIB
_noiseState = speex_preprocess_state_init(_smplPerFrame, _samplingRate); _noiseState = speex_preprocess_state_init(_smplPerFrame, _samplingRate);
int i=1; int i=1;
speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DENOISE, &i); speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DENOISE, &i);
...@@ -110,7 +109,7 @@ EchoCancel::EchoCancel(int smplRate, int frameLength) : _samplingRate(smplRate), ...@@ -110,7 +109,7 @@ EchoCancel::EchoCancel(int smplRate, int frameLength) : _samplingRate(smplRate),
speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f); speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
i = 0; i = 0;
speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_VAD, &i); speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_VAD, &i);
// #endif
memset(_avgSpkrLevelHist, 0, BUFF_SIZE*sizeof(int)); memset(_avgSpkrLevelHist, 0, BUFF_SIZE*sizeof(int));
memset(_avgMicLevelHist, 0, BUFF_SIZE*sizeof(int)); memset(_avgMicLevelHist, 0, BUFF_SIZE*sizeof(int));
...@@ -135,9 +134,7 @@ EchoCancel::~EchoCancel() ...@@ -135,9 +134,7 @@ EchoCancel::~EchoCancel()
delete _spkrData; delete _spkrData;
_spkrData = NULL; _spkrData = NULL;
// #ifdef HAVE_SPEEXDSP_LIB
speex_preprocess_state_destroy(_noiseState); speex_preprocess_state_destroy(_noiseState);
// #endif
// micFile->close(); // micFile->close();
// spkrFile->close(); // spkrFile->close();
...@@ -189,7 +186,6 @@ void EchoCancel::reset() ...@@ -189,7 +186,6 @@ void EchoCancel::reset()
_spkrData->flushAll(); _spkrData->flushAll();
_spkrDataOut->flushAll(); _spkrDataOut->flushAll();
// #ifdef HAVE_SPEEXDSP_LIB
speex_preprocess_state_destroy(_noiseState); speex_preprocess_state_destroy(_noiseState);
_noiseState = speex_preprocess_state_init(_smplPerFrame, _samplingRate); _noiseState = speex_preprocess_state_init(_smplPerFrame, _samplingRate);
...@@ -210,8 +206,6 @@ void EchoCancel::reset() ...@@ -210,8 +206,6 @@ void EchoCancel::reset()
f=0.0; f=0.0;
speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f); speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
// #endif
_spkrStoped = true; _spkrStoped = true;
_processedByte = 0; _processedByte = 0;
...@@ -290,12 +284,14 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int ...@@ -290,12 +284,14 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
// micFile->write((const char *)_tmpMic, byteSize); // micFile->write((const char *)_tmpMic, byteSize);
// spkrFile->write((const char *)_tmpSpkr, byteSize); // spkrFile->write((const char *)_tmpSpkr, byteSize);
// #ifdef HAVE_SPEEXDSP_LIB #ifdef HAVE_LIBSPEEX_DSP
_debug("OK");
// Remove noise // Remove noise
if(_noiseActive) if(_noiseActive)
speex_preprocess_run(_noiseState, _tmpMic); speex_preprocess_run(_noiseState, _tmpMic);
// #endif #endif
// Processed echo cancellation // Processed echo cancellation
performEchoCancel(_tmpMic, _tmpSpkr, _tmpOut); performEchoCancel(_tmpMic, _tmpSpkr, _tmpOut);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment