mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 00:23:34 +02:00
- separates audio system round trip time determination from echo cancellation
- changes speex parameters to more humble values - resolves build issues by removing the speex dylibs - static ones are fine - tightens build script
This commit is contained in:
parent
651dc19427
commit
7588b7f6bb
13 changed files with 34 additions and 122 deletions
|
@ -47,7 +47,7 @@
|
|||
|
||||
if (SPEEXDSP_INCLUDE_DIRS AND SPEEXDSP_LIBRARIES)
|
||||
set(SPEEXDSP_FOUND TRUE)
|
||||
else (SPEEXDSP_INCLUDE_DIRS)
|
||||
else (SPEEXDSP_INCLUDE_DIRS AND SPEEXDSP_LIBRARIES)
|
||||
|
||||
find_path(SPEEXDSP_INCLUDE_DIRS speex/speex.h
|
||||
/usr/include
|
||||
|
@ -84,5 +84,5 @@ else (SPEEXDSP_INCLUDE_DIRS)
|
|||
|
||||
mark_as_advanced(SPEEXDSP_INCLUDE_DIRS SPEEXDSP_LIBRARIES)
|
||||
|
||||
endif (SPEEXDSP_INCLUDE_DIRS)
|
||||
endif (SPEEXDSP_INCLUDE_DIRS AND SPEEXDSP_LIBRARIES)
|
||||
|
||||
|
|
Binary file not shown.
BIN
interface/external/Speex/lib/MacOS/libspeex.1.dylib
vendored
BIN
interface/external/Speex/lib/MacOS/libspeex.1.dylib
vendored
Binary file not shown.
BIN
interface/external/Speex/lib/MacOS/libspeex.dylib
vendored
BIN
interface/external/Speex/lib/MacOS/libspeex.dylib
vendored
Binary file not shown.
35
interface/external/Speex/lib/MacOS/libspeex.la
vendored
35
interface/external/Speex/lib/MacOS/libspeex.la
vendored
|
@ -1,35 +0,0 @@
|
|||
# libspeex.la - a libtool library file
|
||||
# Generated by ltmain.sh - GNU libtool 1.5.22 Debian 1.5.22-4 (1.1220.2.365 2005/12/18 22:14:06)
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='libspeex.1.dylib'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libspeex.1.5.0.dylib libspeex.1.dylib libspeex.dylib'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libspeex.a'
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lm'
|
||||
|
||||
# Version information for libspeex.
|
||||
current=6
|
||||
age=5
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/usr/local/speex/lib'
|
Binary file not shown.
Binary file not shown.
BIN
interface/external/Speex/lib/MacOS/libspeexdsp.dylib
vendored
BIN
interface/external/Speex/lib/MacOS/libspeexdsp.dylib
vendored
Binary file not shown.
|
@ -1,35 +0,0 @@
|
|||
# libspeexdsp.la - a libtool library file
|
||||
# Generated by ltmain.sh - GNU libtool 1.5.22 Debian 1.5.22-4 (1.1220.2.365 2005/12/18 22:14:06)
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='libspeexdsp.1.dylib'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libspeexdsp.1.5.0.dylib libspeexdsp.1.dylib libspeexdsp.dylib'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libspeexdsp.a'
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lm'
|
||||
|
||||
# Version information for libspeexdsp.
|
||||
current=6
|
||||
age=5
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/usr/local/speex/lib'
|
|
@ -1,15 +0,0 @@
|
|||
# libspeex pkg-config source file
|
||||
|
||||
prefix=/usr/local/speex
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: speex
|
||||
Description: Speex is an audio codec tuned for speech
|
||||
Version: 1.2rc1
|
||||
Requires:
|
||||
Conflicts:
|
||||
Libs: -L${libdir} -lspeex
|
||||
Libs.private: -lm
|
||||
Cflags: -I${includedir}
|
|
@ -1,15 +0,0 @@
|
|||
# libspeexdsp pkg-config source file
|
||||
|
||||
prefix=/usr/local/speex
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: speexdsp
|
||||
Description: Speexdsp is a speech processing library that goes along with the Speex codec
|
||||
Version: 1.2rc1
|
||||
Requires:
|
||||
Conflicts:
|
||||
Libs: -L${libdir} -lspeexdsp
|
||||
Libs.private: -lm
|
||||
Cflags: -I${includedir}
|
|
@ -55,7 +55,7 @@ static const int AGENT_LOOPBACK_MODIFIER = 307;
|
|||
// Speex preprocessor and echo canceller adaption
|
||||
static const int AEC_N_CHANNELS_MIC = 1; // Number of microphone channels
|
||||
static const int AEC_N_CHANNELS_PLAY = 2; // Number of speaker channels
|
||||
static const int AEC_FILTER_LENGTH = BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 8; // Width of the filter
|
||||
static const int AEC_FILTER_LENGTH = BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 20; // Width of the filter
|
||||
static const int AEC_BUFFERED_FRAMES = 6; // Maximum number of frames to buffer
|
||||
static const int AEC_BUFFERED_SAMPLES_PER_CHANNEL = BUFFER_LENGTH_SAMPLES_PER_CHANNEL * AEC_BUFFERED_FRAMES;
|
||||
static const int AEC_BUFFERED_SAMPLES = AEC_BUFFERED_SAMPLES_PER_CHANNEL * AEC_N_CHANNELS_PLAY;
|
||||
|
@ -63,14 +63,14 @@ static const int AEC_TMP_BUFFER_SIZE = (AEC_N_CHANNELS_MIC +
|
|||
AEC_N_CHANNELS_PLAY) * BUFFER_LENGTH_SAMPLES_PER_CHANNEL; // single frame
|
||||
|
||||
// Speex preprocessor and echo canceller configuration
|
||||
static const int AEC_NOISE_REDUCTION = -400; // Noise reduction (important)
|
||||
static const int AEC_NOISE_REDUCTION = -80; // Noise reduction (important)
|
||||
static const int AEC_RESIDUAL_ECHO_REDUCTION = -60; // Residual echo reduction
|
||||
static const int AEC_RESIDUAL_ECHO_REDUCTION_ACTIVE = -40; // ~on active side
|
||||
static const int AEC_RESIDUAL_ECHO_REDUCTION_ACTIVE = -45; // ~on active side
|
||||
static const bool AEC_USE_AGC = true; // Automatic gain control
|
||||
static const int AEC_AGC_MAX_GAIN = -12; // Gain in db
|
||||
static const int AEC_AGC_TARGET_LEVEL = 20000; // Target reference level
|
||||
static const int AEC_AGC_MAX_GAIN = -30; // Gain in db
|
||||
static const int AEC_AGC_TARGET_LEVEL = 9000; // Target reference level
|
||||
static const int AEC_AGC_MAX_INC = 6; // Max increase in db/s
|
||||
static const int AEC_AGC_MAX_DEC = 40; // Max decrease in db/s
|
||||
static const int AEC_AGC_MAX_DEC = 200; // Max decrease in db/s
|
||||
static const bool AEC_USE_VAD = false; // Voice activity determination
|
||||
|
||||
// Ping test configuration
|
||||
|
@ -305,7 +305,7 @@ Audio::Audio(Oscilloscope* scope) :
|
|||
_scope(scope),
|
||||
_averagedLatency(0.0),
|
||||
_measuredJitter(0),
|
||||
_jitterBufferLengthMsecs(12.0),
|
||||
// _jitterBufferLengthMsecs(12.0),
|
||||
// _jitterBufferSamples(_jitterBufferLengthMsecs *
|
||||
// NUM_AUDIO_CHANNELS * (SAMPLE_RATE / 1000.0)),
|
||||
_wasStarved(0),
|
||||
|
@ -317,7 +317,7 @@ Audio::Audio(Oscilloscope* scope) :
|
|||
_firstPlaybackTime(),
|
||||
_packetsReceivedThisPlayback(0),
|
||||
_isCancellingEcho(false),
|
||||
_echoDelay(BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2),
|
||||
_echoDelay(0),
|
||||
_echoSamplesLeft(0l),
|
||||
_speexEchoState(NULL),
|
||||
_speexPreprocessState(NULL),
|
||||
|
@ -544,8 +544,21 @@ void Audio::addProceduralSounds(int16_t* inputBuffer, int numSamples) {
|
|||
// Speex-based echo cancellation
|
||||
// -----------------------------
|
||||
|
||||
bool Audio::isCancellingEcho() const {
|
||||
return _isCancellingEcho && ! (_pingFramesToRecord != 0 || _pingAnalysisPending || ! _speexPreprocessState);
|
||||
}
|
||||
|
||||
void Audio::setIsCancellingEcho(bool enable) {
|
||||
if (enable) {
|
||||
speex_echo_state_reset(_speexEchoState);
|
||||
_echoWritePos = 0;
|
||||
memset(_echoSamplesLeft, 0, AEC_BUFFERED_SAMPLES * sizeof(int16_t));
|
||||
}
|
||||
_isCancellingEcho = enable;
|
||||
}
|
||||
|
||||
inline void Audio::eventuallyCancelEcho(int16_t* inputLeft) {
|
||||
if (! _isCancellingEcho || _pingFramesToRecord != 0 || ! _speexPreprocessState) {
|
||||
if (! isCancellingEcho()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -584,7 +597,7 @@ inline void Audio::eventuallyCancelEcho(int16_t* inputLeft) {
|
|||
}
|
||||
|
||||
inline void Audio::eventuallyRecordEcho(int16_t* outputLeft, int16_t* outputRight) {
|
||||
if (! _isCancellingEcho || _pingFramesToRecord != 0 || ! _speexPreprocessState) {
|
||||
if (! isCancellingEcho()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -702,7 +715,7 @@ inline void Audio::analyzePing() {
|
|||
}
|
||||
|
||||
// Determine period - warn if doesn't look like our signal
|
||||
int halfPeriod = topAt - botAt;
|
||||
int halfPeriod = abs(topAt - botAt);
|
||||
if (abs(halfPeriod-PING_HALF_PERIOD) > PING_MAX_PERIOD_DIFFERENCE) {
|
||||
printLog("Audio Ping unreliable - peak distance %d vs. %d\n", halfPeriod, PING_HALF_PERIOD);
|
||||
}
|
||||
|
@ -745,11 +758,9 @@ inline void Audio::analyzePing() {
|
|||
|
||||
int delay = (botAt + topAt) / 2 + PING_PERIOD;
|
||||
|
||||
printLog("| Audio Ping results:\n"
|
||||
"+----- ---- --- - - - - -\n"
|
||||
"\n"
|
||||
" Delay = %d samples (%d ms)\n"
|
||||
" Peak amplitude = %d\n\n", delay, delay * 1000 / SAMPLE_RATE, ampli);
|
||||
printLog("\n| Audio Ping results:\n+----- ---- --- - - - - -\n\n"
|
||||
"Delay = %d samples (%d ms)\nPeak amplitude = %d\n\n",
|
||||
delay, (delay * 1000) / int(SAMPLE_RATE), ampli);
|
||||
}
|
||||
|
||||
bool Audio::eventuallyAnalyzePing() {
|
||||
|
@ -757,9 +768,10 @@ bool Audio::eventuallyAnalyzePing() {
|
|||
if (! _pingAnalysisPending) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_scope->inputPaused = true;
|
||||
analyzePing();
|
||||
setIsCancellingEcho(_isCancellingEcho);
|
||||
_pingAnalysisPending = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
void setLastAcceleration(glm::vec3 lastAcceleration) { _lastAcceleration = lastAcceleration; };
|
||||
void setLastVelocity(glm::vec3 lastVelocity) { _lastVelocity = lastVelocity; };
|
||||
|
||||
void setIsCancellingEcho(bool enabled) { _isCancellingEcho = enabled; }
|
||||
bool isCancellingEcho() const { return _isCancellingEcho; }
|
||||
void setIsCancellingEcho(bool enabled);
|
||||
bool isCancellingEcho() const;
|
||||
|
||||
void ping();
|
||||
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
timeval _lastReceiveTime;
|
||||
float _averagedLatency;
|
||||
float _measuredJitter;
|
||||
float _jitterBufferLengthMsecs;
|
||||
// float _jitterBufferLengthMsecs; // currently unused
|
||||
// short _jitterBufferSamples; // currently unsused
|
||||
int _wasStarved;
|
||||
int _numStarves;
|
||||
|
|
Loading…
Reference in a new issue