changeset 30:7fd8f7a0b088

Start overhaul for (current git, presumably later v0.4.0) aubio API
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 09 Jul 2012 15:10:35 +0100
parents 11f0fcad5418
children 2e979622bd93
files Makefile plugins/Notes.cpp plugins/Notes.h plugins/Onset.h plugins/Pitch.h plugins/Tempo.h plugins/Types.cpp plugins/Types.h
diffstat 8 files changed, 125 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Jul 04 10:26:11 2012 +0000
+++ b/Makefile	Mon Jul 09 15:10:35 2012 +0100
@@ -5,25 +5,23 @@
 
 # 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
--- a/plugins/Notes.cpp	Wed Jul 04 10:26:11 2012 +0000
+++ b/plugins/Notes.cpp	Mon Jul 09 15:10:35 2012 +0100
@@ -33,10 +33,9 @@
     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()
 {
-    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 @@
     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;
--- a/plugins/Notes.h	Wed Jul 04 10:26:11 2012 +0000
+++ b/plugins/Notes.h	Mon Jul 09 15:10:35 2012 +0100
@@ -22,6 +22,8 @@
 
 #include <deque>
 
+#include "Types.h"
+
 class Notes : public Vamp::Plugin
 {
 public:
@@ -60,12 +62,11 @@
     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;
--- a/plugins/Onset.h	Wed Jul 04 10:26:11 2012 +0000
+++ b/plugins/Onset.h	Mon Jul 09 15:10:35 2012 +0100
@@ -20,6 +20,8 @@
 #include <vamp-sdk/Plugin.h>
 #include <aubio/aubio.h>
 
+#include "Types.h"
+
 class Onset : public Vamp::Plugin
 {
 public:
@@ -57,9 +59,9 @@
     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;
--- a/plugins/Pitch.h	Wed Jul 04 10:26:11 2012 +0000
+++ b/plugins/Pitch.h	Mon Jul 09 15:10:35 2012 +0100
@@ -54,9 +54,8 @@
 
 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;
--- a/plugins/Tempo.h	Wed Jul 04 10:26:11 2012 +0000
+++ b/plugins/Tempo.h	Mon Jul 09 15:10:35 2012 +0100
@@ -20,6 +20,8 @@
 #include <vamp-sdk/Plugin.h>
 #include <aubio/aubio.h>
 
+#include "Types.h"
+
 class Tempo : public Vamp::Plugin
 {
 public:
@@ -56,10 +58,10 @@
     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;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/Types.cpp	Mon Jul 09 15:10:35 2012 +0100
@@ -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";
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/Types.h	Mon Jul 09 15:10:35 2012 +0100
@@ -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
+
+