X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Faudio_processor_delay_test.cc;h=90c8c18979ee8d62604f21cc271d81b3241df76d;hb=HEAD;hp=b3948a71be64a9a38c7b22952993d44b377535bc;hpb=0dfd150ac546eb42067cb51b6d4386fadc24afab;p=dcpomatic.git diff --git a/test/audio_processor_delay_test.cc b/test/audio_processor_delay_test.cc index b3948a71b..90c8c1897 100644 --- a/test/audio_processor_delay_test.cc +++ b/test/audio_processor_delay_test.cc @@ -1,30 +1,41 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -#include "lib/audio_delay.h" + +/** @file test/audio_processor_delay_test.cc + * @brief Test the AudioDelay class. + * @ingroup selfcontained + */ + + #include "lib/audio_buffers.h" +#include "lib/audio_delay.h" #include #include +#include + using std::cerr; using std::cout; -using boost::shared_ptr; +using std::make_shared; + #define CHECK_SAMPLE(c,f,r) \ if (fabs(out->data(c)[f] - (r)) > 0.1) { \ @@ -32,6 +43,7 @@ using boost::shared_ptr; BOOST_REQUIRE (fabs(out->data(c)[f] - (r)) <= 0.1); \ } + /** Block size greater than delay */ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1) { @@ -39,14 +51,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1) int const C = 2; - shared_ptr in (new AudioBuffers (C, 256)); + auto in = make_shared(C, 256); for (int i = 0; i < C; ++i) { for (int j = 0; j < 256; ++j) { in->data(i)[j] = j; } } - shared_ptr out = delay.run (in); + auto out = delay.run (in); BOOST_REQUIRE_EQUAL (out->frames(), in->frames()); /* Silence at the start */ @@ -79,6 +91,7 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1) } } + /** Block size less than delay */ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2) { @@ -89,15 +102,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) { - cout << "i=" << i << "\n"; - shared_ptr in (new AudioBuffers (C, 64)); + auto in = make_shared(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 out = delay.run (in); + auto out = delay.run (in); BOOST_REQUIRE_EQUAL (out->frames(), in->frames()); /* Check for silence */ @@ -111,9 +123,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 in (new AudioBuffers (C, 64)); + auto in = make_shared(C, 64); in->make_silent (); - shared_ptr out = delay.run (in); + auto out = delay.run (in); /* Should now see the delayed data */ for (int j = 0; j < C; ++j) {