LMMS
Loading...
Searching...
No Matches
EchoTest.h
Go to the documentation of this file.
1/*
2 ZynAddSubFX - a software synthesizer
3
4 EchoTest.h - CxxTest for Effect/Echo
5 Copyright (C) 2009-2011 Mark McCurry
6 Copyright (C) 2009 Harald Hvaal
7 Authors: Mark McCurry, Harald Hvaal
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of version 2 of the GNU General Public License
11 as published by the Free Software Foundation.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License (version 2 or later) for more details.
17
18 You should have received a copy of the GNU General Public License (version 2)
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22*/
23#include <cxxtest/TestSuite.h>
24#include <cmath>
25#include <cstdlib>
26#include <iostream>
27#include "../Effects/Echo.h"
28#include "../globals.h"
30
31using namespace std;
32
33class EchoTest:public CxxTest::TestSuite
34{
35 public:
36 void setUp() {
37 synth = new SYNTH_T;
38 outL = new float[synth->buffersize];
39 for(int i = 0; i < synth->buffersize; ++i)
40 outL[i] = 0.0f;
41 outR = new float[synth->buffersize];
42 for(int i = 0; i < synth->buffersize; ++i)
43 outR[i] = 0.0f;
44 input = new Stereo<float *>(new float[synth->buffersize],
45 new float[synth->buffersize]);
46 for(int i = 0; i < synth->buffersize; ++i)
47 input->l[i] = input->r[i] = 0.0f;
48 testFX = new Echo(true, outL, outR, 44100, 256);
49 }
50
51 void tearDown() {
52 delete[] input->r;
53 delete[] input->l;
54 delete input;
55 delete[] outL;
56 delete[] outR;
57 delete testFX;
58 delete synth;
59 }
60
61
62 void testInit() {
63 //Make sure that the output will be zero at start
64 //(given a zero input)
65 testFX->out(*input);
66 for(int i = 0; i < synth->buffersize; ++i) {
67 TS_ASSERT_DELTA(outL[i], 0.0f, 0.0001f);
68 TS_ASSERT_DELTA(outR[i], 0.0f, 0.0001f);
69 }
70 }
71
72 void testClear() {
73 char DELAY = 2;
74 testFX->changepar(DELAY, 127);
75
76 //flood with high input
77 for(int i = 0; i < synth->buffersize; ++i)
78 input->r[i] = input->l[i] = 1.0f;
79
80 for(int i = 0; i < 500; ++i)
81 testFX->out(*input);
82 for(int i = 0; i < synth->buffersize; ++i) {
83 TS_ASSERT_DIFFERS(outL[i], 0.0f);
84 TS_ASSERT_DIFFERS(outR[i], 0.0f)
85 }
86 //After making sure the internal buffer has a nonzero value
87 //cleanup
88 //Then get the next output, which should be zereoed out if DELAY
89 //is large enough
90 testFX->cleanup();
91 testFX->out(*input);
92 for(int i = 0; i < synth->buffersize; ++i) {
93 TS_ASSERT_DELTA(outL[i], 0.0f, 0.0001f);
94 TS_ASSERT_DELTA(outR[i], 0.0f, 0.0001f);
95 }
96 }
97 //Insures that the proper decay occurs with high feedback
98 void testDecaywFb() {
99 //flood with high input
100 for(int i = 0; i < synth->buffersize; ++i)
101 input->r[i] = input->l[i] = 1.0f;
102 char FEEDBACK = 5;
103 testFX->changepar(FEEDBACK, 127);
104 for(int i = 0; i < 100; ++i)
105 testFX->out(*input);
106 for(int i = 0; i < synth->buffersize; ++i) {
107 TS_ASSERT_DIFFERS(outL[i], 0.0f);
108 TS_ASSERT_DIFFERS(outR[i], 0.0f)
109 }
110 float amp = abs(outL[0] + outR[0]) / 2;
111 //reset input to zero
112 for(int i = 0; i < synth->buffersize; ++i)
113 input->r[i] = input->l[i] = 0.0f;
114
115 //give the echo time to fade based upon zero input and high feedback
116 for(int i = 0; i < 50; ++i)
117 testFX->out(*input);
118 TS_ASSERT_LESS_THAN_EQUALS(abs(outL[0] + outR[0]) / 2, amp);
119 }
120
121
122 private:
124 float *outR, *outL;
126};
SYNTH_T * synth
Definition EchoTest.h:29
SYNTH_T * synth
Definition LocalZynAddSubFx.cpp:47
float abs(const fft_t *freqs, off_t x)
Definition OscilGen.cpp:52
Definition EchoTest.h:34
Stereo< float * > * input
Definition EchoTest.h:123
float * outL
Definition EchoTest.h:124
void testDecaywFb()
Definition EchoTest.h:98
Echo * testFX
Definition EchoTest.h:125
float * outR
Definition EchoTest.h:124
void setUp()
Definition EchoTest.h:36
void tearDown()
Definition EchoTest.h:51
void testClear()
Definition EchoTest.h:72
void testInit()
Definition EchoTest.h:62
register unsigned i
Definition inflate.c:1575
Definition juce_Uuid.h:141
Definition tap_echo.c:62
Definition globals.h:204
Definition Stereo.h:25
#define DELAY
Definition tap_chorusflanger.c:39