zynaddsubfx

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

commit c85a442544fa89458f6e6846333891b36a411733
parent 42a066a7d7e3c9631bde7187269acd7e9234ccf6
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sun,  4 Oct 2009 21:34:53 -0400

Ctest: fixed test finding issues

Removed hacky make.sh that was used in the past for testing building

Diffstat:
MChangeLog | 3+++
Msrc/CMakeLists.txt | 5+++--
Dsrc/Synth/ADnote.cxx | 136-------------------------------------------------------------------------------
Msrc/Synth/CMakeLists.txt | 2--
Asrc/Tests/AdNoteTest.h | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Tests/CMakeLists.txt | 11++++++-----
Dsrc/Tests/XMLWrapperTest.h | 48------------------------------------------------
Asrc/Tests/XMLwrapperTest.h | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/Tests/make.sh | 6------
9 files changed, 192 insertions(+), 199 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -944,3 +944,6 @@ 02 Oct 2009 (Mark McCurry) - Added OSS failsafe by Jérémie Andréi +04 Oct 2009 (Mark McCurry) + - fixed Ctest issues + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -118,9 +118,10 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) + #macro for tests macro(unit_test NAME CXX_FILE FILES) - if (CompileTests) + # if (CompileTests) set(PATH_FILES "") foreach(part ${FILES}) set(PATH_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${part}" ${PATH_FILES}) @@ -141,7 +142,7 @@ macro(unit_test NAME CXX_FILE FILES) ${MXML_LIBRARIES} ) add_test("${NAME}" "${EXECUTABLE_OUTPUT_PATH}/${NAME}") - endif() + #endif() endmacro(unit_test) set(NONGUI_LIBRARIES diff --git a/src/Synth/ADnote.cxx b/src/Synth/ADnote.cxx @@ -1,136 +0,0 @@ -#include <cxxtest/TestSuite.h> -#include <iostream> -#include <fstream> -#include "../Misc/Master.h" -#include "../Misc/Util.h" -#include "../Synth/ADnote.h" -#include "../Params/Presets.h" -#include "../globals.h" - -class AdNoteTest : public CxxTest::TestSuite -{ -public: - - ADnote *note; - Master *master; - Controller *controller; - unsigned char testnote; - - - float *outR,*outL; - - void setUp() { - - //First the sensible settings and variables that have to be set: - SOUND_BUFFER_SIZE = 256; - - outL=new float[SOUND_BUFFER_SIZE]; - for (int i=0;i<SOUND_BUFFER_SIZE;++i) - *(outL+i)=0; - outR=new float[SOUND_BUFFER_SIZE]; - for (int i=0;i<SOUND_BUFFER_SIZE;++i) - *(outR+i)=0; - - //next the bad global variables that for some reason have not been properly placed in some - //initialization routine, but rather exist as cryptic oneliners in main.cpp: - denormalkillbuf= new REALTYPE[SOUND_BUFFER_SIZE]; - for (int i=0;i<SOUND_BUFFER_SIZE;i++) denormalkillbuf[i]=0; - - OscilGen::tmpsmps=new REALTYPE[OSCIL_SIZE]; - newFFTFREQS(&OscilGen::outoscilFFTfreqs,OSCIL_SIZE/2); - - - //phew, glad to get thouse out of my way. took me a lot of sweat and gdb to get this far... - - //prepare the default settings - ADnoteParameters *defaultPreset = new ADnoteParameters(new FFTwrapper(OSCIL_SIZE)); - XMLwrapper *wrap = new XMLwrapper(); - wrap->loadXMLfile("src/Tests/guitar-adnote.xmz"); - TS_ASSERT(wrap->enterbranch("MASTER")); - TS_ASSERT(wrap->enterbranch("PART", 0)); - TS_ASSERT(wrap->enterbranch("INSTRUMENT")); - TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT")); - TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT_ITEM", 0)); - TS_ASSERT(wrap->enterbranch("ADD_SYNTH_PARAMETERS")); - defaultPreset->getfromXML(wrap); - //defaultPreset->defaults(); - - - - controller = new Controller(); - - //lets go with.... 50! as a nice note - testnote = 50; - REALTYPE freq = 440.0*pow(2.0,(testnote-69.0)/12.0); - - note = new ADnote(defaultPreset, controller, freq, 120, 0, testnote, false); - - } - - void willNoteBeRunButIsHereForLinkingReasonsHowsThisForCamelCaseEh() - { - master = new Master(); - } - - void tearDown() { - delete note; - deleteFFTFREQS(&OscilGen::outoscilFFTfreqs); - } - - void testDefaults() { - - TS_ASSERT(note->ready); - int sampleCount = 0; - -//#define WRITE_OUTPUT - -#ifdef WRITE_OUTPUT - ofstream file("adnoteout", ios::out); -#endif - note->noteout(outL, outR); -#ifdef WRITE_OUTPUT - for (int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - file << outL[i] << std::endl; - } -#endif - sampleCount += SOUND_BUFFER_SIZE; - - TS_ASSERT_DELTA(outL[255], 0.1724, 0.0001); - - note->relasekey(); - - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.1284, 0.0001); - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.0206, 0.0001); - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.1122, 0.0001); - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.1707, 0.0001); - - while (!note->finished()) { - note->noteout(outL, outR); -#ifdef WRITE_OUTPUT - for (int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - file << outL[i] << std::endl; - } -#endif - sampleCount += SOUND_BUFFER_SIZE; - } -#ifdef WRITE_OUTPUT - file.close(); -#endif - - TS_ASSERT_EQUALS(sampleCount, 9472); - - } -}; - diff --git a/src/Synth/CMakeLists.txt b/src/Synth/CMakeLists.txt @@ -14,5 +14,3 @@ add_library(zynaddsubfx_synth STATIC target_link_libraries(zynaddsubfx_synth) -unit_test(adnote_test ADnote.cxx "") - diff --git a/src/Tests/AdNoteTest.h b/src/Tests/AdNoteTest.h @@ -0,0 +1,131 @@ +#include <cxxtest/TestSuite.h> +#include <iostream> +#include <fstream> +#include "../Misc/Master.h" +#include "../Misc/Util.h" +#include "../Synth/ADnote.h" +#include "../Params/Presets.h" +#include "../globals.h" + +class AdNoteTest : public CxxTest::TestSuite +{ +public: + + ADnote *note; + Master *master; + Controller *controller; + unsigned char testnote; + + + float *outR,*outL; + + void setUp() { + + //First the sensible settings and variables that have to be set: + SOUND_BUFFER_SIZE = 256; + + outL=new float[SOUND_BUFFER_SIZE]; + for (int i=0;i<SOUND_BUFFER_SIZE;++i) + *(outL+i)=0; + outR=new float[SOUND_BUFFER_SIZE]; + for (int i=0;i<SOUND_BUFFER_SIZE;++i) + *(outR+i)=0; + + //next the bad global variables that for some reason have not been properly placed in some + //initialization routine, but rather exist as cryptic oneliners in main.cpp: + denormalkillbuf= new REALTYPE[SOUND_BUFFER_SIZE]; + for (int i=0;i<SOUND_BUFFER_SIZE;i++) denormalkillbuf[i]=0; + + //phew, glad to get thouse out of my way. took me a lot of sweat and gdb to get this far... + + //prepare the default settings + ADnoteParameters *defaultPreset = new ADnoteParameters(new FFTwrapper(OSCIL_SIZE)); + XMLwrapper *wrap = new XMLwrapper(); + wrap->loadXMLfile("src/Tests/guitar-adnote.xmz"); + TS_ASSERT(wrap->enterbranch("MASTER")); + TS_ASSERT(wrap->enterbranch("PART", 0)); + TS_ASSERT(wrap->enterbranch("INSTRUMENT")); + TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT")); + TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT_ITEM", 0)); + TS_ASSERT(wrap->enterbranch("ADD_SYNTH_PARAMETERS")); + defaultPreset->getfromXML(wrap); + //defaultPreset->defaults(); + + + + controller = new Controller(); + + //lets go with.... 50! as a nice note + testnote = 50; + REALTYPE freq = 440.0*pow(2.0,(testnote-69.0)/12.0); + + note = new ADnote(defaultPreset, controller, freq, 120, 0, testnote, false); + + } + + void willNoteBeRunButIsHereForLinkingReasonsHowsThisForCamelCaseEh() + { + master = new Master(); + } + + void tearDown() { + delete note; + } + + void testDefaults() { + + TS_ASSERT(note->ready); + int sampleCount = 0; + +//#define WRITE_OUTPUT + +#ifdef WRITE_OUTPUT + ofstream file("adnoteout", ios::out); +#endif + note->noteout(outL, outR); +#ifdef WRITE_OUTPUT + for (int i = 0; i < SOUND_BUFFER_SIZE; ++i) { + file << outL[i] << std::endl; + } +#endif + sampleCount += SOUND_BUFFER_SIZE; + + TS_ASSERT_DELTA(outL[255], 0.1724, 0.0001); + + note->relasekey(); + + + note->noteout(outL, outR); + sampleCount += SOUND_BUFFER_SIZE; + TS_ASSERT_DELTA(outL[255], -0.1284, 0.0001); + + note->noteout(outL, outR); + sampleCount += SOUND_BUFFER_SIZE; + TS_ASSERT_DELTA(outL[255], -0.0206, 0.0001); + + note->noteout(outL, outR); + sampleCount += SOUND_BUFFER_SIZE; + TS_ASSERT_DELTA(outL[255], -0.1122, 0.0001); + + note->noteout(outL, outR); + sampleCount += SOUND_BUFFER_SIZE; + TS_ASSERT_DELTA(outL[255], 0.1707, 0.0001); + + while (!note->finished()) { + note->noteout(outL, outR); +#ifdef WRITE_OUTPUT + for (int i = 0; i < SOUND_BUFFER_SIZE; ++i) { + file << outL[i] << std::endl; + } +#endif + sampleCount += SOUND_BUFFER_SIZE; + } +#ifdef WRITE_OUTPUT + file.close(); +#endif + + TS_ASSERT_EQUALS(sampleCount, 9472); + + } +}; + diff --git a/src/Tests/CMakeLists.txt b/src/Tests/CMakeLists.txt @@ -1,5 +1,6 @@ -unit_test(ControllerTest ControllerTest.h "") -unit_test(EchoTest EchoTest.h "") -unit_test(SampleTest SampleTest.h "") -unit_test(MicrotonalTest MicrotonalTest.h "") -unit_test(XMLwrapperTest XMLwrapperTest.h "") +unit_test(ControllerTest ControllerTest.h ../Params/Controller.h) +unit_test(EchoTest EchoTest.h ../Effects/Echo.h) +unit_test(SampleTest SampleTest.h ../Samples/AuSample.h) +unit_test(MicrotonalTest MicrotonalTest.h ../Misc/Microtonal.h) +unit_test(XMLwrapperTest XMLwrapperTest.h ../Misc/XMLwrapper.h) +unit_test(ADnoteTest AdNoteTest.h ../Synth/ADnote.h) diff --git a/src/Tests/XMLWrapperTest.h b/src/Tests/XMLWrapperTest.h @@ -1,48 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - XMLwrapperTest.h - CxxTest for Misc/XMLwrapper - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program 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 (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ -#include <cxxtest/TestSuite.h> -#include "../XMLwrapper.h" - -class XMLwrapperTest : pubilc CxxTest::TestSuite -{ -pubilic: - void setUp() { - xmla = new XMLwrapper; - xmlb = new XMLwrapper; - } - - void tearDown() { - delete xmla; - delete xmlb; - } - - void testAddPar(){ - xmla.addpar("my Pa*_ramet@er",75); - TS_ASSERT_EQUALS(xmla.getpar("my Pa*_ramet@er",0,-200,200),75); - } - - -private: - XMLwrapper *xmla; - XMLwrapper *xmlb; -} - diff --git a/src/Tests/XMLwrapperTest.h b/src/Tests/XMLwrapperTest.h @@ -0,0 +1,49 @@ +/* + ZynAddSubFX - a software synthesizer + + XMLwrapperTest.h - CxxTest for Misc/XMLwrapper + Copyright (C) 2009-2009 Mark McCurry + Author: Mark McCurry + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + This program 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 (version 2 or later) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ +#include <cxxtest/TestSuite.h> +#include "../Misc/XMLwrapper.h" + +class XMLwrapperTest : public CxxTest::TestSuite +{ +public: + void setUp() { + xmla = new XMLwrapper; + xmlb = new XMLwrapper; + } + + + void testAddPar() { + xmla->addpar("my Pa*_ramet@er",75); + TS_ASSERT_EQUALS(xmla->getpar("my Pa*_ramet@er",0,-200,200),75); + } + + void tearDown() { + delete xmla; + delete xmlb; + } + + +private: + XMLwrapper *xmla; + XMLwrapper *xmlb; +}; + diff --git a/src/Tests/make.sh b/src/Tests/make.sh @@ -1,6 +0,0 @@ -cd ../ -make -cd Tests -cxxtestgen.py --error-printer -o runner.cpp SampleTest.h EchoTest.h \ -ControllerTest.h MicrotonalTest.h XMLwrapperTest.h -g++ -g -o runner runner.cpp ../Samples/AuSample.o ../Samples/Sample.o ../Effects/Echo.o ../Effects/Effect.o ../Controls/Control.o ../Controls/DelayCtl.o ../Params/Controller.o ../Misc/XMLwrapper.o ../Misc/Config.o ../Misc/Util.o ../Misc/Microtonal.o -lmxml -lm -lz -lpthread