Mercurial > hg > qm-vamp-plugins
changeset 178:f96ea0e4b475
Fix compiler warnings with -Wall -Wextra
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 28 Sep 2015 12:33:17 +0100 |
parents | a83a81ed1303 |
children | f302170c720b |
files | build/linux/Makefile.linux64 plugins/AdaptiveSpectrogram.cpp plugins/BarBeatTrack.cpp plugins/BeatTrack.cpp plugins/ChromagramPlugin.cpp plugins/DWT.cpp plugins/DWT.h plugins/MFCCPlugin.cpp plugins/SegmenterPlugin.cpp plugins/SimilarityPlugin.cpp plugins/SimilarityPlugin.h plugins/TonalChangeDetect.cpp plugins/Transcription.cpp plugins/Transcription.h |
diffstat | 14 files changed, 577 insertions(+), 590 deletions(-) [+] |
line wrap: on
line diff
--- a/build/linux/Makefile.linux64 Tue Sep 08 17:32:03 2015 +0100 +++ b/build/linux/Makefile.linux64 Mon Sep 28 12:33:17 2015 +0100 @@ -1,6 +1,6 @@ -CFLAGS += -DNDEBUG -O3 -fno-exceptions -fPIC -ffast-math -msse -msse2 -mfpmath=sse -ftree-vectorize -DUSE_PTHREADS -#CFLAGS += -DDEBUG -g -fno-exceptions -fPIC -ffast-math -DUSE_PTHREADS +#CFLAGS += -DNDEBUG -O3 -fno-exceptions -fPIC -ffast-math -msse -msse2 -mfpmath=sse -ftree-vectorize -DUSE_PTHREADS +CFLAGS += -DDEBUG -g -fno-exceptions -Wall -Wextra -Werror -fPIC -ffast-math -DUSE_PTHREADS CXXFLAGS += $(CFLAGS)
--- a/plugins/AdaptiveSpectrogram.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/AdaptiveSpectrogram.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -39,17 +39,17 @@ m_n(2), m_coarse(false), m_threaded(true), - m_threadsInUse(false), m_decFactor(1), + m_buffer(0), m_buflen(0), - m_buffer(0), - m_decimator(0) + m_decimator(0), + m_threadsInUse(false) { } AdaptiveSpectrogram::~AdaptiveSpectrogram() { - for (int i = 0; i < m_cutThreads.size(); ++i) { + for (int i = 0; i < int(m_cutThreads.size()); ++i) { delete m_cutThreads[i]; } m_cutThreads.clear(); @@ -289,7 +289,7 @@ d.sampleRate = m_inputSampleRate / (m_decFactor * ((2 << m_w) / 2)); d.hasDuration = false; char name[20]; - for (int i = 0; i < d.binCount; ++i) { + for (int i = 0; i < int(d.binCount); ++i) { float freq = (m_inputSampleRate / (m_decFactor * (d.binCount * 2)) * (i + 1)); // no DC bin sprintf(name, "%.1f Hz", freq); d.binNames.push_back(name); @@ -307,7 +307,7 @@ } AdaptiveSpectrogram::FeatureSet -AdaptiveSpectrogram::process(const float *const *inputBuffers, RealTime ts) +AdaptiveSpectrogram::process(const float *const *inputBuffers, RealTime) { // framing: shift and write the new data to right half for (int i = 0; i < m_buflen/2; ++i) { @@ -392,7 +392,7 @@ cutting->erase(); - for (int i = 0; i < rmat.size(); ++i) { + for (int i = 0; i < int(rmat.size()); ++i) { Feature f; f.hasTimestamp = false; f.values = rmat[i];
--- a/plugins/BarBeatTrack.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/BarBeatTrack.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -434,11 +434,11 @@ if (beat == m_bpb) beat = 0; } - for (size_t i = 0; i < beats.size(); ++i) { + for (int i = 0; i < int(beats.size()); ++i) { - size_t frame = beats[i] * m_d->dfConfig.stepSize; + size_t frame = size_t(beats[i]) * m_d->dfConfig.stepSize; - if (dbi < downbeats.size() && i == downbeats[dbi]) { + if (dbi < int(downbeats.size()) && i == downbeats[dbi]) { beat = 0; ++bar; ++dbi; @@ -452,19 +452,19 @@ // 1 -> bars // 2 -> beat counter function - Feature feature; - feature.hasTimestamp = true; - feature.timestamp = m_d->origin + Vamp::RealTime::frame2RealTime - (frame, lrintf(m_inputSampleRate)); + Feature feature; + feature.hasTimestamp = true; + feature.timestamp = m_d->origin + Vamp::RealTime::frame2RealTime + (frame, lrintf(m_inputSampleRate)); sprintf(label, "%d", beat + 1); feature.label = label; - returnFeatures[0].push_back(feature); // labelled beats + returnFeatures[0].push_back(feature); // labelled beats feature.values.push_back(beat + 1); returnFeatures[2].push_back(feature); // beat function - if (i > 0 && i <= beatsd.size()) { + if (i > 0 && i <= int(beatsd.size())) { feature.values.clear(); feature.values.push_back(beatsd[i-1]); feature.label = "";
--- a/plugins/BeatTrack.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/BeatTrack.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -57,12 +57,12 @@ m_d(0), m_method(METHOD_NEW), m_dfType(DF_COMPLEXSD), - m_whiten(false), m_alpha(0.9), // MEPD new exposed parameter for beat tracker, default value = 0.9 (as old version) m_tightness(4.), m_inputtempo(120.), // MEPD new exposed parameter for beat tracker, default value = 120. (as old version) - m_constraintempo(false) // MEPD new exposed parameter for beat tracker, default value = false (as old version) + m_constraintempo(false), // MEPD new exposed parameter for beat tracker, default value = false (as old version) // calling the beat tracker with these default parameters will give the same output as the previous existing version + m_whiten(false) { }
--- a/plugins/ChromagramPlugin.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/ChromagramPlugin.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -330,7 +330,7 @@ ChromagramPlugin::FeatureSet ChromagramPlugin::process(const float *const *inputBuffers, - Vamp::RealTime timestamp) + Vamp::RealTime ) { if (!m_chromagram) { cerr << "ERROR: ChromagramPlugin::process: " @@ -371,7 +371,7 @@ Feature feature; feature.hasTimestamp = false; - for (size_t i = 0; i < m_config.BPO; ++i) { + for (int i = 0; i < m_config.BPO; ++i) { double value = output[i]; /* if (printThis) { @@ -402,7 +402,7 @@ feature.hasTimestamp = true; feature.timestamp = Vamp::RealTime::zeroTime; - for (size_t i = 0; i < m_config.BPO; ++i) { + for (int i = 0; i < m_config.BPO; ++i) { double v = m_binsums[i]; if (m_count > 0) v /= m_count; feature.values.push_back(v);
--- a/plugins/DWT.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/DWT.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -1,448 +1,448 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - QM Vamp Plugin Set - - Centre for Digital Music, Queen Mary, University of London. - This file copyright 2009 Thomas Wilmering. +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + QM Vamp Plugin Set + + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2009 Thomas Wilmering. This program 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 2 of the License, or (at your option) any later version. See the file - COPYING included with this distribution for more information. -*/ - -#include "DWT.h" - -#include <cmath> - -using std::string; -using std::vector; -using std::cerr; -using std::endl; - -DWT::DWT(float inputSampleRate) : - Plugin(inputSampleRate), - m_stepSize(0), - m_blockSize(0) -{ - m_scales = 10; - m_flength = 0; - m_wavelet = Wavelet::Haar; - m_threshold = 0; - m_absolute = 0; -} - -DWT::~DWT() -{ -} - -string -DWT::getIdentifier() const -{ - return "qm-dwt"; -} - -string -DWT::getName() const -{ - return "Discrete Wavelet Transform"; -} - -string -DWT::getDescription() const -{ - return "Visualisation by scalogram"; -} - -string -DWT::getMaker() const -{ - return "Queen Mary, University of London"; -} - -int -DWT::getPluginVersion() const -{ - return 1; -} - -string -DWT::getCopyright() const -{ - return "Plugin by Thomas Wilmering. Copyright (c) 2009 Thomas Wilmering and QMUL - All Rights Reserved"; -} - -size_t -DWT::getPreferredBlockSize() const -{ - size_t s = (1 << m_scales); - while (s < 1024) s *= 2; - return s; -} - -size_t -DWT::getPreferredStepSize() const -{ - return 0; -} - -bool -DWT::initialise(size_t channels, size_t stepSize, size_t blockSize) -{ - if (channels < getMinChannelCount() || - channels > getMaxChannelCount()) return false; - - if ((1 << m_scales) > blockSize) { - std::cerr << "DWT::initialise: ERROR: Block size must be at least 2^scales (specified block size " << blockSize << " < " << (1 << m_scales) << ")" << std::endl; - return false; - } - - m_stepSize = stepSize; - m_blockSize = blockSize; - - Wavelet::createDecompositionFilters(m_wavelet, m_lpd, m_hpd); - - m_flength = m_lpd.size(); // or m_hpd.size() - - m_samplePass.resize(m_scales); // resize buffer for samples to pass to next block - - for (int i=0; i<m_scales; ++i) { - m_samplePass[i].resize(m_flength-2, 0.0); - } - - return true; -} - -void -DWT::reset() -{ - m_samplePass.clear(); - - m_samplePass.resize(m_scales); - - for (int i=0; i<m_scales; ++i) { - m_samplePass[i].resize(m_flength-2, 0.0); - } -} - -DWT::OutputList -DWT::getOutputDescriptors() const -{ - OutputList list; - - OutputDescriptor sg; - sg.identifier = "wcoeff"; - sg.name = "Wavelet Coefficients"; - sg.description = "Wavelet coefficients"; - sg.unit = ""; - sg.hasFixedBinCount = true; // depends on block size - sg.binCount = m_scales; // number of scales - sg.hasKnownExtents = false; - sg.isQuantized = false; - sg.sampleType = OutputDescriptor::FixedSampleRate; - sg.sampleRate = .5 * m_inputSampleRate; - - list.push_back(sg); - - return list; -} - - -DWT::ParameterList -DWT::getParameterDescriptors() const -{ - ParameterList list; - - ParameterDescriptor d; - d.identifier = "scales"; - d.name = "Scales"; - d.description = "Scale depth"; - d.unit = ""; - d.minValue = 1.0f; - d.maxValue = 16.0f; - d.defaultValue = 10.0f; - d.isQuantized = true; - d.quantizeStep = 1.0f; - list.push_back(d); - - d.identifier = "wavelet"; - d.name = "Wavelet"; - d.description = "Wavelet type to use"; - d.unit = ""; - d.minValue = 0.f; - d.maxValue = int(Wavelet::LastType); - d.defaultValue = int(Wavelet::Haar); - d.isQuantized = true; - d.quantizeStep = 1.0f; - - for (int i = 0; i <= int(Wavelet::LastType); ++i) { - d.valueNames.push_back(Wavelet::getWaveletName(Wavelet::Type(i))); - } - list.push_back(d); - d.valueNames.clear(); - - d.identifier = "threshold"; - d.name = "Threshold"; - d.description = "Wavelet coefficient threshold"; - d.unit = ""; - d.minValue = 0.0f; - d.maxValue = 0.01f; - d.defaultValue = 0.0f; - d.isQuantized = false; - list.push_back(d); - - d.identifier = "absolute"; - d.name = "Absolute values"; - d.description = "Return absolute values"; - d.unit = ""; - d.minValue = 0.0f; - d.maxValue = 1.00f; - d.defaultValue = 0.0f; - d.isQuantized = true; - d.quantizeStep = 1.0f; - list.push_back(d); - - return list; -} - -void DWT::setParameter(std::string paramid, float newval) -{ - if (paramid == "scales") { - m_scales = newval; - } - else if (paramid == "wavelet") { - m_wavelet = (Wavelet::Type)(int(newval + 0.1)); - } - else if (paramid == "threshold") { - m_threshold = newval; - } - else if (paramid == "absolute") { - m_absolute = newval; - } -} - -float DWT::getParameter(std::string paramid) const -{ - if (paramid == "scales") { - return m_scales; - } - else if (paramid == "wavelet") { - return int(m_wavelet); - } - else if (paramid == "threshold") { - return m_threshold; - } - else if (paramid == "absolute") { - return m_absolute; - } - - return 0.0f; -} - - -DWT::FeatureSet -DWT::process(const float *const *inputBuffers, - Vamp::RealTime) -{ - FeatureSet fs; - - if (m_blockSize == 0) { - cerr << "ERROR: DWT::process: Not initialised" << endl; - return fs; - } - - int s = m_scales; - int b = m_blockSize; - int b_init = b; - - if ((1 << s) > b) b = 1 << s; // correct blocksize if smaller than 2^(max scale) - -//-------------------------------------------------------------------------------------------------- - - float tempDet; - float aTempDet; - int outloc; - int halfblocksize = int(.5 * b); - int fbufloc; - int fbufloc2; - - vector< vector<float> > wCoefficients(m_scales); // result - vector<float> tempAprx(halfblocksize,0.0); // approximation - vector<float> fbuf(b+m_flength-2,0.0); // input buffer - - for (int n=m_flength-2; n<b+m_flength-2; n++) // copy input buffer to dwt input - fbuf[n] = inputBuffers[0][n-m_flength+2]; - - for (int scale=0; scale<m_scales; ++scale) // do for each scale - { - for (int n=0; n<m_flength-2; ++n) // get samples from previous block - fbuf[n] = m_samplePass[scale][n]; - - - if ((m_flength-2)<b) // pass samples to next block - for (int n=0; n<m_flength-2; ++n) - m_samplePass[scale][n] = fbuf[b+n]; - else { - for (int n=0; n<b; ++n) // if number of samples to pass > blocksize - m_samplePass[scale].push_back(fbuf[m_flength-2+n]); - m_samplePass[scale].erase (m_samplePass[scale].begin(),m_samplePass[scale].begin()+b); - } - - for (int n=0; n<halfblocksize; ++n) { // do for every other sample of the input buffer - tempDet = 0; - fbufloc = 2*n+m_flength-1; - for (int m=0; m<m_flength; ++m) { // Convolve the sample with filter coefficients - fbufloc2 = fbufloc - m; - tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation - tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail - } - - aTempDet = fabs(tempDet); - if (m_absolute == 1) tempDet = aTempDet; - - - if (aTempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale - wCoefficients[scale].push_back(tempDet); - } - - if (scale+1<m_scales) { // prepare variables for next scale - b = b >> 1; // the approximation in tmpfwd is stored as - halfblocksize = halfblocksize >> 1; // input for next level - - for (int n=m_flength-2; n<b+m_flength-2; n++) // copy approximation to dwt input - fbuf[n] = tempAprx[n-m_flength+2]; - - //vector<float>(b+m_flength-2).swap(fbuf); - vector<float>(halfblocksize).swap(tempAprx); // set new size with zeros - } - } - - -//----------------------------------------------------------------------------------------- - - halfblocksize = int(.5 * b_init); - - for (int m = 0; m<halfblocksize; m++) { - - Feature feature; - feature.hasTimestamp = false; - - for (int j = 0; j < s; j++) { - outloc = m / (1 << j); // This one pushes a single result bin - // onto the top of a feature column - feature.values.push_back(wCoefficients[j][outloc]); // each coefficient on higher scales need - } // to be copied multiple times to feature columns - fs[0].push_back(feature); - } - return fs; -} - - - -DWT::FeatureSet -DWT::getRemainingFeatures() -{ - int s = m_scales; - - FeatureSet fs; - -/* - int b = 1; - while (b<((m_flength-1) * (1 << s))) { //set blocksize to tail length - b= (b << 1); - } - int b_init = b; - -*/ - int b = m_blockSize; - int b_init = b; - int tailIterations = int(((m_flength-1) * (1 << s)) / b) + 1; // number of iterations for tail - - - for(int m=0; m<tailIterations; ++m) - { - - b = b_init; - - //------------------------------------------------------------------------------------------- - float tempDet; - float aTempDet; - int outloc; - int halfblocksize = int(.5 * b); - int fbufloc; - int fbufloc2; - int len = m_flength; - - vector< vector<float> > wCoefficients(m_scales); // result - vector<float> tempAprx(halfblocksize,0.0); // approximation - vector<float> fbuf(b+len-2,0.0); // input buffer - - //for (int n=len-2; n<b+len-2; n++) // copy input buffer to dwt input - // fbuf[n] = 0; //inputBuffers[0][n-len+2]; - - for (int scale=0; scale<m_scales; ++scale) // do for each scale - { - for (int n=0; n<len-2; ++n) // get samples from previous block - fbuf[n] = m_samplePass[scale][n]; - - - if ((len-2)<b) // pass samples to next block - for (int n=0; n<len-2; ++n) - m_samplePass[scale][n] = fbuf[b+n]; - else { - for (int n=0; n<b; ++n) // if number of samples to pass > blocksize - m_samplePass[scale].push_back(fbuf[len-2+n]); - m_samplePass[scale].erase (m_samplePass[scale].begin(),m_samplePass[scale].begin()+b); - } - - for (int n=0; n<halfblocksize; ++n) { // do for every other sample of the input buffer - tempDet = 0; - fbufloc = 2*n+len-1; - for (int m=0; m<len; ++m) { // Convolve the sample with filter coefficients - fbufloc2 = fbufloc - m; - tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation - tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail - } - - aTempDet = fabs(tempDet); - if (m_absolute == 1) tempDet = aTempDet; - if (aTempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale - wCoefficients[scale].push_back(tempDet); - } - - if (scale+1<m_scales) { // prepare variables for next scale - b = b >> 1; // the approximation in tmpfwd is stored as - halfblocksize = halfblocksize >> 1; // input for next level - - for (int n=len-2; n<b+len-2; n++) // copy approximation to dwt input - fbuf[n] = tempAprx[n-len+2]; - - //vector<float>(b+len-2).swap(fbuf); - vector<float>(halfblocksize).swap(tempAprx); // set new size with zeros - } - - } - -//----------------------------------------------------------------------------------------- - - halfblocksize = int(.5 * b_init + 0.1); - - for (int m = 0; m<halfblocksize; m++) { - - Feature feature; - feature.hasTimestamp = false; - - for (int j = 0; j < s; j++) { - outloc = m / (1 << j); // This one pushes a single result bin - // onto the top of a feature column - feature.values.push_back(wCoefficients[j][outloc]); // each coefficient on higher scales need - } // to be copied multiple times to feature columns - fs[0].push_back(feature); - } - } - return fs; - -} - + COPYING included with this distribution for more information. +*/ + +#include "DWT.h" + +#include <cmath> + +using std::string; +using std::vector; +using std::cerr; +using std::endl; + +DWT::DWT(float inputSampleRate) : + Plugin(inputSampleRate), + m_stepSize(0), + m_blockSize(0) +{ + m_scales = 10; + m_flength = 0; + m_wavelet = Wavelet::Haar; + m_threshold = 0; + m_absolute = 0; +} + +DWT::~DWT() +{ +} + +string +DWT::getIdentifier() const +{ + return "qm-dwt"; +} + +string +DWT::getName() const +{ + return "Discrete Wavelet Transform"; +} + +string +DWT::getDescription() const +{ + return "Visualisation by scalogram"; +} + +string +DWT::getMaker() const +{ + return "Queen Mary, University of London"; +} + +int +DWT::getPluginVersion() const +{ + return 1; +} + +string +DWT::getCopyright() const +{ + return "Plugin by Thomas Wilmering. Copyright (c) 2009 Thomas Wilmering and QMUL - All Rights Reserved"; +} + +size_t +DWT::getPreferredBlockSize() const +{ + size_t s = (1 << m_scales); + while (s < 1024) s *= 2; + return s; +} + +size_t +DWT::getPreferredStepSize() const +{ + return 0; +} + +bool +DWT::initialise(size_t channels, size_t stepSize, size_t blockSize) +{ + if (channels < getMinChannelCount() || + channels > getMaxChannelCount()) return false; + + if ((1U << m_scales) > blockSize) { + std::cerr << "DWT::initialise: ERROR: Block size must be at least 2^scales (specified block size " << blockSize << " < " << (1 << m_scales) << ")" << std::endl; + return false; + } + + m_stepSize = stepSize; + m_blockSize = blockSize; + + Wavelet::createDecompositionFilters(m_wavelet, m_lpd, m_hpd); + + m_flength = m_lpd.size(); // or m_hpd.size() + + m_samplePass.resize(m_scales); // resize buffer for samples to pass to next block + + for (int i=0; i<m_scales; ++i) { + m_samplePass[i].resize(m_flength-2, 0.0); + } + + return true; +} + +void +DWT::reset() +{ + m_samplePass.clear(); + + m_samplePass.resize(m_scales); + + for (int i=0; i<m_scales; ++i) { + m_samplePass[i].resize(m_flength-2, 0.0); + } +} + +DWT::OutputList +DWT::getOutputDescriptors() const +{ + OutputList list; + + OutputDescriptor sg; + sg.identifier = "wcoeff"; + sg.name = "Wavelet Coefficients"; + sg.description = "Wavelet coefficients"; + sg.unit = ""; + sg.hasFixedBinCount = true; // depends on block size + sg.binCount = m_scales; // number of scales + sg.hasKnownExtents = false; + sg.isQuantized = false; + sg.sampleType = OutputDescriptor::FixedSampleRate; + sg.sampleRate = .5 * m_inputSampleRate; + + list.push_back(sg); + + return list; +} + + +DWT::ParameterList +DWT::getParameterDescriptors() const +{ + ParameterList list; + + ParameterDescriptor d; + d.identifier = "scales"; + d.name = "Scales"; + d.description = "Scale depth"; + d.unit = ""; + d.minValue = 1.0f; + d.maxValue = 16.0f; + d.defaultValue = 10.0f; + d.isQuantized = true; + d.quantizeStep = 1.0f; + list.push_back(d); + + d.identifier = "wavelet"; + d.name = "Wavelet"; + d.description = "Wavelet type to use"; + d.unit = ""; + d.minValue = 0.f; + d.maxValue = int(Wavelet::LastType); + d.defaultValue = int(Wavelet::Haar); + d.isQuantized = true; + d.quantizeStep = 1.0f; + + for (int i = 0; i <= int(Wavelet::LastType); ++i) { + d.valueNames.push_back(Wavelet::getWaveletName(Wavelet::Type(i))); + } + list.push_back(d); + d.valueNames.clear(); + + d.identifier = "threshold"; + d.name = "Threshold"; + d.description = "Wavelet coefficient threshold"; + d.unit = ""; + d.minValue = 0.0f; + d.maxValue = 0.01f; + d.defaultValue = 0.0f; + d.isQuantized = false; + list.push_back(d); + + d.identifier = "absolute"; + d.name = "Absolute values"; + d.description = "Return absolute values"; + d.unit = ""; + d.minValue = 0.0f; + d.maxValue = 1.00f; + d.defaultValue = 0.0f; + d.isQuantized = true; + d.quantizeStep = 1.0f; + list.push_back(d); + + return list; +} + +void DWT::setParameter(std::string paramid, float newval) +{ + if (paramid == "scales") { + m_scales = newval; + } + else if (paramid == "wavelet") { + m_wavelet = (Wavelet::Type)(int(newval + 0.1)); + } + else if (paramid == "threshold") { + m_threshold = newval; + } + else if (paramid == "absolute") { + m_absolute = newval; + } +} + +float DWT::getParameter(std::string paramid) const +{ + if (paramid == "scales") { + return m_scales; + } + else if (paramid == "wavelet") { + return int(m_wavelet); + } + else if (paramid == "threshold") { + return m_threshold; + } + else if (paramid == "absolute") { + return m_absolute; + } + + return 0.0f; +} + + +DWT::FeatureSet +DWT::process(const float *const *inputBuffers, + Vamp::RealTime) +{ + FeatureSet fs; + + if (m_blockSize == 0) { + cerr << "ERROR: DWT::process: Not initialised" << endl; + return fs; + } + + int s = m_scales; + int b = m_blockSize; + int b_init = b; + + if ((1 << s) > b) b = 1 << s; // correct blocksize if smaller than 2^(max scale) + +//-------------------------------------------------------------------------------------------------- + + float tempDet; + float aTempDet; + int outloc; + int halfblocksize = int(.5 * b); + int fbufloc; + int fbufloc2; + + vector< vector<float> > wCoefficients(m_scales); // result + vector<float> tempAprx(halfblocksize,0.0); // approximation + vector<float> fbuf(b+m_flength-2,0.0); // input buffer + + for (int n=m_flength-2; n<b+m_flength-2; n++) // copy input buffer to dwt input + fbuf[n] = inputBuffers[0][n-m_flength+2]; + + for (int scale=0; scale<m_scales; ++scale) // do for each scale + { + for (int n=0; n<m_flength-2; ++n) // get samples from previous block + fbuf[n] = m_samplePass[scale][n]; + + + if ((m_flength-2)<b) // pass samples to next block + for (int n=0; n<m_flength-2; ++n) + m_samplePass[scale][n] = fbuf[b+n]; + else { + for (int n=0; n<b; ++n) // if number of samples to pass > blocksize + m_samplePass[scale].push_back(fbuf[m_flength-2+n]); + m_samplePass[scale].erase (m_samplePass[scale].begin(),m_samplePass[scale].begin()+b); + } + + for (int n=0; n<halfblocksize; ++n) { // do for every other sample of the input buffer + tempDet = 0; + fbufloc = 2*n+m_flength-1; + for (int m=0; m<m_flength; ++m) { // Convolve the sample with filter coefficients + fbufloc2 = fbufloc - m; + tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation + tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail + } + + aTempDet = fabs(tempDet); + if (m_absolute == 1) tempDet = aTempDet; + + + if (aTempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale + wCoefficients[scale].push_back(tempDet); + } + + if (scale+1<m_scales) { // prepare variables for next scale + b = b >> 1; // the approximation in tmpfwd is stored as + halfblocksize = halfblocksize >> 1; // input for next level + + for (int n=m_flength-2; n<b+m_flength-2; n++) // copy approximation to dwt input + fbuf[n] = tempAprx[n-m_flength+2]; + + //vector<float>(b+m_flength-2).swap(fbuf); + vector<float>(halfblocksize).swap(tempAprx); // set new size with zeros + } + } + + +//----------------------------------------------------------------------------------------- + + halfblocksize = int(.5 * b_init); + + for (int m = 0; m<halfblocksize; m++) { + + Feature feature; + feature.hasTimestamp = false; + + for (int j = 0; j < s; j++) { + outloc = m / (1 << j); // This one pushes a single result bin + // onto the top of a feature column + feature.values.push_back(wCoefficients[j][outloc]); // each coefficient on higher scales need + } // to be copied multiple times to feature columns + fs[0].push_back(feature); + } + return fs; +} + + + +DWT::FeatureSet +DWT::getRemainingFeatures() +{ + int s = m_scales; + + FeatureSet fs; + +/* + int b = 1; + while (b<((m_flength-1) * (1 << s))) { //set blocksize to tail length + b= (b << 1); + } + int b_init = b; + +*/ + int b = m_blockSize; + int b_init = b; + int tailIterations = int(((m_flength-1) * (1 << s)) / b) + 1; // number of iterations for tail + + + for(int m=0; m<tailIterations; ++m) + { + + b = b_init; + + //------------------------------------------------------------------------------------------- + float tempDet; + float aTempDet; + int outloc; + int halfblocksize = int(.5 * b); + int fbufloc; + int fbufloc2; + int len = m_flength; + + vector< vector<float> > wCoefficients(m_scales); // result + vector<float> tempAprx(halfblocksize,0.0); // approximation + vector<float> fbuf(b+len-2,0.0); // input buffer + + //for (int n=len-2; n<b+len-2; n++) // copy input buffer to dwt input + // fbuf[n] = 0; //inputBuffers[0][n-len+2]; + + for (int scale=0; scale<m_scales; ++scale) // do for each scale + { + for (int n=0; n<len-2; ++n) // get samples from previous block + fbuf[n] = m_samplePass[scale][n]; + + + if ((len-2)<b) // pass samples to next block + for (int n=0; n<len-2; ++n) + m_samplePass[scale][n] = fbuf[b+n]; + else { + for (int n=0; n<b; ++n) // if number of samples to pass > blocksize + m_samplePass[scale].push_back(fbuf[len-2+n]); + m_samplePass[scale].erase (m_samplePass[scale].begin(),m_samplePass[scale].begin()+b); + } + + for (int n=0; n<halfblocksize; ++n) { // do for every other sample of the input buffer + tempDet = 0; + fbufloc = 2*n+len-1; + for (int m=0; m<len; ++m) { // Convolve the sample with filter coefficients + fbufloc2 = fbufloc - m; + tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation + tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail + } + + aTempDet = fabs(tempDet); + if (m_absolute == 1) tempDet = aTempDet; + if (aTempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale + wCoefficients[scale].push_back(tempDet); + } + + if (scale+1<m_scales) { // prepare variables for next scale + b = b >> 1; // the approximation in tmpfwd is stored as + halfblocksize = halfblocksize >> 1; // input for next level + + for (int n=len-2; n<b+len-2; n++) // copy approximation to dwt input + fbuf[n] = tempAprx[n-len+2]; + + //vector<float>(b+len-2).swap(fbuf); + vector<float>(halfblocksize).swap(tempAprx); // set new size with zeros + } + + } + +//----------------------------------------------------------------------------------------- + + halfblocksize = int(.5 * b_init + 0.1); + + for (int m = 0; m<halfblocksize; m++) { + + Feature feature; + feature.hasTimestamp = false; + + for (int j = 0; j < s; j++) { + outloc = m / (1 << j); // This one pushes a single result bin + // onto the top of a feature column + feature.values.push_back(wCoefficients[j][outloc]); // each coefficient on higher scales need + } // to be copied multiple times to feature columns + fs[0].push_back(feature); + } + } + return fs; + +} +
--- a/plugins/DWT.h Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/DWT.h Mon Sep 28 12:33:17 2015 +0100 @@ -1,73 +1,73 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - QM Vamp Plugin Set - - Centre for Digital Music, Queen Mary, University of London. - This file copyright 2009 Thomas Wilmering. +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + QM Vamp Plugin Set + + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2009 Thomas Wilmering. This program 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 2 of the License, or (at your option) any later version. See the file - COPYING included with this distribution for more information. -*/ - -#ifndef _DWT_PLUGIN_H_ -#define _DWT_PLUGIN_H_ - -#include <vamp-sdk/Plugin.h> - -#include <dsp/wavelet/Wavelet.h> - -using std::vector; - -class DWT : public Vamp::Plugin -{ -public: - DWT(float inputSampleRate); - virtual ~DWT(); - - bool initialise(size_t channels, size_t stepSize, size_t blockSize); - void reset(); - - InputDomain getInputDomain() const { return TimeDomain; } - - std::string getIdentifier() const; - std::string getName() const; - std::string getDescription() const; - std::string getMaker() const; - int getPluginVersion() const; - std::string getCopyright() const; - size_t getPreferredBlockSize() const; - size_t getPreferredStepSize() const; - - OutputList getOutputDescriptors() const; - - ParameterList getParameterDescriptors() const; - float getParameter(std::string paramid) const; - void setParameter(std::string paramid, float newval); - - FeatureSet process(const float *const *inputBuffers, - Vamp::RealTime timestamp); - - FeatureSet getRemainingFeatures(); - -protected: - size_t m_stepSize; - size_t m_blockSize; - - int m_scales; - int m_flength; - Wavelet::Type m_wavelet; - float m_threshold; - float m_absolute; - - vector<float> m_lpd; - vector<float> m_hpd; - - vector< vector<float> > m_samplePass; -}; - - -#endif + COPYING included with this distribution for more information. +*/ + +#ifndef _DWT_PLUGIN_H_ +#define _DWT_PLUGIN_H_ + +#include <vamp-sdk/Plugin.h> + +#include <dsp/wavelet/Wavelet.h> + +using std::vector; + +class DWT : public Vamp::Plugin +{ +public: + DWT(float inputSampleRate); + virtual ~DWT(); + + bool initialise(size_t channels, size_t stepSize, size_t blockSize); + void reset(); + + InputDomain getInputDomain() const { return TimeDomain; } + + std::string getIdentifier() const; + std::string getName() const; + std::string getDescription() const; + std::string getMaker() const; + int getPluginVersion() const; + std::string getCopyright() const; + size_t getPreferredBlockSize() const; + size_t getPreferredStepSize() const; + + OutputList getOutputDescriptors() const; + + ParameterList getParameterDescriptors() const; + float getParameter(std::string paramid) const; + void setParameter(std::string paramid, float newval); + + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); + + FeatureSet getRemainingFeatures(); + +protected: + size_t m_stepSize; + size_t m_blockSize; + + int m_scales; + int m_flength; + Wavelet::Type m_wavelet; + float m_threshold; + float m_absolute; + + vector<float> m_lpd; + vector<float> m_hpd; + + vector< vector<float> > m_samplePass; +}; + + +#endif
--- a/plugins/MFCCPlugin.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/MFCCPlugin.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -274,7 +274,7 @@ Feature feature; feature.hasTimestamp = false; - for (size_t i = 0; i < m_bins; ++i) { + for (int i = 0; i < m_bins; ++i) { double value = output[i]; if (ISNAN(value)) value = 0.0; m_binsums[i] += value; @@ -297,7 +297,7 @@ feature.hasTimestamp = true; feature.timestamp = Vamp::RealTime::zeroTime; - for (size_t i = 0; i < m_bins; ++i) { + for (int i = 0; i < m_bins; ++i) { double v = m_binsums[i]; if (m_count > 0) v /= m_count; feature.values.push_back(v);
--- a/plugins/SegmenterPlugin.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/SegmenterPlugin.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -28,8 +28,10 @@ SegmenterPlugin::SegmenterPlugin(float inputSampleRate) : Plugin(inputSampleRate), segmenter(0), + hopsize(0), + windowsize(0), + neighbourhoodLimit(4), nSegmentTypes(10), - neighbourhoodLimit(4), featureType(feature_types(1)) { @@ -81,14 +83,14 @@ if (!segmenter) makeSegmenter(); - if (stepSize != hopsize) { + if (int(stepSize) != hopsize) { std::cerr << "SegmenterPlugin::initialise: supplied step size " << stepSize << " differs from required step size " << hopsize << std::endl; return false; } - if (blockSize != windowsize) { + if (int(blockSize) != windowsize) { std::cerr << "SegmenterPlugin::initialise: supplied block size " << blockSize << " differs from required block size " << windowsize << std::endl; @@ -282,7 +284,7 @@ { // convert float* to double* double *tempBuffer = new double[windowsize]; - for (size_t i = 0; i < windowsize; ++i) { + for (int i = 0; i < windowsize; ++i) { tempBuffer[i] = inputBuffers[0][i]; } @@ -308,7 +310,7 @@ std::map<int, int> typeMap; int nextType = 1; - for (int i = 0; i < segm.segments.size(); ++i) { + for (int i = 0; i < int(segm.segments.size()); ++i) { Segment s = segm.segments[i]; if (typeMap.find(s.type) == typeMap.end()) { typeMap[s.type] = nextType; @@ -316,7 +318,7 @@ } } - for (int i = 0; i < segm.segments.size(); ++i) { + for (int i = 0; i < int(segm.segments.size()); ++i) { Segment s = segm.segments[i]; @@ -326,7 +328,7 @@ (s.start, (int)m_inputSampleRate); feature.hasDuration = true; - if (i + 1 < segm.segments.size()) { + if (i + 1 < int(segm.segments.size())) { feature.duration = Vamp::RealTime::frame2RealTime (segm.segments[i+1].start - s.start, (int)m_inputSampleRate); } else {
--- a/plugins/SimilarityPlugin.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/SimilarityPlugin.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -507,19 +507,19 @@ void SimilarityPlugin::reset() { - for (int i = 0; i < m_values.size(); ++i) { + for (int i = 0; i < int(m_values.size()); ++i) { m_values[i].clear(); } - for (int i = 0; i < m_rhythmValues.size(); ++i) { + for (int i = 0; i < int(m_rhythmValues.size()); ++i) { m_rhythmValues[i].clear(); } - for (int i = 0; i < m_lastNonEmptyFrame.size(); ++i) { + for (int i = 0; i < int(m_lastNonEmptyFrame.size()); ++i) { m_lastNonEmptyFrame[i] = -1; } - for (int i = 0; i < m_emptyFrameCount.size(); ++i) { + for (int i = 0; i < int(m_emptyFrameCount.size()); ++i) { m_emptyFrameCount[i] = 0; } @@ -544,7 +544,7 @@ bool someRhythmFrameNeeded = false; - for (size_t c = 0; c < m_channels; ++c) { + for (int c = 0; c < m_channels; ++c) { bool empty = true; @@ -557,7 +557,7 @@ if (empty) { if (needRhythm() && ((m_frameNo % 2) == 0)) { for (int i = 0; i < m_fftSize / m_rhythmClipFrameSize; ++i) { - if (m_rhythmValues[c].size() < m_rhythmClipFrames) { + if (int(m_rhythmValues[c].size()) < m_rhythmClipFrames) { FeatureColumn mf(m_rhythmColumnSize); for (int i = 0; i < m_rhythmColumnSize; ++i) { mf[i] = 0.0; @@ -609,7 +609,7 @@ bool needRhythmFrame = true; - if (m_rhythmValues[c].size() >= m_rhythmClipFrames) { + if (int(m_rhythmValues[c].size()) >= m_rhythmClipFrames) { needRhythmFrame = false; @@ -681,7 +681,9 @@ int sz = m_lastNonEmptyFrame[i] - m_emptyFrameCount[i]; if (sz < 0) sz = 0; - if (sz >= m_values[i].size()) sz = m_values[i].size()-1; + if (sz >= int(m_values[i].size())) { + sz = int(m_values[i].size())-1; + } count = 0; for (int k = 0; k < sz; ++k) { @@ -803,7 +805,7 @@ FeatureMatrixSet bsinput(m_channels); for (int i = 0; i < m_channels; ++i) { - for (int j = 0; j < m_rhythmValues[i].size(); ++j) { + for (int j = 0; j < int(m_rhythmValues[i].size()); ++j) { bsinput[i].push_back(m_rhythmValues[i][j]); } } @@ -834,7 +836,7 @@ feature.label = labelBuffer; feature.values.clear(); - for (int j = 0; j < bs[i].size(); ++j) { + for (int j = 0; j < int(bs[i].size()); ++j) { feature.values.push_back(bs[i][j]); }
--- a/plugins/SimilarityPlugin.h Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/SimilarityPlugin.h Mon Sep 28 12:33:17 2015 +0100 @@ -82,8 +82,8 @@ int m_rhythmClipFrameSize; int m_rhythmClipFrames; int m_rhythmColumnSize; - mutable size_t m_blockSize; // before decimation - size_t m_fftSize; // after decimation + mutable int m_blockSize; // before decimation + int m_fftSize; // after decimation int m_channels; int m_processRate; int m_frameNo;
--- a/plugins/TonalChangeDetect.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/TonalChangeDetect.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -407,13 +407,11 @@ ChangeDetectionFunction df(dfc); ChangeDistance d = df.process(m_TCSGram); - - - for (int i = 0; i < d.size(); i++) + for (int i = 0; i < int(d.size()); i++) { double dCurrent = d[i]; double dPrevious = d[i > 0 ? i - 1 : i]; - double dNext = d[i < d.size()-1 ? i + 1 : i]; + double dNext = d[i < int(d.size())-1 ? i + 1 : i]; Feature feature; feature.label = "";
--- a/plugins/Transcription.cpp Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/Transcription.cpp Mon Sep 28 12:33:17 2015 +0100 @@ -351,10 +351,10 @@ if (m_Excess) return FeatureSet(); - for (size_t i = 0; i < m_blockSize;i++) { + for (int i = 0; i < m_blockSize;i++) { if (m_SampleN >= m_AllocN) { - size_t newsize = m_AllocN * 2; + int newsize = m_AllocN * 2; if (newsize < 10000) newsize = 10000; double *newbuf = (double *)realloc(m_SoundIn, newsize * sizeof(double)); if (!newbuf) { @@ -382,10 +382,9 @@ double *hello1; double *hello2; int Msec; - size_t i; - size_t j; - size_t n; - size_t count; + int i; + int j; + int n; Msec=(int)(100*m_SampleN/m_inputSampleRate); @@ -471,9 +470,7 @@ double starts[88]; for (n = 0; n < 88; ++n) starts[n] = -1.0; - int nn; for (j = 0; j <Msec; j++) { - for(n=0;n<88;n++) { @@ -536,17 +533,15 @@ void sofacomplexMex(double *y, double *z, int ncols,double StartNote,double NoteInterval1,double NoteNum,double C,double D,double SR) { - int mseconds,i,j,el,count,count2; - double Snote,NoteInterval,NoteN, BasicR; + int mseconds,i,el,count,count2; + double Snote,NoteInterval,NoteN; double *signs; - double *rwork,*buffer; + double *rwork; double freq,R,gain,gainI,gainII,coefI,coefM; double output,input,outputI,outputM; double *x; double *sum,*sum2; double power; - double temp; - //SR=44100; Snote=StartNote; @@ -813,7 +808,7 @@ } -void FindPeaks(double *In, int InLen,double *Out1,double *Out2, int db, int db2, int db3) +void FindPeaks(double *In, int InLen,double *Out1,double *Out2, int /* db */, int db2, int db3) { int i,lastout; for (i=0;i<InLen;i++) @@ -1182,7 +1177,7 @@ void PeakDetect(double *In, int InLen) { - int i,j; + int i; double *Out1; Out1=(double*)malloc(InLen*sizeof(double)); @@ -1307,21 +1302,15 @@ } -void PitchEstimation(double *In, int InLen, double *OutArray,double *OutArray2) +void PitchEstimation(double *In, int /* InLen */, double *OutArray,double *OutArray2) { double *xx,*x,*y,*y1,*PeakPitch1, *PeakPitch2,*PeakInput1, *PeakInput2; double *out,*outValue; double *output,*output1; - double notefloat,hh0,hh1,hh28; - double outM12[12]; int *outc; - int *yI; double temp; - int i,j,sumI; + int i,sumI; int Len; - int NN,NN2; - int count; - double Th; Len=1050; xx=(double*)malloc(Len*sizeof(double)); @@ -1479,16 +1468,13 @@ } - Th=30; for(i=20;i<105;i++) { if(output1[i]==1) { OutArray[i]=outc[i]+200+2; OutArray2[i]=y[outc[i]]; - } - } free(xx); // xx=(double*)malloc(Len*sizeof(double)); @@ -1633,7 +1619,6 @@ { int i; int j; - double temp; for (i=0;i<InputVLen;i++) {
--- a/plugins/Transcription.h Tue Sep 08 17:32:03 2015 +0100 +++ b/plugins/Transcription.h Mon Sep 28 12:33:17 2015 +0100 @@ -33,11 +33,11 @@ FeatureSet getRemainingFeatures(); protected: - size_t m_stepSize; - size_t m_blockSize; + int m_stepSize; + int m_blockSize; double * m_SoundIn; - size_t m_SampleN; - size_t m_AllocN; + int m_SampleN; + int m_AllocN; bool m_Excess; Vamp::RealTime m_Base; /*