zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 941cfdcf29cee9d215bb36f3090b14b5fdefbbbd
parent f3a43e9b76976803576ebad96bedda767833c189
Author: fundamental <[email protected]>
Date:   Sat,  1 May 2010 18:38:50 -0400

Echo: fixing failing tests

Diffstat:
Msrc/Effects/Echo.cpp | 4++--
Msrc/Tests/EchoTest.h | 15++++++++++-----
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp @@ -53,8 +53,8 @@ Echo::~Echo() */ void Echo::cleanup() { - memset(delay.l(),0,MAX_DELAY*SAMPLE_RATE); - memset(delay.r(),0,MAX_DELAY*SAMPLE_RATE); + memset(delay.l(),0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); + memset(delay.r(),0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); old = Stereo<REALTYPE>(0.0); } diff --git a/src/Tests/EchoTest.h b/src/Tests/EchoTest.h @@ -21,26 +21,31 @@ */ #include <cxxtest/TestSuite.h> #include <cmath> +#include <iostream> #include "../Effects/Echo.h" #include "../globals.h" +using namespace std; + class EchoTest:public CxxTest::TestSuite { public: void setUp() { outL = new float[SOUND_BUFFER_SIZE]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - *(outL + i) = 0; + outL[i] = 0.0; outR = new float[SOUND_BUFFER_SIZE]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - *(outR + i) = 0; + outR[i] = 0.0; input = new Stereo<REALTYPE *>(new REALTYPE[SOUND_BUFFER_SIZE],new REALTYPE[SOUND_BUFFER_SIZE]); + for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) + input->l()[i] = input->r()[i] = 0.0f; testFX = new Echo(true, outL, outR); } void tearDown() { - delete input->r(); - delete input->l(); + delete[] input->r(); + delete[] input->l(); delete input; delete[] outL; delete[] outR; @@ -105,7 +110,7 @@ class EchoTest:public CxxTest::TestSuite //give the echo time to fade based upon zero input and high feedback for(int i = 0; i < 50; ++i) testFX->out(*input); - TS_ASSERT_LESS_THAN(abs(outL[0] + outR[0]) / 2, amp); + TS_ASSERT_LESS_THAN_EQUALS(abs(outL[0] + outR[0]) / 2, amp); }