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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
db945995
Commit
db945995
authored
14 years ago
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
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide 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),
{
_debug
(
"EchoCancel: Instantiate echo canceller"
);
/*
micFile = new ofstream("micData", ofstream::binary);
echoFile = new ofstream("echoData", ofstream::binary);
spkrFile = new ofstream("spkrData", ofstream::binary);
micLevelData = new ofstream("micLevelData", ofstream::binary);
spkrLevelData = new ofstream("spkrLevelData", ofstream::binary);
*/
_micData
=
new
RingBuffer
(
50000
);
_spkrData
=
new
RingBuffer
(
50000
);
...
...
@@ -121,6 +123,7 @@ EchoCancel::~EchoCancel()
speex_preprocess_state_destroy
(
_noiseState
);
/*
micFile->close();
spkrFile->close();
echoFile->close();
...
...
@@ -133,7 +136,7 @@ EchoCancel::~EchoCancel()
spkrLevelData->close();
delete micLevelData;
delete spkrLevelData;
*/
}
...
...
@@ -179,6 +182,8 @@ void EchoCancel::reset()
_noiseState
=
speex_preprocess_state_init
(
_smplPerFrame
,
_samplingRate
);
int
i
=
1
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_DENOISE
,
&
i
);
i
=-
30
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS
,
&
i
);
i
=
0
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_AGC
,
&
i
);
i
=
8000
;
...
...
@@ -197,8 +202,6 @@ void EchoCancel::reset()
void
EchoCancel
::
putData
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
{
// std::cout << "putData nbBytes: " << nbBytes << std::endl;
if
(
_spkrStoped
)
{
_debug
(
"EchoCancel: Flush data"
);
...
...
@@ -209,16 +212,10 @@ void EchoCancel::putData(SFLDataFormat *inputData, int nbBytes)
// Put data in speaker ring buffer
_spkrData
->
Put
(
inputData
,
nbBytes
);
_spkrDataOut
->
Put
(
inputData
,
nbBytes
);
// _debug("********************** signal event *****************");
// _event.signal();
}
int
EchoCancel
::
getData
(
SFLDataFormat
*
outputData
)
{
// int availForGet = _spkrData->AvailForGet();
int
copied
=
0
;
...
...
@@ -239,12 +236,6 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
return
0
;
}
// _debug("****************************** wait signal ********************************");
// _event.wait();
// _debug("****************************** process ************************ ********");
int
byteSize
=
_smplPerFrame
*
sizeof
(
SFLDataFormat
);
// init temporary buffers
...
...
@@ -267,30 +258,27 @@ int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int
// Get data from mic and speaker internal buffer
while
((
spkrAvail
>=
byteSize
)
&&
(
micAvail
>=
byteSize
))
{
// if ((spkrAvail >= byteSize) && (micAvail >= byteSize)) {
// get synchronized data
_spkrData
->
Get
(
_tmpSpkr
,
byteSize
);
_micData
->
Get
(
_tmpMic
,
byteSize
);
micFile
->
write
((
const
char
*
)
_tmpMic
,
byteSize
);
spkrFile
->
write
((
const
char
*
)
_tmpSpkr
,
byteSize
);
//
micFile->write((const char *)_tmpMic, byteSize);
//
spkrFile->write((const char *)_tmpSpkr, byteSize);
// Remove noise
speex_preprocess_run
(
_noiseState
,
_tmpMic
);
// Processed echo cancellation
performEchoCancel
(
_tmpMic
,
_tmpSpkr
,
_tmpOut
);
echoFile
->
write
((
const
char
*
)
_tmpOut
,
byteSize
);
//
echoFile->write((const char *)_tmpOut, byteSize);
bcopy
(
_tmpOut
,
outputData
+
(
nbFrame
*
_smplPerFrame
),
byteSize
);
// used to sync with speaker
_processedByte
+=
byteSize
;
// echoFile->write ((const char *)_tmpOut, byteSize);
spkrAvail
=
_spkrData
->
AvailForGet
();
micAvail
=
_micData
->
AvailForGet
();
...
...
@@ -319,8 +307,8 @@ void EchoCancel::setSamplingRate(int smplRate) {
void
EchoCancel
::
performEchoCancel
(
SFLDataFormat
*
micData
,
SFLDataFormat
*
spkrData
,
SFLDataFormat
*
outputData
)
{
int
tempmiclevel
[
_nbSegmentPerFrame
];
int
tempspkrlevel
[
_nbSegmentPerFrame
];
//
int tempmiclevel[_nbSegmentPerFrame];
//
int tempspkrlevel[_nbSegmentPerFrame];
for
(
int
k
=
0
;
k
<
_nbSegmentPerFrame
;
k
++
)
{
...
...
@@ -332,8 +320,8 @@ void EchoCancel::performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDa
// _debug("_spkrLevel: (max): %d", _spkrLevel);
// _debug("_micLevel: (min): %d", _micLevel);
tempspkrlevel
[
k
]
=
_spkrLevel
;
tempmiclevel
[
k
]
=
_micLevel
;
//
tempspkrlevel[k] = _spkrLevel;
//
tempmiclevel[k] = _micLevel;
if
(
_spkrLevel
>=
MIN_SIG_LEVEL
)
{
if
(
_micLevel
>
_spkrLevel
)
{
...
...
@@ -358,8 +346,8 @@ void EchoCancel::performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDa
}
micLevelData
->
write
((
const
char
*
)
tempmiclevel
,
sizeof
(
int
)
*
_nbSegmentPerFrame
);
spkrLevelData
->
write
((
const
char
*
)
tempspkrlevel
,
sizeof
(
int
)
*
_nbSegmentPerFrame
);
//
micLevelData->write((const char *)tempmiclevel, 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
register
or
sign in
to comment