summaryrefslogtreecommitdiff
path: root/libs/audiographer/tests/general/silence_trimmer_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/audiographer/tests/general/silence_trimmer_test.cc')
-rw-r--r--libs/audiographer/tests/general/silence_trimmer_test.cc104
1 files changed, 52 insertions, 52 deletions
diff --git a/libs/audiographer/tests/general/silence_trimmer_test.cc b/libs/audiographer/tests/general/silence_trimmer_test.cc
index be53c89978..c6662c92de 100644
--- a/libs/audiographer/tests/general/silence_trimmer_test.cc
+++ b/libs/audiographer/tests/general/silence_trimmer_test.cc
@@ -17,19 +17,19 @@ class SilenceTrimmerTest : public CppUnit::TestFixture
public:
void setUp()
{
- frames = 128;
+ samples = 128;
- random_data = TestUtils::init_random_data(frames);
+ random_data = TestUtils::init_random_data(samples);
random_data[0] = 0.5;
- random_data[frames - 1] = 0.5;
+ random_data[samples - 1] = 0.5;
- zero_data = new float[frames];
- memset(zero_data, 0, frames * sizeof(float));
+ zero_data = new float[samples];
+ memset(zero_data, 0, samples * sizeof(float));
- half_random_data = TestUtils::init_random_data(frames);
- memset(half_random_data, 0, (frames / 2) * sizeof(float));
+ half_random_data = TestUtils::init_random_data(samples);
+ memset(half_random_data, 0, (samples / 2) * sizeof(float));
- trimmer.reset (new SilenceTrimmer<float> (frames / 2));
+ trimmer.reset (new SilenceTrimmer<float> (samples / 2));
sink.reset (new AppendingVectorSink<float>());
trimmer->set_trim_beginning (true);
@@ -48,73 +48,73 @@ class SilenceTrimmerTest : public CppUnit::TestFixture
trimmer->add_output (sink);
{
- ProcessContext<float> c (zero_data, frames, 1);
+ ProcessContext<float> c (zero_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL ((framecnt_t) 0, frames_processed);
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL ((samplecnt_t) 0, samples_processed);
}
{
- ProcessContext<float> c (random_data, frames, 1);
+ ProcessContext<float> c (random_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (frames, frames_processed);
- CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, frames));
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (samples, samples_processed);
+ CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, samples));
}
{
- ProcessContext<float> c (zero_data, frames, 1);
+ ProcessContext<float> c (zero_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (frames, frames_processed);
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (samples, samples_processed);
}
{
- ProcessContext<float> c (random_data, frames, 1);
+ ProcessContext<float> c (random_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (3 * frames, frames_processed);
- CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, frames));
- CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[frames], zero_data, frames));
- CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[2 * frames], random_data, frames));
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (3 * samples, samples_processed);
+ CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, samples));
+ CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[samples], zero_data, samples));
+ CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[2 * samples], random_data, samples));
}
{
- ProcessContext<float> c (zero_data, frames, 1);
+ ProcessContext<float> c (zero_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (3 * frames, frames_processed);
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (3 * samples, samples_processed);
}
}
void testPartialBuffers()
{
trimmer->add_output (sink);
- trimmer->reset (frames / 4);
+ trimmer->reset (samples / 4);
trimmer->set_trim_beginning (true);
trimmer->set_trim_end (true);
{
- ProcessContext<float> c (half_random_data, frames, 1);
+ ProcessContext<float> c (half_random_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (frames / 2, frames_processed);
- CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), &half_random_data[frames / 2], frames / 2));
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (samples / 2, samples_processed);
+ CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), &half_random_data[samples / 2], samples / 2));
}
{
- ProcessContext<float> c (zero_data, frames, 1);
+ ProcessContext<float> c (zero_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (frames / 2, frames_processed);
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (samples / 2, samples_processed);
}
{
- ProcessContext<float> c (half_random_data, frames, 1);
+ ProcessContext<float> c (half_random_data, samples, 1);
trimmer->process (c);
- framecnt_t frames_processed = sink->get_data().size();
- CPPUNIT_ASSERT_EQUAL (2 * frames + frames / 2, frames_processed);
- CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[frames + frames / 2], half_random_data, frames));
+ samplecnt_t samples_processed = sink->get_data().size();
+ CPPUNIT_ASSERT_EQUAL (2 * samples + samples / 2, samples_processed);
+ CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[samples + samples / 2], half_random_data, samples));
}
}
@@ -129,42 +129,42 @@ class SilenceTrimmerTest : public CppUnit::TestFixture
{
trimmer->add_output (sink);
- framecnt_t silence = frames / 2;
+ samplecnt_t silence = samples / 2;
trimmer->add_silence_to_beginning (silence);
{
- ProcessContext<float> c (random_data, frames, 1);
+ ProcessContext<float> c (random_data, samples, 1);
trimmer->process (c);
}
CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), zero_data, silence));
- CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[silence], random_data, frames));
+ CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[silence], random_data, samples));
}
void testAddSilenceEnd()
{
trimmer->add_output (sink);
- framecnt_t silence = frames / 3;
+ samplecnt_t silence = samples / 3;
trimmer->add_silence_to_end (silence);
{
- ProcessContext<float> c (random_data, frames, 1);
+ ProcessContext<float> c (random_data, samples, 1);
trimmer->process (c);
}
{
- ProcessContext<float> c (random_data, frames, 1);
+ ProcessContext<float> c (random_data, samples, 1);
c.set_flag (ProcessContext<float>::EndOfInput);
trimmer->process (c);
}
- framecnt_t frames_processed = sink->get_data().size();
- framecnt_t total_frames = 2 * frames + silence;
- CPPUNIT_ASSERT_EQUAL (total_frames, frames_processed);
- CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, frames));
- CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[frames], random_data, frames));
- CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[frames * 2], zero_data, silence));
+ samplecnt_t samples_processed = sink->get_data().size();
+ samplecnt_t total_samples = 2 * samples + silence;
+ CPPUNIT_ASSERT_EQUAL (total_samples, samples_processed);
+ CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, samples));
+ CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[samples], random_data, samples));
+ CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[samples * 2], zero_data, silence));
}
private:
@@ -174,7 +174,7 @@ class SilenceTrimmerTest : public CppUnit::TestFixture
float * random_data;
float * zero_data;
float * half_random_data;
- framecnt_t frames;
+ samplecnt_t samples;
};
CPPUNIT_TEST_SUITE_REGISTRATION (SilenceTrimmerTest);