Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
d7a2b23d
Commit
d7a2b23d
authored
Jun 14, 2010
by
Alexandre Savard
Browse files
[#3507] Implement FIR general filter with variable number of coefficient
parent
404ce691
Changes
4
Show whitespace changes
Inline
Side-by-side
sflphone-common/src/audio/dcblocker.cpp
View file @
d7a2b23d
...
...
@@ -30,31 +30,6 @@
#include
"dcblocker.h"
FirFilter
::
FirFilter
(
std
::
vector
<
double
>
ir
)
:
_impulseResponse
(
ir
),
_length
(
ir
.
size
()),
_count
(
0
)
{}
FirFilter
::~
FirFilter
()
{}
int
FirFilter
::
getOutputSample
(
int
inputSample
)
{
_delayLine
[
_count
]
=
(
double
)
inputSample
;
double
result
=
0.0
;
int
index
=
_count
;
for
(
int
i
=
0
;
i
<
_length
;
i
++
)
{
result
=
result
+
_impulseResponse
[
i
]
*
_delayLine
[
index
--
];
if
(
index
<
0
)
index
=
_length
-
1
;
}
_count
++
;
if
(
_count
>=
_length
)
_count
=
0
;
return
(
int
)
result
;
}
DcBlocker
::
DcBlocker
()
:
_y
(
0
),
_x
(
0
),
_xm1
(
0
),
_ym1
(
0
)
{}
DcBlocker
::~
DcBlocker
()
{}
...
...
sflphone-common/src/audio/dcblocker.h
View file @
d7a2b23d
...
...
@@ -36,52 +36,6 @@
#include
<vector>
#define MAXFILTERSIZE 100
class
FirFilter
{
public:
/**
* Constructor for this class
*/
FirFilter
(
std
::
vector
<
double
>
ir
);
/**
* SDestructor for this class
*/
~
FirFilter
();
private:
/**
* Length of the filter
*/
int
_length
;
/**
* Coefficient of the filter
*/
std
::
vector
<
double
>
_impulseResponse
;
/**
* Circular buffer
*/
double
_delayLine
[
MAXFILTERSIZE
];
/**
* Counter
*/
int
_count
;
/**
* Perform filtering on one sample
*/
int
getOutputSample
(
int
inputSample
);
};
class
DcBlocker
:
public
Algorithm
{
public:
...
...
sflphone-common/src/audio/delaydetection.cpp
View file @
d7a2b23d
...
...
@@ -33,6 +33,31 @@
#include
"delaydetection.h"
#include
"math.h"
FirFilter
::
FirFilter
(
std
::
vector
<
double
>
ir
)
:
_impulseResponse
(
ir
),
_length
(
ir
.
size
()),
_count
(
0
)
{}
FirFilter
::~
FirFilter
()
{}
int
FirFilter
::
getOutputSample
(
int
inputSample
)
{
_delayLine
[
_count
]
=
(
double
)
inputSample
;
double
result
=
0.0
;
int
index
=
_count
;
for
(
int
i
=
0
;
i
<
_length
;
i
++
)
{
result
=
result
+
_impulseResponse
[
i
]
*
_delayLine
[
index
--
];
if
(
index
<
0
)
index
=
_length
-
1
;
}
_count
++
;
if
(
_count
>=
_length
)
_count
=
0
;
return
(
int
)
result
;
}
DelayDetection
::
DelayDetection
(){}
DelayDetection
::~
DelayDetection
(){}
...
...
@@ -43,7 +68,9 @@ void DelayDetection::putData(SFLDataFormat *inputData, int nbBytes) {}
int
DelayDetection
::
getData
(
SFLDataFormat
*
outputData
)
{
return
0
;
}
void
DelayDetection
::
process
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
{}
void
DelayDetection
::
process
(
SFLDataFormat
*
inputData
,
int
nbBytes
)
{
}
int
DelayDetection
::
process
(
SFLDataFormat
*
intputData
,
SFLDataFormat
*
outputData
,
int
nbBytes
)
{
return
0
;
}
...
...
sflphone-common/src/audio/delaydetection.h
View file @
d7a2b23d
...
...
@@ -40,6 +40,53 @@
// Segment length in ms for correlation
#define MAX_DELAY 150
#define MAXFILTERSIZE 100
class
FirFilter
{
public:
/**
* Constructor for this class
*/
FirFilter
(
std
::
vector
<
double
>
ir
);
/**
* SDestructor for this class
*/
~
FirFilter
();
private:
/**
* Length of the filter
*/
int
_length
;
/**
* Coefficient of the filter
*/
std
::
vector
<
double
>
_impulseResponse
;
/**
* Circular buffer
*/
double
_delayLine
[
MAXFILTERSIZE
];
/**
* Counter
*/
int
_count
;
/**
* Perform filtering on one sample
*/
int
getOutputSample
(
int
inputSample
);
};
class
DelayDetection
:
public
Algorithm
{
public:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment