2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/test/unit_test.hpp>
21 #include "lib/audio_buffers.h"
22 #include "lib/resampler.h"
26 using boost::shared_ptr;
29 resampler_test_one (int from, int to)
31 Resampler resamp (from, to, 1);
36 int64_t const N = int64_t (from) * 60 * 60 * 3;
38 for (int64_t i = 0; i < N; i += 1000) {
39 shared_ptr<AudioBuffers> a (new AudioBuffers (1, 1000));
41 pair<shared_ptr<const AudioBuffers>, AudioContent::Frame> r = resamp.run (a, i);
42 BOOST_CHECK_EQUAL (r.second, total_out);
43 total_out += r.first->frames ();
47 /** Check that the timings that come back from the resampler correspond
48 to the number of samples it generates.
50 BOOST_AUTO_TEST_CASE (resampler_test)
52 resampler_test_one (44100, 48000);
53 resampler_test_one (44100, 46080);
54 resampler_test_one (44100, 50000);