Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
db945995
Commit
db945995
authored
May 27, 2010
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[
#959
] Use -32 dB noise attenuation in speex noise canceller (default -15 dB)
parent
b2497fed
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-common/src/audio/echocancel.cpp
+17
-29
17 additions, 29 deletions
sflphone-common/src/audio/echocancel.cpp
with
17 additions
and
29 deletions
sflphone-common/src/audio/echocancel.cpp
+
17
−
29
View file @
db945995
...
@@ -59,12 +59,14 @@ EchoCancel::EchoCancel(int smplRate, int frameLength) : _samplingRate(smplRate),
...
@@ -59,12 +59,14 @@ EchoCancel::EchoCancel(int smplRate, int frameLength) : _samplingRate(smplRate),
{
{
_debug
(
"EchoCancel: Instantiate echo canceller"
);
_debug
(
"EchoCancel: Instantiate echo canceller"
);
/*
micFile = new ofstream("micData", ofstream::binary);
micFile = new ofstream("micData", ofstream::binary);
echoFile = new ofstream("echoData", ofstream::binary);
echoFile = new ofstream("echoData", ofstream::binary);
spkrFile = new ofstream("spkrData", ofstream::binary);
spkrFile = new ofstream("spkrData", ofstream::binary);
micLevelData = new ofstream("micLevelData", ofstream::binary);
micLevelData = new ofstream("micLevelData", ofstream::binary);
spkrLevelData = new ofstream("spkrLevelData", ofstream::binary);
spkrLevelData = new ofstream("spkrLevelData", ofstream::binary);
*/
_micData
=
new
RingBuffer
(
50000
);
_micData
=
new
RingBuffer
(
50000
);
_spkrData
=
new
RingBuffer
(
50000
);
_spkrData
=
new
RingBuffer
(
50000
);
...
@@ -121,6 +123,7 @@ EchoCancel::~EchoCancel()
...
@@ -121,6 +123,7 @@ EchoCancel::~EchoCancel()
speex_preprocess_state_destroy
(
_noiseState
);
speex_preprocess_state_destroy
(
_noiseState
);
/*
micFile->close();
micFile->close();
spkrFile->close();
spkrFile->close();
echoFile->close();
echoFile->close();
...
@@ -133,7 +136,7 @@ EchoCancel::~EchoCancel()
...
@@ -133,7 +136,7 @@ EchoCancel::~EchoCancel()
spkrLevelData->close();
spkrLevelData->close();
delete micLevelData;
delete micLevelData;
delete spkrLevelData;
delete spkrLevelData;
*/
}
}
...
@@ -179,6 +182,8 @@ void EchoCancel::reset()
...
@@ -179,6 +182,8 @@ void EchoCancel::reset()
_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
);
i
=-
30
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS
,
&
i
);
i
=
0
;
i
=
0
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_AGC
,
&
i
);
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_AGC
,
&
i
);
i
=
8000
;
i
=
8000
;
...
@@ -197,8 +202,6 @@ void EchoCancel::reset()
...
@@ -197,8 +202,6 @@ void EchoCancel::reset()
void
EchoCancel
::
putData
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
void
EchoCancel
::
putData
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
{
{
// std::cout << "putData nbBytes: " << nbBytes << std::endl;
if
(
_spkrStoped
)
{
if
(
_spkrStoped
)
{
_debug
(
"EchoCancel: Flush data"
);
_debug
(
"EchoCancel: Flush data"
);
...
@@ -209,16 +212,10 @@ void EchoCancel::putData(SFLDataFormat *inputData, int nbBytes)
...
@@ -209,16 +212,10 @@ void EchoCancel::putData(SFLDataFormat *inputData, int nbBytes)
// Put data in speaker ring buffer
// Put data in speaker ring buffer
_spkrData
->
Put
(
inputData
,
nbBytes
);
_spkrData
->
Put
(
inputData
,
nbBytes
);
_spkrDataOut
->
Put
(
inputData
,
nbBytes
);
// _debug("********************** signal event *****************");
// _event.signal();
}
}
int
EchoCancel
::
getData
(
SFLDataFormat
*
outputData
)
int
EchoCancel
::
getData
(
SFLDataFormat
*
outputData
)
{
{
// int availForGet = _spkrData->AvailForGet();
int
copied
=
0
;
int
copied
=
0
;
...
@@ -239,12 +236,6 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
...
@@ -239,12 +236,6 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
return
0
;
return
0
;
}
}
// _debug("****************************** wait signal ********************************");
// _event.wait();
// _debug("****************************** process ************************ ********");
int
byteSize
=
_smplPerFrame
*
sizeof
(
SFLDataFormat
);
int
byteSize
=
_smplPerFrame
*
sizeof
(
SFLDataFormat
);
// init temporary buffers
// init temporary buffers
...
@@ -267,14 +258,13 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
...
@@ -267,14 +258,13 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
// Get data from mic and speaker internal buffer
// Get data from mic and speaker internal buffer
while
((
spkrAvail
>=
byteSize
)
&&
(
micAvail
>=
byteSize
))
{
while
((
spkrAvail
>=
byteSize
)
&&
(
micAvail
>=
byteSize
))
{
// if ((spkrAvail >= byteSize) && (micAvail >= byteSize)) {
// get synchronized data
// get synchronized data
_spkrData
->
Get
(
_tmpSpkr
,
byteSize
);
_spkrData
->
Get
(
_tmpSpkr
,
byteSize
);
_micData
->
Get
(
_tmpMic
,
byteSize
);
_micData
->
Get
(
_tmpMic
,
byteSize
);
micFile
->
write
((
const
char
*
)
_tmpMic
,
byteSize
);
//
micFile->write((const char *)_tmpMic, byteSize);
spkrFile
->
write
((
const
char
*
)
_tmpSpkr
,
byteSize
);
//
spkrFile->write((const char *)_tmpSpkr, byteSize);
// Remove noise
// Remove noise
speex_preprocess_run
(
_noiseState
,
_tmpMic
);
speex_preprocess_run
(
_noiseState
,
_tmpMic
);
...
@@ -282,15 +272,13 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
...
@@ -282,15 +272,13 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
// Processed echo cancellation
// Processed echo cancellation
performEchoCancel
(
_tmpMic
,
_tmpSpkr
,
_tmpOut
);
performEchoCancel
(
_tmpMic
,
_tmpSpkr
,
_tmpOut
);
echoFile
->
write
((
const
char
*
)
_tmpOut
,
byteSize
);
//
echoFile->write((const char *)_tmpOut, byteSize);
bcopy
(
_tmpOut
,
outputData
+
(
nbFrame
*
_smplPerFrame
),
byteSize
);
bcopy
(
_tmpOut
,
outputData
+
(
nbFrame
*
_smplPerFrame
),
byteSize
);
// used to sync with speaker
// used to sync with speaker
_processedByte
+=
byteSize
;
_processedByte
+=
byteSize
;
// echoFile->write ((const char *)_tmpOut, byteSize);
spkrAvail
=
_spkrData
->
AvailForGet
();
spkrAvail
=
_spkrData
->
AvailForGet
();
micAvail
=
_micData
->
AvailForGet
();
micAvail
=
_micData
->
AvailForGet
();
...
@@ -319,8 +307,8 @@ void EchoCancel::setSamplingRate(int smplRate) {
...
@@ -319,8 +307,8 @@ void EchoCancel::setSamplingRate(int smplRate) {
void
EchoCancel
::
performEchoCancel
(
SFLDataFormat
*
micData
,
SFLDataFormat
*
spkrData
,
SFLDataFormat
*
outputData
)
{
void
EchoCancel
::
performEchoCancel
(
SFLDataFormat
*
micData
,
SFLDataFormat
*
spkrData
,
SFLDataFormat
*
outputData
)
{
int
tempmiclevel
[
_nbSegmentPerFrame
];
//
int tempmiclevel[_nbSegmentPerFrame];
int
tempspkrlevel
[
_nbSegmentPerFrame
];
//
int tempspkrlevel[_nbSegmentPerFrame];
for
(
int
k
=
0
;
k
<
_nbSegmentPerFrame
;
k
++
)
{
for
(
int
k
=
0
;
k
<
_nbSegmentPerFrame
;
k
++
)
{
...
@@ -332,8 +320,8 @@ void EchoCancel::performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDa
...
@@ -332,8 +320,8 @@ void EchoCancel::performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDa
// _debug("_spkrLevel: (max): %d", _spkrLevel);
// _debug("_spkrLevel: (max): %d", _spkrLevel);
// _debug("_micLevel: (min): %d", _micLevel);
// _debug("_micLevel: (min): %d", _micLevel);
tempspkrlevel
[
k
]
=
_spkrLevel
;
//
tempspkrlevel[k] = _spkrLevel;
tempmiclevel
[
k
]
=
_micLevel
;
//
tempmiclevel[k] = _micLevel;
if
(
_spkrLevel
>=
MIN_SIG_LEVEL
)
{
if
(
_spkrLevel
>=
MIN_SIG_LEVEL
)
{
if
(
_micLevel
>
_spkrLevel
)
{
if
(
_micLevel
>
_spkrLevel
)
{
...
@@ -358,8 +346,8 @@ void EchoCancel::performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDa
...
@@ -358,8 +346,8 @@ void EchoCancel::performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDa
}
}
micLevelData
->
write
((
const
char
*
)
tempmiclevel
,
sizeof
(
int
)
*
_nbSegmentPerFrame
);
//
micLevelData->write((const char *)tempmiclevel, sizeof(int)*_nbSegmentPerFrame);
spkrLevelData
->
write
((
const
char
*
)
tempspkrlevel
,
sizeof
(
int
)
*
_nbSegmentPerFrame
);
//
spkrLevelData->write((const char *)tempspkrlevel, sizeof(int)*_nbSegmentPerFrame);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment