Mercurial > hg > cepstral-pitchtracker
changeset 41:16908c2bd781
Build & test fixes
author | Chris Cannam |
---|---|
date | Fri, 20 Jul 2012 19:08:38 +0100 |
parents | 8f56ef28b0b1 |
children | 45b4401136f6 |
files | Makefile.inc Makefile.linux64 test/Makefile test/TestPeakInterpolator.cpp |
diffstat | 4 files changed, 54 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.inc Fri Jul 20 10:46:40 2012 +0100 +++ b/Makefile.inc Fri Jul 20 19:08:38 2012 +0100 @@ -1,12 +1,17 @@ PLUGIN_EXT ?= .so -PLUGIN ?= cepstral-pitchtracker$(PLUGIN_EXT) + CXX ?= g++ CC ?= gcc -CFLAGS := $(CFLAGS) -CXXFLAGS := $(CXXFLAGS) -LDFLAGS := $(LDFLAGS) -lvamp-sdk +CFLAGS := $(CFLAGS) +CXXFLAGS := -I. $(CXXFLAGS) + +LDFLAGS := $(LDFLAGS) -lvamp-sdk +PLUGIN_LDFLAGS := $(LDFLAGS) $(PLUGIN_LDFLAGS) +TEST_LDFLAGS := $(LDFLAGS) -lboost_unit_test_framework + +PLUGIN := cepstral-pitchtracker$(PLUGIN_EXT) HEADERS := CepstralPitchTracker.h \ NoteHypothesis.h \ @@ -14,27 +19,41 @@ SOURCES := CepstralPitchTracker.cpp \ NoteHypothesis.cpp \ - PeakInterpolator.cpp \ - libmain.cpp + PeakInterpolator.cpp + +PLUGIN_MAIN := libmain.cpp + +TESTS := test/test-notehypothesis \ + test/test-peakinterpolator OBJECTS := $(SOURCES:.cpp=.o) OBJECTS := $(OBJECTS:.c=.o) -all: $(PLUGIN) +PLUGIN_OBJECTS := $(OBJECTS) $(PLUGIN_MAIN:.cpp=.o) -$(PLUGIN): $(OBJECTS) - $(CXX) -o $@ $^ $(LDFLAGS) - $(MAKE) -C test +all: $(PLUGIN) $(TESTS) + for t in $(TESTS); do echo "Running $$t"; ./"$$t" || exit 1; done + +$(PLUGIN): $(PLUGIN_OBJECTS) + $(CXX) -o $@ $^ $(PLUGIN_LDFLAGS) + +test/test-notehypothesis: test/TestNoteHypothesis.o $(OBJECTS) + $(CXX) -o $@ $^ $(TEST_LDFLAGS) + +test/test-peakinterpolator: test/TestPeakInterpolator.o $(OBJECTS) + $(CXX) -o $@ $^ $(TEST_LDFLAGS) clean: - rm -f $(OBJECTS) - $(MAKE) -C test clean + rm -f $(OBJECTS) test/*.o distclean: clean - rm -f $(PLUGIN) - $(MAKE) -C test distclean + rm -f $(PLUGIN) $(TESTS) -libmain.o: $(HEADERS) $(SOURCES) -CepstralPitchTracker.o: $(HEADERS) $(SOURCES) -NoteHypothesis.o: $(HEADERS) $(SOURCES) -PeakInterpolator.o: $(HEADERS) $(SOURCES) +# DO NOT DELETE + +CepstralPitchTracker.o: CepstralPitchTracker.h NoteHypothesis.h +libmain.o: CepstralPitchTracker.h NoteHypothesis.h +NoteHypothesis.o: NoteHypothesis.h +PeakInterpolator.o: PeakInterpolator.h +test/TestNoteHypothesis.o: NoteHypothesis.h +test/TestPeakInterpolator.o: PeakInterpolator.h
--- a/Makefile.linux64 Fri Jul 20 10:46:40 2012 +0100 +++ b/Makefile.linux64 Fri Jul 20 19:08:38 2012 +0100 @@ -2,7 +2,7 @@ CFLAGS := -Wall -g -fPIC CXXFLAGS := $(CFLAGS) -LDFLAGS := -shared -Wl,-Bstatic -lvamp-sdk -Wl,-Bdynamic +PLUGIN_LDFLAGS := -shared -Wl,-Bstatic -lvamp-sdk -Wl,-Bdynamic PLUGIN_EXT := .so
--- a/test/Makefile Fri Jul 20 10:46:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -CXX ?= g++ -CC ?= gcc - -CFLAGS := $(CFLAGS) -CXXFLAGS := $(CXXFLAGS) -I.. -LDFLAGS := $(LDFLAGS) -lvamp-sdk -lboost_unit_test_framework - -SUPER_OBJECTS := ../NoteHypothesis.o ../PeakInterpolator.o - -OBJECTS := TestNoteHypothesis.o TestPeakInterpolator.o - -TESTS := test-notehypothesis test-peakinterpolator - -all: run-tests - -test-notehypothesis: TestNoteHypothesis.o - $(CXX) -o $@ $^ $(SUPER_OBJECTS) $(LDFLAGS) - -test-peakinterpolator: TestPeakInterpolator.o - $(CXX) -o $@ $^ $(SUPER_OBJECTS) $(LDFLAGS) - -run-tests: $(TESTS) - for t in $(TESTS); do ./"$$t" || exit 1; done - -clean: - rm -f $(OBJECTS) - -distclean: clean - rm -f $(TESTS) -
--- a/test/TestPeakInterpolator.cpp Fri Jul 20 10:46:40 2012 +0100 +++ b/test/TestPeakInterpolator.cpp Fri Jul 20 19:08:38 2012 +0100 @@ -98,5 +98,21 @@ BOOST_CHECK_EQUAL(result, 1.5); } +BOOST_AUTO_TEST_CASE(aboveHalfway) +{ + double data[] = { 1.0, 1.5, 2.0, 1.0 }; + PeakInterpolator p; + double result = p.findPeakLocation(data, 4, 2); + BOOST_CHECK(result > 1.5 && result < 2.0); +} + +BOOST_AUTO_TEST_CASE(belowHalfway) +{ + double data[] = { 1.0, 2.0, 1.5, 1.0 }; + PeakInterpolator p; + double result = p.findPeakLocation(data, 4, 1); + BOOST_CHECK(result > 1.0 && result < 1.5); +} + BOOST_AUTO_TEST_SUITE_END()