Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
130
Issues
130
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-daemon
Commits
f04c0827
Commit
f04c0827
authored
May 17, 2012
by
Tristan Matthews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings in resampler test
parent
6c69c397
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
56 deletions
+38
-56
daemon/test/resamplertest.cpp
daemon/test/resamplertest.cpp
+35
-49
daemon/test/resamplertest.h
daemon/test/resamplertest.h
+3
-7
No files found.
daemon/test/resamplertest.cpp
View file @
f04c0827
...
...
@@ -29,11 +29,16 @@
*/
#include <iostream>
#include <iterator>
#include <algorithm>
#include <math.h>
#include "resamplertest.h"
ResamplerTest
::
ResamplerTest
()
:
CppUnit
::
TestCase
(
"Resampler module test"
),
inputBuffer
(),
outputBuffer
()
{}
void
ResamplerTest
::
setUp
()
{
...
...
@@ -44,6 +49,16 @@ void ResamplerTest::tearDown()
}
namespace
{
template
<
typename
T
>
void
print_buffer
(
T
&
buffer
)
{
std
::
copy
(
buffer
.
begin
(),
buffer
.
end
(),
std
::
ostream_iterator
<
SFLDataFormat
>
(
std
::
cout
,
", "
));
std
::
cout
<<
std
::
endl
;
}
}
void
ResamplerTest
::
testUpsamplingRamp
()
{
// generate input samples and store them in inputBuffer
...
...
@@ -59,15 +74,11 @@ void ResamplerTest::testUpsamplingRamp()
std
::
copy
(
inputBuffer
.
begin
(),
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
(),
tmpInputBuffer
.
begin
());
std
::
cout
<<
"Input Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpInputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpInputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpInputBuffer
);
std
::
copy
(
outputBuffer
.
begin
(),
outputBuffer
.
begin
()
+
tmpOutputBuffer
.
size
(),
tmpOutputBuffer
.
begin
());
std
::
cout
<<
"Output Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpOutputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpOutputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpOutputBuffer
);
}
void
ResamplerTest
::
testDownsamplingRamp
()
...
...
@@ -84,15 +95,11 @@ void ResamplerTest::testDownsamplingRamp()
std
::
copy
(
inputBuffer
.
begin
(),
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
(),
tmpInputBuffer
.
begin
());
std
::
cout
<<
"Input Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpInputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpInputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpInputBuffer
);
std
::
copy
(
outputBuffer
.
begin
(),
outputBuffer
.
begin
()
+
tmpOutputBuffer
.
size
(),
tmpOutputBuffer
.
begin
());
std
::
cout
<<
"Output Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpOutputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpOutputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpOutputBuffer
);
}
void
ResamplerTest
::
testUpsamplingTriangle
()
...
...
@@ -109,15 +116,11 @@ void ResamplerTest::testUpsamplingTriangle()
std
::
copy
(
inputBuffer
.
begin
(),
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
(),
tmpInputBuffer
.
begin
());
std
::
cout
<<
"Input Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpInputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpInputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpInputBuffer
);
std
::
copy
(
outputBuffer
.
begin
(),
outputBuffer
.
begin
()
+
tmpOutputBuffer
.
size
(),
tmpOutputBuffer
.
begin
());
std
::
cout
<<
"Output Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpOutputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpOutputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpOutputBuffer
);
}
void
ResamplerTest
::
testDownsamplingTriangle
()
...
...
@@ -134,15 +137,11 @@ void ResamplerTest::testDownsamplingTriangle()
std
::
copy
(
inputBuffer
.
begin
(),
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
(),
tmpInputBuffer
.
begin
());
std
::
cout
<<
"Input Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpInputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpInputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpInputBuffer
);
std
::
copy
(
outputBuffer
.
begin
(),
outputBuffer
.
begin
()
+
tmpOutputBuffer
.
size
(),
tmpOutputBuffer
.
begin
());
std
::
cout
<<
"Output Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpOutputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpOutputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpOutputBuffer
);
}
void
ResamplerTest
::
testUpsamplingSine
()
{
...
...
@@ -159,15 +158,11 @@ void ResamplerTest::testUpsamplingSine()
std
::
copy
(
inputBuffer
.
begin
(),
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
(),
tmpInputBuffer
.
begin
());
std
::
cout
<<
"Input Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpInputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpInputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpInputBuffer
);
std
::
copy
(
outputBuffer
.
begin
(),
outputBuffer
.
begin
()
+
tmpOutputBuffer
.
size
(),
tmpOutputBuffer
.
begin
());
std
::
cout
<<
"Output Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpOutputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpOutputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpOutputBuffer
);
}
void
ResamplerTest
::
testDownsamplingSine
()
...
...
@@ -185,36 +180,29 @@ void ResamplerTest::testDownsamplingSine()
std
::
copy
(
inputBuffer
.
begin
(),
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
(),
tmpInputBuffer
.
begin
());
std
::
cout
<<
"Input Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpInputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpInputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpInputBuffer
);
std
::
copy
(
outputBuffer
.
begin
(),
outputBuffer
.
begin
()
+
tmpOutputBuffer
.
size
(),
tmpOutputBuffer
.
begin
());
std
::
cout
<<
"Output Buffer"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
tmpOutputBuffer
.
size
();
i
++
)
std
::
cout
<<
tmpOutputBuffer
[
i
]
<<
", "
;
std
::
cout
<<
std
::
endl
;
print_buffer
(
tmpOutputBuffer
);
}
void
ResamplerTest
::
generateRamp
()
{
for
(
int
i
=
0
;
i
<
inputBuffer
.
size
();
i
++
)
{
inputBuffer
[
i
]
=
(
SFLDataFormat
)
i
;
}
for
(
size_t
i
=
0
;
i
<
inputBuffer
.
size
();
++
i
)
inputBuffer
[
i
]
=
i
;
}
void
ResamplerTest
::
generateTriangularSignal
()
{
for
(
int
i
=
0
;
i
<
inputBuffer
.
size
();
i
++
)
{
inputBuffer
[
i
]
=
(
SFLDataFormat
)(
i
*
10
);
}
for
(
size_t
i
=
0
;
i
<
inputBuffer
.
size
();
++
i
)
inputBuffer
[
i
]
=
i
*
10
;
}
void
ResamplerTest
::
generateSineSignal
()
{
for
(
int
i
=
0
;
i
<
inputBuffer
.
size
();
i
++
)
{
inputBuffer
[
i
]
=
(
SFLDataFormat
)(
1000.0
*
sin
((
double
)
i
));
}
for
(
size_t
i
=
0
;
i
<
inputBuffer
.
size
();
++
i
)
inputBuffer
[
i
]
=
(
SFLDataFormat
)
(
1000.0
*
sin
(
i
));
}
void
ResamplerTest
::
performUpsampling
(
SamplerateConverter
&
converter
)
...
...
@@ -222,8 +210,7 @@ void ResamplerTest::performUpsampling(SamplerateConverter &converter)
LowSmplrBuffer
tmpInputBuffer
;
HighSmplrBuffer
tmpOutputBuffer
;
int
i
,
j
;
for
(
i
=
0
,
j
=
0
;
i
<
(
inputBuffer
.
size
()
/
2
);
i
+=
tmpInputBuffer
.
size
(),
j
+=
tmpOutputBuffer
.
size
())
{
for
(
size_t
i
=
0
,
j
=
0
;
i
<
(
inputBuffer
.
size
()
/
2
);
i
+=
tmpInputBuffer
.
size
(),
j
+=
tmpOutputBuffer
.
size
())
{
std
::
copy
(
inputBuffer
.
begin
()
+
i
,
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
()
+
i
,
tmpInputBuffer
.
begin
());
converter
.
resample
(
tmpInputBuffer
.
data
(),
tmpOutputBuffer
.
data
(),
tmpOutputBuffer
.
size
(),
8000
,
16000
,
tmpInputBuffer
.
size
());
std
::
copy
(
tmpOutputBuffer
.
begin
(),
tmpOutputBuffer
.
end
(),
outputBuffer
.
begin
()
+
j
);
...
...
@@ -235,8 +222,7 @@ void ResamplerTest::performDownsampling(SamplerateConverter &converter)
HighSmplrBuffer
tmpInputBuffer
;
LowSmplrBuffer
tmpOutputBuffer
;
int
i
,
j
;
for
(
i
=
0
,
j
=
0
;
i
<
inputBuffer
.
size
();
i
+=
tmpInputBuffer
.
size
(),
j
+=
tmpOutputBuffer
.
size
())
{
for
(
size_t
i
=
0
,
j
=
0
;
i
<
inputBuffer
.
size
();
i
+=
tmpInputBuffer
.
size
(),
j
+=
tmpOutputBuffer
.
size
())
{
std
::
copy
(
inputBuffer
.
begin
()
+
i
,
inputBuffer
.
begin
()
+
tmpInputBuffer
.
size
()
+
i
,
tmpInputBuffer
.
begin
());
converter
.
resample
(
tmpInputBuffer
.
data
(),
tmpOutputBuffer
.
data
(),
tmpOutputBuffer
.
size
(),
16000
,
8000
,
tmpInputBuffer
.
size
());
std
::
copy
(
tmpOutputBuffer
.
begin
(),
tmpOutputBuffer
.
end
(),
outputBuffer
.
begin
()
+
j
);
...
...
daemon/test/resamplertest.h
View file @
f04c0827
...
...
@@ -39,6 +39,7 @@
#include <tr1/array>
#include "audio/samplerateconverter.h"
#include "noncopyable.h"
#define MAX_BUFFER_LENGTH 40000
#define TMP_LOWSMPLR_BUFFER_LENGTH 160
...
...
@@ -62,7 +63,7 @@ class ResamplerTest : public CppUnit::TestCase {
CPPUNIT_TEST_SUITE_END
();
public:
ResamplerTest
()
:
CppUnit
::
TestCase
(
"Resampler module test"
)
{}
ResamplerTest
()
;
/*
* Code factoring - Common resources can be initialized here.
...
...
@@ -107,6 +108,7 @@ class ResamplerTest : public CppUnit::TestCase {
void
testDownsamplingSine
();
private:
NON_COPYABLE
(
ResamplerTest
);
/*
* Generate a ramp to be stored in inputBuffer
...
...
@@ -142,12 +144,6 @@ private:
* Used to receive output samples
*/
std
::
tr1
::
array
<
SFLDataFormat
,
MAX_BUFFER_LENGTH
>
outputBuffer
;
/**
* Pointer to samplerate converter, may be reinitialized during tests
* don't keep a statically declared instance.
*/
SamplerateConverter
*
converter
;
};
/* Register the test module */
...
...
Write
Preview
Markdown
is supported
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