Permalink
Browse files

Cleaned out the unit testing

It was pretty crap anyway.
  • Loading branch information...
1 parent 9c22c83 commit 4249da35057594062f4c63a5e19c68e4920193d6 @ibsh committed Oct 9, 2011
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -17,50 +17,9 @@
QT += core
+QT += gui
TEMPLATE = app
-
-CONFIG(debug, debug|release){
- # DEBUG (UNIT TESTING) CONFIGURATION
- QT -= gui
- QT += testlib
- TARGET = keyfinder_test
- CONFIG += console
- CONFIG -= app_bundle
- HEADERS += unittest.h
- SOURCES += \
- test__main.cpp \
- test_audiobuffer.cpp \
- test_chromagram.cpp \
- test_decoderlibav.cpp \
- test_downsamplerib.cpp \
- test_downsamplerlibsrc.cpp \
- test_directskpostproc.cpp \
- test_constantqpostproc.cpp
-}else{
- # RELEASE CONFIGURATION
- QT += gui
- TARGET = KeyFinder
- HEADERS += \
- guiabout.h \
- guibatch.h \
- guidetail.h \
- guimenuhandler.h \
- guiprefs.h \
- guivisuals.h
- SOURCES += \
- main.cpp \
- guiabout.cpp \
- guibatch.cpp \
- guidetail.cpp \
- guimenuhandler.cpp \
- guiprefs.cpp \
- guivisuals.cpp
- FORMS += \
- detailwindow.ui \
- batchwindow.ui \
- aboutdialog.ui \
- prefsdialog.ui
-}
+TARGET = KeyFinder
SOURCES += \
decoderlibav.cpp \
@@ -87,7 +46,14 @@ SOURCES += \
spectrumanalyserfftw.cpp \
spectrumanalysergoertzel.cpp \
hcdfarbitrary.cpp \
- audiostream.cpp
+ audiostream.cpp \
+ main.cpp \
+ guiabout.cpp \
+ guibatch.cpp \
+ guidetail.cpp \
+ guimenuhandler.cpp \
+ guiprefs.cpp \
+ guivisuals.cpp
HEADERS += \
decoderlibav.h \
@@ -115,7 +81,20 @@ HEADERS += \
spectrumanalysergoertzel.h \
fftpp.h \
hcdfarbitrary.h \
- audiostream.h
+ audiostream.h \
+ guiabout.h \
+ guibatch.h \
+ guidetail.h \
+ guimenuhandler.h \
+ guiprefs.h \
+ guivisuals.h
+
+FORMS += \
+ detailwindow.ui \
+ batchwindow.ui \
+ aboutdialog.ui \
+ prefsdialog.ui
+
OTHER_FILES += \
is_KeyFinder.pro.user \
README
View
@@ -1,24 +0,0 @@
-/*************************************************************************
-
- Copyright 2011 Ibrahim Sha'ath
-
- This file is part of KeyFinder.
-
- KeyFinder is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- KeyFinder 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 for more details.
-
- You should have received a copy of the GNU General Public License
- along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
-
-*************************************************************************/
-
-#include "unittest.h"
-
-TEST_MAIN
View
@@ -1,69 +0,0 @@
-/*************************************************************************
-
- Copyright 2011 Ibrahim Sha'ath
-
- This file is part of KeyFinder.
-
- KeyFinder is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- KeyFinder 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 for more details.
-
- You should have received a copy of the GNU General Public License
- along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
-
-*************************************************************************/
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-#include "unittest.h"
-
-#include "audiostream.h"
-
-class AudioStream_Test : public QObject{
- Q_OBJECT
-public:
- AudioStream_Test();
-private Q_SLOTS:
- void testConstructor();
- void testMutators();
-};
-DECLARE_TEST(AudioStream_Test)
-
-AudioStream_Test::AudioStream_Test(){}
-
-void AudioStream_Test::testConstructor(){
- AudioStream* ab = new AudioStream();
- QVERIFY(ab->getChannels() == 0);
- QVERIFY(ab->getFrameRate() == 0);
- QVERIFY(ab->getSampleCount() == 0);
- delete ab;
-}
-
-void AudioStream_Test::testMutators(){
- AudioStream* ab = new AudioStream();
- ab->setChannels(2);
- QVERIFY(ab->getChannels() == 2);
- ab->setFrameRate(44100);
- QVERIFY(ab->getFrameRate() == 44100);
- ab->addToSampleCount(65536);
- QVERIFY(ab->getSampleCount() == 65536);
- QVERIFY(ab->getSample(0) == 0.0);
- ab->setSample(101,16384.0);
- QVERIFY(ab->getSample(101) == 16384.0);
- // test that exception handling for bad alloc
- try{
- ab->addToSampleCount(INT_MAX);
- QFAIL("Either your machine has a startlingly large memory or an exception failed to throw.");
- }catch(...){
- QVERIFY(true);
- }
- delete ab;
-}
-
-#include "test_audiobuffer.moc"
View
@@ -1,96 +0,0 @@
-/*************************************************************************
-
- Copyright 2011 Ibrahim Sha'ath
-
- This file is part of KeyFinder.
-
- KeyFinder is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- KeyFinder 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 for more details.
-
- You should have received a copy of the GNU General Public License
- along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
-
-*************************************************************************/
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-#include "unittest.h"
-
-#include "chromagram.h"
-#include "preferences.h"
-
-class Chromagram_Test : public QObject{
- Q_OBJECT
-public:
- Chromagram_Test();
-private Q_SLOTS:
- void testConstructor();
- void testSetMagnitude();
- void testAdaptiveDecomposition();
-};
-DECLARE_TEST(Chromagram_Test)
-
-Chromagram_Test::Chromagram_Test(){}
-
-void Chromagram_Test::testConstructor(){
- Chromagram* ch = new Chromagram(1,1);
- QVERIFY(ch->getBins() == 1);
- QVERIFY(ch->getHops() == 1);
- QVERIFY(ch->getMagnitude(0,0) == 0.0);
- delete ch;
-}
-
-void Chromagram_Test::testSetMagnitude(){
- Chromagram* ch = new Chromagram(1,1);
- ch->setMagnitude(0,0,5.0);
- QVERIFY(ch->getMagnitude(0,0) == 5.0);
- delete ch;
-}
-
-void Chromagram_Test::testAdaptiveDecomposition(){
- int octaves = 6;
- int semitones = 12;
- int bandsPerSemitone = 3;
- Preferences prefs;
- prefs.setTuningMethod(1);
- prefs.setBandsPerSemitone(bandsPerSemitone);
- float weight = prefs.getDetunedBandWeight();
- Chromagram* ch = new Chromagram(1,octaves*semitones*bandsPerSemitone);
- QVERIFY(ch->getBins() == 216);
- // first semitone of first octave, tuned down
- ch->setMagnitude(0,0,10.0);
- ch->setMagnitude(0,1,1.0);
- ch->setMagnitude(0,2,1.0);
- // first semitone of second octave, tuned to concert pitch
- ch->setMagnitude(0,36,1.0);
- ch->setMagnitude(0,37,10.0);
- ch->setMagnitude(0,38,1.0);
- // first semitone of second octave, tuned up
- ch->setMagnitude(0,72,1.0);
- ch->setMagnitude(0,73,1.0);
- ch->setMagnitude(0,74,10.0);
- // reduce to 1 band per semitone
- ch->reduceTuningBins(prefs);
- QVERIFY(ch->getBins() == 72);
- // adaptive tuning should mean all three set semitones come out the same
- QVERIFY(ch->getMagnitude(0,0) == 10 + 2.0 * weight);
- QVERIFY(ch->getMagnitude(0,12) == 10 + 2.0 * weight);
- QVERIFY(ch->getMagnitude(0,24) == 10 + 2.0 * weight);
- QVERIFY(ch->getMagnitude(0,36) == 0.0);
- // reduce to one octave
- ch->reduceToOneOctave(prefs);
- QVERIFY(ch->getBins() == 12);
- // test that the magnitude is now halved, since only three of six were set
- QVERIFY(ch->getMagnitude(0,0) == 0.5 * (10 + 2 * 1.0 * weight));
- delete ch;
-}
-
-#include "test_chromagram.moc"
-
View
@@ -1,96 +0,0 @@
-/*************************************************************************
-
- Copyright 2011 Ibrahim Sha'ath
-
- This file is part of KeyFinder.
-
- KeyFinder is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- KeyFinder 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 for more details.
-
- You should have received a copy of the GNU General Public License
- along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
-
-*************************************************************************/
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-#include "unittest.h"
-
-#include "decoderlibav.h"
-#include "spectrumanalyserfftw.h"
-#include "fftppconstantq.h"
-#include "chromagram.h"
-
-class ConstantQPostProc_Test : public QObject{
- Q_OBJECT
-public:
- ConstantQPostProc_Test();
-private Q_SLOTS:
- void testTransform();
-};
-DECLARE_TEST(ConstantQPostProc_Test)
-
-ConstantQPostProc_Test::ConstantQPostProc_Test(){}
-
-void ConstantQPostProc_Test::testTransform(){
- LibAvDecoder* dec = new LibAvDecoder;
- AudioStream* ab = NULL;
- try{
- ab = dec->decodeFile("../is_KeyFinder/_testaudio/audio-sine-chord.wav");
- }catch(...){
- QFAIL("Decoder failed");
- }
- delete dec;
- Preferences prefs;
- prefs.setBandsPerSemitone(1);
- prefs.setDownsampleFactor(1);
- prefs.setFftPostProcessor('c');
- SpectrumAnalyser* sa = new FftwAnalyser(44100,prefs);
- Chromagram* ch = sa->chromagram(ab);
- delete sa;
- delete ab;
- /*
- audio-sine-chord.wav contains an A minor seventh chord starting at A440,
- so we test that those four notes are roughly equal in energy, and that the
- other notes are below some threshold.
- OBSERVE THE MUCH LARGER THRESHOLDS NECESSARY HERE VERSUS DIRECT SK.
- */
- int notes[] = {48,51,55,58}; // A4, C5, E5, G5.
- // normalise
- float norm = ch->getMagnitude(0,notes[0]);
- for(int i=0; i<ch->getBins(); i++){
- if(i != 48)
- ch->setMagnitude(0,i,ch->getMagnitude(0,i) / norm);
- }
- ch->setMagnitude(0,48,1.0);
- // test all bins
- for(int i=0; i<ch->getBins(); i++){
- bool tested = false;
- for(int j=0; j<4; j++){
- if(i == notes[j]){
- QVERIFY(ch->getMagnitude(0,i) > 0.99);
- QVERIFY(ch->getMagnitude(0,i) < 1.5);
- tested = true;
- break;
- }else if(i+1 == notes[j] || i-1 == notes[j]){
- // This variation is necessary for CQT because it's not as precise as DSK at standard Q.
- QVERIFY(ch->getMagnitude(0,i) < 0.7);
- tested = true;
- break;
- }
- }
- if(!tested){
- QVERIFY(ch->getMagnitude(0,i) < 0.1);
- }
- }
- delete ch;
-}
-
-#include "test_constantqpostproc.moc"
Oops, something went wrong.

0 comments on commit 4249da3

Please sign in to comment.