From: Chris Cannam Date: Mon, 9 Jul 2012 14:10:35 +0000 (+0100) Subject: Start overhaul for (current git, presumably later v0.4.0) aubio API X-Git-Tag: hgimport~20 X-Git-Url: https://git.aubio.org/?p=vamp-aubio-plugins.git;a=commitdiff_plain;h=dcba2c85bbd9b3095913807e9e32b6fa532858aa Start overhaul for (current git, presumably later v0.4.0) aubio API --- diff --git a/Makefile b/Makefile index 358564a..f10817d 100644 --- a/Makefile +++ b/Makefile @@ -5,25 +5,23 @@ PLUGINDIR = plugins # Compile flags # -CXXFLAGS := $(CXXFLAGS) -fPIC -DNDEBUG -O2 -Wall -I. +CXXFLAGS := -I/Users/cannam/code/inst/include $(CXXFLAGS) -fPIC -DNDEBUG -O2 -Wall -I. # Libraries required for the plugins. Note that we can (and actively # want to) statically link libstdc++, because our plugin exposes only # a C API so there are no boundary compatibility problems. # -PLUGIN_LIBS = -Wl,-Bstatic -lvamp-sdk -laubio -lfftw3f -Wl,-Bdynamic +PLUGIN_LIBS = -L/Users/cannam/code/inst/lib -lvamp-sdk -laubio # Flags required to tell the compiler to make a dynamically loadable object # -PLUGIN_LDFLAGS = -shared -Wl,-Bsymbolic -static-libgcc -Wl,--version-script=vamp-plugin.map # File extension for a dynamically loadable object # -PLUGIN_EXT = .so ## For OS/X with g++: -#PLUGIN_LDFLAGS = -dynamiclib -exported_symbols_list=vamp-plugin.list -#PLUGIN_EXT = .dylib +PLUGIN_LDFLAGS = -dynamiclib -exported_symbols_list=vamp-plugin.list +PLUGIN_EXT = .dylib ### End of user-serviceable parts diff --git a/plugins/Notes.cpp b/plugins/Notes.cpp index 5c1fd3d..e593d38 100644 --- a/plugins/Notes.cpp +++ b/plugins/Notes.cpp @@ -33,10 +33,9 @@ Notes::Notes(float inputSampleRate, unsigned int apiVersion) : m_pv(0), m_peakpick(0), m_onsetdet(0), - m_onsettype(aubio_onset_complex), + m_onsettype(OnsetComplex), m_pitchdet(0), - m_pitchtype(aubio_pitch_yinfft), - m_pitchmode(aubio_pitchm_freq), + m_pitchtype(PitchYinFFT), m_threshold(0.3), m_silence(-90), m_median(6), @@ -56,8 +55,8 @@ Notes::Notes(float inputSampleRate, unsigned int apiVersion) : Notes::~Notes() { - if (m_onsetdet) aubio_onsetdetection_free(m_onsetdet); - if (m_pitchdet) del_aubio_pitchdetection(m_pitchdet); + if (m_onsetdet) del_aubio_onset(m_onsetdet); + if (m_pitchdet) del_aubio_pitch(m_pitchdet); if (m_ibuf) del_fvec(m_ibuf); if (m_onset) del_fvec(m_onset); if (m_fftgrain) del_cvec(m_fftgrain); @@ -110,8 +109,8 @@ Notes::initialise(size_t channels, size_t stepSize, size_t blockSize) m_blockSize = blockSize; size_t processingBlockSize; - if (m_onsettype == aubio_onset_energy || - m_onsettype == aubio_onset_hfc) { + if (m_onsettype == OnsetEnergy || + m_onsettype == OnsetHFC) { processingBlockSize = stepSize * 2; } else { processingBlockSize = stepSize * 4; diff --git a/plugins/Notes.h b/plugins/Notes.h index c8141b9..66d7f98 100644 --- a/plugins/Notes.h +++ b/plugins/Notes.h @@ -22,6 +22,8 @@ #include +#include "Types.h" + class Notes : public Vamp::Plugin { public: @@ -60,12 +62,11 @@ protected: cvec_t *m_fftgrain; fvec_t *m_onset; aubio_pvoc_t *m_pv; - aubio_pickpeak_t *m_peakpick; - aubio_onsetdetection_t *m_onsetdet; - aubio_onsetdetection_type m_onsettype; - aubio_pitchdetection_t *m_pitchdet; - aubio_pitchdetection_type m_pitchtype; - aubio_pitchdetection_mode m_pitchmode; + aubio_peakpicker_t *m_peakpick; + aubio_onset_t *m_onsetdet; + OnsetType m_onsettype; + aubio_pitch_t *m_pitchdet; + PitchType m_pitchtype; float m_threshold; float m_silence; size_t m_median; diff --git a/plugins/Onset.h b/plugins/Onset.h index 314e107..a88409c 100644 --- a/plugins/Onset.h +++ b/plugins/Onset.h @@ -20,6 +20,8 @@ #include #include +#include "Types.h" + class Onset : public Vamp::Plugin { public: @@ -57,9 +59,9 @@ protected: cvec_t *m_fftgrain; fvec_t *m_onset; aubio_pvoc_t *m_pv; - aubio_pickpeak_t *m_peakpick; - aubio_onsetdetection_t *m_onsetdet; - aubio_onsetdetection_type m_onsettype; + aubio_peakpicker_t *m_peakpick; + aubio_specdesc_t *m_onsetdet; + OnsetType m_onsettype; float m_threshold; float m_silence; size_t m_stepSize; diff --git a/plugins/Pitch.h b/plugins/Pitch.h index b54124d..1541f18 100644 --- a/plugins/Pitch.h +++ b/plugins/Pitch.h @@ -54,9 +54,8 @@ public: protected: fvec_t *m_ibuf; - aubio_pitchdetection_t *m_pitchdet; - aubio_pitchdetection_type m_pitchtype; - aubio_pitchdetection_mode m_pitchmode; + aubio_pitch_t *m_pitchdet; + PitchType m_pitchtype; float m_minfreq; float m_maxfreq; float m_silence; diff --git a/plugins/Tempo.h b/plugins/Tempo.h index ab07d35..ac8f6de 100644 --- a/plugins/Tempo.h +++ b/plugins/Tempo.h @@ -20,6 +20,8 @@ #include #include +#include "Types.h" + class Tempo : public Vamp::Plugin { public: @@ -56,10 +58,10 @@ protected: cvec_t *m_fftgrain; fvec_t *m_onset; aubio_pvoc_t *m_pv; - aubio_pickpeak_t *m_peakpick; - aubio_onsetdetection_t *m_onsetdet; - aubio_onsetdetection_type m_onsettype; - aubio_beattracking_t *m_beattracking; + aubio_peakpicker_t *m_peakpick; + aubio_onset_t *m_onsetdet; + OnsetType m_onsettype; + aubio_tempo_t *m_tempo; fvec_t *m_dfframe; fvec_t *m_btout; uint_t m_winlen; diff --git a/plugins/Types.cpp b/plugins/Types.cpp new file mode 100644 index 0000000..6a692b1 --- /dev/null +++ b/plugins/Types.cpp @@ -0,0 +1,43 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Vamp feature extraction plugins using Paul Brossier's Aubio library. + + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2012 Queen Mary, University of London. + + 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 "Types.h" + +const char *getAubioNameForOnsetType(OnsetType t) +{ + switch (t) { + case OnsetEnergy: return "energy"; + case OnsetSpecDiff: return "specdiff"; + case OnsetHFC: return "hfc"; + case OnsetComplex: return "complex"; + case OnsetPhase: return "phase"; + case OnsetMKL: return "mkl"; + case OnsetKL: return "kl"; + case OnsetSpecFlux: return "specflux"; + } +} + +const char *getAubioNameForPitchType(PitchType t) +{ + switch (t) { + case PitchMComb: return "mcomb"; + case PitchYinFFT: return "yinfft"; + case PitchYin: return "yin"; + case PitchSchmitt: return "schmitt"; + case PitchFComb: return "fcomb"; + } +} + diff --git a/plugins/Types.h b/plugins/Types.h new file mode 100644 index 0000000..aa642b0 --- /dev/null +++ b/plugins/Types.h @@ -0,0 +1,52 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Vamp feature extraction plugins using Paul Brossier's Aubio library. + + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2012 Queen Mary, University of London. + + 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 _ONSET_TYPE_H_ +#define _ONSET_TYPE_H_ + +// Note: the enum values in this header are ordered to match the Vamp +// plugin parameter values in earlier versions of this plugin set, to +// avoid breaking stored parameter settings that use the parameter's +// numerical value. Any additional values must be added after all +// existing ones. + +enum OnsetType { + OnsetEnergy, + OnsetSpecDiff, + OnsetHFC, + OnsetComplex, + OnsetPhase, + OnsetKL, + OnsetMKL, + OnsetSpecFlux // new in 0.4! +}; + +extern const char *getAubioNameForOnsetType(OnsetType t); + +enum PitchType { + PitchYin, + PitchMComb, + PitchSchmitt, + PitchFComb, + PitchYinFFT +}; + +extern const char *getAubioNameForPitchType(PitchType t); + + +#endif + +