summaryrefslogtreecommitdiff
path: root/test/audio_processor_delay_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-29 09:14:20 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-29 20:53:49 +0200
commit39fb8198febde1937019db1c300ec363aab5aa56 (patch)
tree52bc32134e8ae2b5587b3a62130baa9acf815b60 /test/audio_processor_delay_test.cc
parentb249700e1da7dd6631a8b4440587f4093a2bdef1 (diff)
C++11 tidying.
Diffstat (limited to 'test/audio_processor_delay_test.cc')
-rw-r--r--test/audio_processor_delay_test.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/test/audio_processor_delay_test.cc b/test/audio_processor_delay_test.cc
index 6fd644a7e..47a1cc8ad 100644
--- a/test/audio_processor_delay_test.cc
+++ b/test/audio_processor_delay_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,27 +18,33 @@
*/
+
/** @file test/audio_processor_delay_test.cc
* @brief Test the AudioDelay class.
* @ingroup selfcontained
*/
-#include "lib/audio_delay.h"
+
#include "lib/audio_buffers.h"
+#include "lib/audio_delay.h"
#include <boost/test/unit_test.hpp>
#include <cmath>
#include <iostream>
+
using std::cerr;
using std::cout;
+using std::make_shared;
using std::shared_ptr;
+
#define CHECK_SAMPLE(c,f,r) \
if (fabs(out->data(c)[f] - (r)) > 0.1) { \
cerr << "Sample " << f << " at line " << __LINE__ << " is " << out->data(c)[f] << " not " << r << "; difference is " << fabs(out->data(c)[f] - (r)) << "\n"; \
BOOST_REQUIRE (fabs(out->data(c)[f] - (r)) <= 0.1); \
}
+
/** Block size greater than delay */
BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
{
@@ -46,14 +52,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
int const C = 2;
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 256));
+ auto in = make_shared<AudioBuffers>(C, 256);
for (int i = 0; i < C; ++i) {
for (int j = 0; j < 256; ++j) {
in->data(i)[j] = j;
}
}
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
BOOST_REQUIRE_EQUAL (out->frames(), in->frames());
/* Silence at the start */
@@ -86,6 +92,7 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
}
}
+
/** Block size less than delay */
BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
{
@@ -96,14 +103,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
/* Feeding 4 blocks of 64 should give silence each time */
for (int i = 0; i < 4; ++i) {
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 64));
+ auto in = make_shared<AudioBuffers>(C, 64);
for (int j = 0; j < C; ++j) {
for (int k = 0; k < 64; ++k) {
in->data(j)[k] = k + i * 64;
}
}
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
BOOST_REQUIRE_EQUAL (out->frames(), in->frames());
/* Check for silence */
@@ -117,9 +124,9 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
/* Now feed 4 blocks of silence and we should see the data */
for (int i = 0; i < 4; ++i) {
/* Feed some silence */
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 64));
+ auto in = make_shared<AudioBuffers>(C, 64);
in->make_silent ();
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
/* Should now see the delayed data */
for (int j = 0; j < C; ++j) {