fix plugin silence runs (e.g. during audition)
[ardour.git] / libs / ardour / test / interpolation_test.h
1 /* Copyright(C) 2000-2008 Paul Davis
2  * Author: Hans Baier
3  *
4  * Evoral is free software; you can redistribute it and/or modify it under the
5  * terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or(at your option) any later
7  * version.
8  *
9  * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17
18 #include <cassert>
19 #include <stdint.h>
20 #include <cppunit/TestFixture.h>
21 #include <cppunit/extensions/HelperMacros.h>
22
23 #include "ardour/interpolation.h"
24
25 class InterpolationTest : public CppUnit::TestFixture
26 {
27         CPPUNIT_TEST_SUITE(InterpolationTest);
28         CPPUNIT_TEST(cubicInterpolationTest);
29         CPPUNIT_TEST(linearInterpolationTest);
30         CPPUNIT_TEST_SUITE_END();
31
32 #define NUM_SAMPLES 1000000
33 #define INTERVAL 100
34
35         ARDOUR::Sample input[NUM_SAMPLES];
36         ARDOUR::Sample output[NUM_SAMPLES];
37
38         ARDOUR::LinearInterpolation linear;
39         ARDOUR::CubicInterpolation  cubic;
40
41         public:
42
43         void setUp() {
44                 for (int i = 0; i < NUM_SAMPLES; ++i) {
45                         if (i % INTERVAL == 0) {
46                                 input[i] = 1.0f;
47                         } else {
48                                 input[i] = 0.0f;
49                         }
50                         output[i] = 0.0f;
51                 }
52                 linear.add_channel_to (NUM_SAMPLES, NUM_SAMPLES);
53                 cubic.add_channel_to (NUM_SAMPLES, NUM_SAMPLES);
54         }
55
56         void tearDown() {
57         }
58
59         void linearInterpolationTest();
60         void cubicInterpolationTest();
61 };