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
0939e3cc
Commit
0939e3cc
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#3507] Add downsampling and band pass filters
parent
76f88d17
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/src/audio/delaydetection.cpp
+36
-9
36 additions, 9 deletions
sflphone-common/src/audio/delaydetection.cpp
sflphone-common/src/audio/delaydetection.h
+7
-1
7 additions, 1 deletion
sflphone-common/src/audio/delaydetection.h
with
43 additions
and
10 deletions
sflphone-common/src/audio/delaydetection.cpp
+
36
−
9
View file @
0939e3cc
...
@@ -33,6 +33,17 @@
...
@@ -33,6 +33,17 @@
#include
"delaydetection.h"
#include
"delaydetection.h"
#include
"math.h"
#include
"math.h"
// decimation filter coefficient
float
decimationCoefs
[]
=
{
0.1
,
0.1
,
0.1
,
0.1
,
0.1
};
std
::
vector
<
double
>
ird
(
decimationCoefs
,
decimationCoefs
+
sizeof
(
decimationCoefs
)
/
sizeof
(
float
));
// decimation filter coefficient
float
bandpassCoefs
[]
=
{
0.1
,
0.1
,
0.1
,
0.1
,
0.1
};
std
::
vector
<
double
>
irb
(
bandpassCoefs
,
bandpassCoefs
+
sizeof
(
bandpassCoefs
)
/
sizeof
(
float
));
FirFilter
::
FirFilter
(
std
::
vector
<
double
>
ir
)
:
_impulseResponse
(
ir
),
FirFilter
::
FirFilter
(
std
::
vector
<
double
>
ir
)
:
_impulseResponse
(
ir
),
_length
(
ir
.
size
()),
_length
(
ir
.
size
()),
_count
(
0
)
_count
(
0
)
...
@@ -58,7 +69,7 @@ float FirFilter::getOutputSample(float inputSample)
...
@@ -58,7 +69,7 @@ float FirFilter::getOutputSample(float inputSample)
}
}
DelayDetection
::
DelayDetection
(
std
::
vector
<
double
>
ir
)
:
_decimationFilter
(
ir
)
{}
DelayDetection
::
DelayDetection
()
:
_decimationFilter
(
ir
d
),
_bandpassFilter
(
irb
)
{}
DelayDetection
::~
DelayDetection
(){}
DelayDetection
::~
DelayDetection
(){}
...
@@ -69,18 +80,25 @@ void DelayDetection::putData(SFLDataFormat *inputData, int nbBytes)
...
@@ -69,18 +80,25 @@ void DelayDetection::putData(SFLDataFormat *inputData, int nbBytes)
int
nbSamples
=
nbBytes
/
sizeof
(
SFLDataFormat
);
int
nbSamples
=
nbBytes
/
sizeof
(
SFLDataFormat
);
float
tmp
[
nbSamples
];
float
tmp
[
nbSamples
];
float
down
[
nbSamples
];
float
down
[
nbSamples
];
convertInt16ToFloat32
(
inputData
,
tmp
,
nbSamples
);
convertInt16ToFloat32
(
inputData
,
tmp
,
nbSamples
);
downsampleData
(
tmp
,
down
,
nbSamples
,
8
);
downsampleData
(
tmp
,
down
,
nbSamples
,
8
);
bandpassFilter
(
down
,
nbSamples
/
8
);
}
}
int
DelayDetection
::
getData
(
SFLDataFormat
*
outputData
)
{
return
0
;
}
int
DelayDetection
::
getData
(
SFLDataFormat
*
outputData
)
{
return
0
;
}
void
DelayDetection
::
process
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
{
void
DelayDetection
::
process
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
{
int
nbSamples
=
nbBytes
/
sizeof
(
SFLDataFormat
);
float
tmp
[
nbSamples
];
float
down
[
nbSamples
];
convertInt16ToFloat32
(
inputData
,
tmp
,
nbSamples
);
downsampleData
(
tmp
,
down
,
nbSamples
,
8
);
bandpassFilter
(
down
,
nbSamples
/
8
);
}
}
int
DelayDetection
::
process
(
SFLDataFormat
*
intputData
,
SFLDataFormat
*
outputData
,
int
nbBytes
)
{
return
0
;
}
int
DelayDetection
::
process
(
SFLDataFormat
*
intputData
,
SFLDataFormat
*
outputData
,
int
nbBytes
)
{
return
0
;
}
...
@@ -158,17 +176,26 @@ void DelayDetection::convertInt16ToFloat32(SFLDataFormat *input, float *output,
...
@@ -158,17 +176,26 @@ void DelayDetection::convertInt16ToFloat32(SFLDataFormat *input, float *output,
}
}
void
DelayDetection
::
downsampleData
(
float
*
input
,
float
*
output
,
int
nbSamples
,
int
factor
)
{
void
DelayDetection
::
downsampleData
(
float
*
input
,
float
*
output
,
int
nbSamples
,
int
factor
)
{
float
tmp
[
nbSamples
];
float
tmp
[
nbSamples
];
for
(
int
i
=
0
;
i
<
nbSamples
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nbSamples
;
i
++
)
{
tmp
[
i
]
=
_decimationFilter
.
getOutputSample
(
input
[
i
]);
tmp
[
i
]
=
_decimationFilter
.
getOutputSample
(
input
[
i
]);
}
}
for
(
int
i
=
0
;
i
<
nbSamples
;
i
+=
factor
)
{
int
j
;
output
[
i
]
=
tmp
[
i
];
for
(
j
=
_remainingIndex
;
j
<
nbSamples
;
j
+=
factor
)
{
output
[
j
]
=
tmp
[
j
];
}
_remainingIndex
=
j
-
nbSamples
;
}
void
DelayDetection
::
bandpassFilter
(
float
*
input
,
int
nbSamples
)
{
for
(
int
i
=
0
;
i
<
nbSamples
;
i
++
)
{
input
[
i
]
=
_bandpassFilter
.
getOutputSample
(
input
[
i
]);
}
}
}
}
This diff is collapsed.
Click to expand it.
sflphone-common/src/audio/delaydetection.h
+
7
−
1
View file @
0939e3cc
...
@@ -94,7 +94,7 @@ class DelayDetection : public Algorithm {
...
@@ -94,7 +94,7 @@ class DelayDetection : public Algorithm {
public:
public:
DelayDetection
(
std
::
vector
<
double
>
ir
);
DelayDetection
();
~
DelayDetection
();
~
DelayDetection
();
...
@@ -126,6 +126,8 @@ class DelayDetection : public Algorithm {
...
@@ -126,6 +126,8 @@ class DelayDetection : public Algorithm {
void
downsampleData
(
float
*
input
,
float
*
output
,
int
nbSamples
,
int
factor
);
void
downsampleData
(
float
*
input
,
float
*
output
,
int
nbSamples
,
int
factor
);
void
bandpassFilter
(
float
*
input
,
int
nbSamples
);
/**
/**
* Segment size in samples for correlation
* Segment size in samples for correlation
*/
*/
...
@@ -153,6 +155,10 @@ class DelayDetection : public Algorithm {
...
@@ -153,6 +155,10 @@ class DelayDetection : public Algorithm {
FirFilter
_decimationFilter
;
FirFilter
_decimationFilter
;
FirFilter
_bandpassFilter
;
int
_remainingIndex
;
public:
public:
friend
class
DelayDetectionTest
;
friend
class
DelayDetectionTest
;
...
...
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