Mercurial > hg > segmenter-vamp-plugin
changeset 47:5ead8717a618
merge
author | matthiasm |
---|---|
date | Wed, 12 Jun 2013 19:23:03 +0100 |
parents | f59ff6a22f8e (diff) affc4ace1ea3 (current diff) |
children | 69251e11a913 |
files | songparts/lunchMake.sh |
diffstat | 5 files changed, 49 insertions(+), 253 deletions(-) [+] |
line wrap: on
line diff
--- a/armadillo-2.4.4/examples/Makefile Wed Jun 12 12:56:34 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -# NOTE: -# This file is mainly useful when doing a manual installation of Armadillo. -# It is overwritten by CMake when doing an automatic installation. -# -# You may need to edit this file to reflect the type and capabilities -# of your system. The defaults are for a Linux system and will need -# to be changed for other systems (e.g. Mac OS X). - - -CXX=g++ -#CXX=g++-4.2 -## Under MacOS you may have an old compiler as default (e.g. GCC 4.0). -## However, GCC 4.2 or later is available and preferable due to better -## handling of template code. - -#CXX=CC -## When using the Sun Studio compiler - - -ARMA_INCLUDE_FLAG = -I ../include -## If you've installed Armadillo's headers manually, -## you may need to tell the compiler where they are. -## For example, change ../include to /usr/local/include -## and uncomment the above line. - - -#BOOST_INCLUDE_FLAG = -I /usr/include -## If you have Boost libraries, change /usr/include -## to point to where they are installed and uncomment -## the above line. - - -#EXTRA_LIB_FLAGS = -llapack -lblas -## The above line is an example of the extra libraries -## that can be used by Armadillo. You will also need -## to modify "include/armadillo_bits/config.hpp" -## to indicate which extra libraries are present. -## If you're using Mac OS, comment out the line and -## instead use the line below. - - -#EXTRA_LIB_FLAGS = -framework Accelerate -## Uncomment the above line when using Mac OS -## and modify "include/armadillo_bits/config.hpp" -## to indicate that LAPACK and BLAS libraries -## are present - - -#EXTRA_LIB_FLAGS = -library=sunperf -## When using the Sun Studio compiler - - -LIB_FLAGS = $(EXTRA_LIB_FLAGS) -## NOTE: on Ubuntu and Debian based systems you may need to add -## -lgfortran to LIB_FLAGS - - -OPT = -O1 -## As the Armadillo library uses recursive templates, -## compilation times depend on the level of optimisation: -## -## -O0: quick compilation, but the resulting program will be slow -## -O1: produces programs which achieve most of the possible speedup -## -O3: produces programs which have almost all possible speedups, -## but compilation takes considerably longer - - -#OPT = -xO4 -xannotate=no -## When using the Sun Studio compiler - - -#EXTRA_OPT = -fwhole-program -## Uncomment the above line if you're compiling -## all source files into one program in a single hit. - - -#DEBUG = -DARMA_EXTRA_DEBUG -## Uncomment the above line to enable low-level -## debugging. Lots of debugging information will -## be printed when a compiled program is run. -## Please enable this option when reporting bugs. - - -#FINAL = -DARMA_NO_DEBUG -## Uncomment the above line to disable Armadillo's checks. -## DANGEROUS! Not recommended unless your code has been -## thoroughly tested. - - -# -# -# - -CXXFLAGS = $(ARMA_INCLUDE_FLAG) $(BOOST_INCLUDE_FLAG) $(DEBUG) $(FINAL) $(OPT) $(EXTRA_OPT) - -all: example1 example2 - -example1: example1.cpp - $(CXX) $(CXXFLAGS) -o $@ $< $(LIB_FLAGS) - -example2: example2.cpp - $(CXX) $(CXXFLAGS) -o $@ $< $(LIB_FLAGS) - - -.PHONY: clean - -clean: - rm -f example1 example2 -
--- a/armadillo-2.4.4/include/armadillo_bits/config.hpp Wed Jun 12 12:56:34 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) -// Copyright (C) 2008-2012 Conrad Sanderson -// -// This file is part of the Armadillo C++ library. -// It is provided without any warranty of fitness -// for any purpose. You can redistribute this file -// and/or modify it under the terms of the GNU -// Lesser General Public License (LGPL) as published -// by the Free Software Foundation, either version 3 -// of the License or (at your option) any later version. -// (see http://www.opensource.org/licenses for more info) - - - -// #define ARMA_64BIT_WORD -//// Uncomment the above line if you require matrices/vectors capable of holding more than 4 billion elements. -//// Your machine and compiler must have support for 64 bit integers (eg. via "long" or "long long") - -// #define ARMA_USE_CXX11 -//// Uncomment the above line if you have a C++ compiler that supports the C++11 standard -//// This will enable additional features, such as use of initialiser lists - -#if !defined(ARMA_USE_LAPACK) -#define ARMA_USE_LAPACK -//// Uncomment the above line if you have LAPACK or a fast replacement for LAPACK, -//// such as Intel's MKL, AMD's ACML, or the Accelerate framework. -//// LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse. -#endif - -#if !defined(ARMA_USE_BLAS) -#define ARMA_USE_BLAS -//// Uncomment the above line if you have BLAS or a fast replacement for BLAS, -//// such as GotoBLAS, Intel's MKL, AMD's ACML, or the Accelerate framework. -//// BLAS is used for matrix multiplication. -//// Without BLAS, matrix multiplication will still work, but might be slower. -#endif - -// #define ARMA_BLAS_LONG -//// Uncomment the above line if your BLAS and LAPACK libraries use "long" instead of "int" - -// #define ARMA_BLAS_LONG_LONG -//// Uncomment the above line if your BLAS and LAPACK libraries use "long long" instead of "int" - -#define ARMA_BLAS_UNDERSCORE -//// Uncomment the above line if your BLAS and LAPACK libraries have function names with a trailing underscore. -//// Conversely, comment it out if the function names don't have a trailing underscore. - -// #define ARMA_BLAS_CAPITALS -//// Uncomment the above line if your BLAS and LAPACK libraries have capitalised function names (eg. ACML on 64-bit Windows) - -#if !defined(ARMA_MAT_PREALLOC) - #define ARMA_MAT_PREALLOC 16 -#endif -//// This is the number of preallocated elements used by matrices and vectors; -//// it must be an integer that is at least 1. -//// If you mainly use lots of very small vectors (eg. <= 4 elements), -//// change the number to the size of your vectors. - -// #define ARMA_USE_TBB_ALLOC -//// Uncomment the above line if you want to use Intel TBB scalable_malloc() and scalable_free() instead of standard new[] and delete[] - -// #define ARMA_USE_ATLAS -// #define ARMA_ATLAS_INCLUDE_DIR /usr/include/ -//// If you're using ATLAS and the compiler can't find cblas.h and/or clapack.h -//// uncomment the above define and specify the appropriate include directory. -//// Make sure the directory has a trailing / - -// #define ARMA_USE_BOOST -// #define ARMA_USE_BOOST_DATE -// #define ARMA_USE_WRAPPER - -#if !defined(ARMA_DEFAULT_OSTREAM) - #define ARMA_DEFAULT_OSTREAM std::cout -#endif - -#define ARMA_PRINT_LOGIC_ERRORS -#define ARMA_PRINT_RUNTIME_ERRORS - -// #define ARMA_HAVE_STD_ISFINITE -// #define ARMA_HAVE_STD_ISINF -// #define ARMA_HAVE_STD_ISNAN -// #define ARMA_HAVE_STD_SNPRINTF - -// #define ARMA_HAVE_LOG1P -// #define ARMA_HAVE_GETTIMEOFDAY - -// #define ARMA_EXTRA_DEBUG -// #define ARMA_NO_DEBUG - -#if defined(ARMA_DONT_USE_ATLAS) - #undef ARMA_USE_ATLAS - #undef ARMA_ATLAS_INCLUDE_DIR -#endif - -#if defined(ARMA_DONT_USE_LAPACK) - #undef ARMA_USE_LAPACK -#endif - -#if defined(ARMA_DONT_USE_BLAS) - #undef ARMA_USE_BLAS -#endif - -#if defined(ARMA_DONT_PRINT_LOGIC_ERRORS) - #undef ARMA_PRINT_LOGIC_ERRORS -#endif - -#if defined(ARMA_DONT_PRINT_RUNTIME_ERRORS) - #undef ARMA_PRINT_RUNTIME_ERRORS -#endif
--- a/songparts/Makefile.osx Wed Jun 12 12:56:34 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - -CFLAGS := -O3 -ftree-vectorize -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.7.sdk -arch i386 -arch x86_64 -I../armadillo-2.4.4/include -I../vamp-plugin-sdk -I/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/ -DUSE_PTHREADS - -CXXFLAGS := $(CFLAGS) - -LDFLAGS := -isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.5 -arch i386 -arch x86_64 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -dynamiclib -framework Accelerate -lpthread -install_name qm-vamp-plugins.dylib - -PLUGIN_EXT := .dylib - -include build/general/Makefile.inc -
--- a/songparts/Makefile_ORIGINAL.osx Wed Jun 12 12:56:34 2013 +0100 +++ b/songparts/Makefile_ORIGINAL.osx Wed Jun 12 19:23:03 2013 +0100 @@ -1,5 +1,5 @@ -CFLAGS := -O3 -ftree-vectorize -isysroot /Developer/SDKs/MacOSX10.7.sdk -arch i386 -arch x86_64 -I../vamp-plugin-sdk -I/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/ -DUSE_PTHREADS +CFLAGS := -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -I../vamp-plugin-sdk -I/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/ -DUSE_PTHREADS CXXFLAGS := $(CFLAGS)
--- a/songparts/SongParts.cpp Wed Jun 12 12:56:34 2013 +0100 +++ b/songparts/SongParts.cpp Wed Jun 12 19:23:03 2013 +0100 @@ -422,15 +422,15 @@ ParameterDescriptor desc; - desc.identifier = "bpb"; - desc.name = "Beats per Bar"; - desc.description = "The number of beats in each bar"; - desc.minValue = 2; - desc.maxValue = 16; - desc.defaultValue = 4; - desc.isQuantized = true; - desc.quantizeStep = 1; - list.push_back(desc); + // desc.identifier = "bpb"; + // desc.name = "Beats per Bar"; + // desc.description = "The number of beats in each bar"; + // desc.minValue = 2; + // desc.maxValue = 16; + // desc.defaultValue = 4; + // desc.isQuantized = true; + // desc.quantizeStep = 1; + // list.push_back(desc); return list; } @@ -767,6 +767,19 @@ } FeatureSet masterFeatureset = beatTrack(); + Vamp::RealTime last_beattime = masterFeatureset[m_beatOutputNumber][masterFeatureset[m_beatOutputNumber].size()-1].timestamp; + masterFeatureset[m_beatOutputNumber].clear(); + Vamp::RealTime beattime = Vamp::RealTime::fromSeconds(1.0); + while (beattime < last_beattime) + { + Feature beatfeature; + beatfeature.hasTimestamp = true; + beatfeature.timestamp = beattime; + masterFeatureset[m_beatOutputNumber].push_back(beatfeature); + beattime = beattime + Vamp::RealTime::fromSeconds(0.5); + } + + FeatureList chromaList = chromaFeatures(); for (int i = 0; i < (int)chromaList.size(); ++i) @@ -1098,9 +1111,10 @@ FeatureList fwQchromagram; // frame-wise beat-quantised chroma FeatureList bwQchromagram; // beat-wise beat-quantised chroma - - int nChromaFrame = (int) chromagram.size(); - int nBeat = (int) beats.size(); + + + size_t nChromaFrame = chromagram.size(); + size_t nBeat = beats.size(); if (nBeat == 0 && nChromaFrame == 0) return returnVector; @@ -1112,7 +1126,7 @@ int currBeatCount = -1; // start before first beat int framesInBeat = 0; - for (int iChroma = 0; iChroma < nChromaFrame; ++iChroma) + for (size_t iChroma = 0; iChroma < nChromaFrame; ++iChroma) { Vamp::RealTime frameTimestamp = chromagram[iChroma].timestamp; Vamp::RealTime newBeatTimestamp; @@ -1163,6 +1177,8 @@ return returnVector; } + + /* -------------------------------- */ /* ------ Support Functions ------ */ /* -------------------------------- */ @@ -1170,6 +1186,7 @@ // one-dimesion median filter arma::vec medfilt1(arma::vec v, int medfilt_length) { + // TODO: check if this works with odd and even medfilt_length !!! int halfWin = medfilt_length/2; // result vector @@ -1181,7 +1198,14 @@ for (int i=medfilt_length/2; i < medfilt_length/2+(int)v.size(); ++ i) { padV(i) = v(i-medfilt_length/2); - } + } + + // the above loop leaves the boundaries at 0, + // the two loops below fill them with the start or end values of v at start and end + for (int i = 0; i < halfWin; ++i) padV(i) = v(0); + for (int i = halfWin+(int)v.size(); i < (int)v.size()+2*halfWin; ++i) padV(i) = v(v.size()-1); + + // Median filter arma::vec win = arma::zeros<arma::vec>(medfilt_length); @@ -1315,11 +1339,12 @@ newpartind++; Part newPart; - newPart.letter = 'n'; + newPart.letter = 'N'; std::stringstream out; out << newpartind+1; newPart.letter.append(out.str()); - newPart.value = 20+newpartind+1; + // newPart.value = 20+newpartind+1; + newPart.value = 0; newPart.n = 1; newPart.indices.push_back(indices[iInd]); newPart.level = 0; @@ -1348,9 +1373,9 @@ /* ------ Parameters ------ */ double thresh_beat = 0.85; double thresh_seg = 0.80; - int medfilt_length = 5; + int medfilt_length = 5; int minlength = 28; - int maxlength = 128; + int maxlength = 2*128; double quantilePerc = 0.1; /* ------------------------ */ @@ -1388,13 +1413,13 @@ for (int i = 0; i < nBeat; ++ i) for (int j = 0; j < nFeatValues/2; ++ j) { - featVal(i,j) = (quantisedChromagram[i].values[j]+quantisedChromagram[i].values[j+12]) * 0.8; + featVal(i,j) = 0.8 * quantisedChromagram[i].values[j] + quantisedChromagram[i].values[j+12]; // bass attenuated } // Set to arbitrary value to feature vectors with low std arma::mat a = stddev(featVal,1,1); - // Feature Colleration Matrix + // Feature Correlation Matrix arma::mat simmat0 = 1-arma::cor(arma::trans(featVal)); @@ -1455,14 +1480,14 @@ arma::vec partlengths = zeros<arma::vec>(nPartlengths); for (int i = 0; i < nPartlengths; ++ i) - partlengths(i) = (i*4)+ minlength; + partlengths(i) = (i*4) + minlength; // initialise arrays arma::cube simArray = zeros<arma::cube>(nBeat,nBeat,nPartlengths); arma::cube decisionArray2 = zeros<arma::cube>(nBeat,nBeat,nPartlengths); - //for (int iLength = 0; iLength < nPartlengths; ++ iLength) - for (int iLength = 0; iLength < 20; ++ iLength) + for (int iLength = 0; iLength < nPartlengths; ++ iLength) + // for (int iLength = 0; iLength < 20; ++ iLength) { int len = partlengths(iLength); int nUsedBeat = nBeat - len + 1; // number of potential rep beginnings: they can't overlap at the end of the song