From: Chris Cannam Date: Tue, 12 Dec 2006 10:42:21 +0000 (+0000) Subject: * Update to new Vamp process() X-Git-Tag: hgimport~38 X-Git-Url: https://git.aubio.org/?p=vamp-aubio-plugins.git;a=commitdiff_plain;h=3144a5db172787cf4334b4cdd0ccd2eac7593ab0;hp=bd2f00cc0169ee4bb5f55c2208b50c70e40d28f3 * Update to new Vamp process() * Add hack for getting raw tempo out of hacked Aubio --- diff --git a/Makefile b/Makefile index 324ebf9..486b445 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ CXXFLAGS := $(CXXFLAGS) -DNDEBUG -O2 -march=pentium3 -mfpmath=sse -ffast-math -W # want to) statically link libstdc++, because our plugin exposes only # a C API so there are no boundary compatibility problems. # -PLUGIN_LIBS = -L$(VAMPLIBDIR) -Wl,-Bstatic -lvamp-sdk -laubio -Wl,-Bdynamic +PLUGIN_LIBS = -L$(VAMPLIBDIR) -Wl,-Bstatic -lvamp-sdk -laubio -lfftw3f -Wl,-Bdynamic #PLUGIN_LIBS = -L$(VAMPLIBDIR) -lvamp-sdk /usr/lib/libaubio.a /usr/lib/libfftw3f.a #PLUGIN_LIBS = -L$(VAMPLIBDIR) -lvamp-sdk $(shell g++ -print-file-name=libstdc++.a) diff --git a/plugins/Notes.cpp b/plugins/Notes.cpp index 1822954..eb68cee 100644 --- a/plugins/Notes.cpp +++ b/plugins/Notes.cpp @@ -328,7 +328,7 @@ Notes::getOutputDescriptors() const } Notes::FeatureSet -Notes::process(float **inputBuffers, Vamp::RealTime timestamp) +Notes::process(const float *const *inputBuffers, Vamp::RealTime timestamp) { for (size_t i = 0; i < m_stepSize; ++i) { for (size_t j = 0; j < m_channelCount; ++j) { diff --git a/plugins/Notes.h b/plugins/Notes.h index be2e162..b3bc24c 100644 --- a/plugins/Notes.h +++ b/plugins/Notes.h @@ -48,7 +48,8 @@ public: OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures(); diff --git a/plugins/Onset.cpp b/plugins/Onset.cpp index 3771af1..df33208 100644 --- a/plugins/Onset.cpp +++ b/plugins/Onset.cpp @@ -225,7 +225,8 @@ Onset::getOutputDescriptors() const } Onset::FeatureSet -Onset::process(float **inputBuffers, Vamp::RealTime timestamp) +Onset::process(const float *const *inputBuffers, + Vamp::RealTime timestamp) { for (size_t i = 0; i < m_stepSize; ++i) { for (size_t j = 0; j < m_channelCount; ++j) { diff --git a/plugins/Onset.h b/plugins/Onset.h index bf80065..c8c3475 100644 --- a/plugins/Onset.h +++ b/plugins/Onset.h @@ -46,7 +46,8 @@ public: OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures(); diff --git a/plugins/Pitch.cpp b/plugins/Pitch.cpp index 60ba4fe..635909d 100644 --- a/plugins/Pitch.cpp +++ b/plugins/Pitch.cpp @@ -170,7 +170,8 @@ Pitch::getOutputDescriptors() const } Pitch::FeatureSet -Pitch::process(float **inputBuffers, Vamp::RealTime /* timestamp */) +Pitch::process(const float *const *inputBuffers, + Vamp::RealTime /* timestamp */) { for (size_t i = 0; i < m_stepSize; ++i) { for (size_t j = 0; j < m_channelCount; ++j) { diff --git a/plugins/Pitch.h b/plugins/Pitch.h index 1752737..4b86b04 100644 --- a/plugins/Pitch.h +++ b/plugins/Pitch.h @@ -46,7 +46,8 @@ public: OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); FeatureSet getRemainingFeatures(); diff --git a/plugins/Tempo.cpp b/plugins/Tempo.cpp index 5fc3cc6..81c4a49 100644 --- a/plugins/Tempo.cpp +++ b/plugins/Tempo.cpp @@ -22,6 +22,8 @@ using std::vector; using std::cerr; using std::endl; +//#define HAVE_AUBIO_LOCKED_TEMPO_HACK + Tempo::Tempo(float inputSampleRate) : Plugin(inputSampleRate), m_ibuf(0), @@ -223,11 +225,23 @@ Tempo::getOutputDescriptors() const d.sampleRate = 0; list.push_back(d); +#ifdef HAVE_AUBIO_LOCKED_TEMPO_HACK + d.name = "tempo"; + d.unit = "bpm"; + d.description = "Tempo"; + d.hasFixedBinCount = true; + d.binCount = 1; + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::OneSamplePerStep; + list.push_back(d); +#endif + return list; } Tempo::FeatureSet -Tempo::process(float **inputBuffers, Vamp::RealTime timestamp) +Tempo::process(const float *const *inputBuffers, Vamp::RealTime timestamp) { for (size_t i = 0; i < m_stepSize; ++i) { for (size_t j = 0; j < m_channelCount; ++j) { @@ -238,8 +252,16 @@ Tempo::process(float **inputBuffers, Vamp::RealTime timestamp) aubio_pvoc_do(m_pv, m_ibuf, m_fftgrain); aubio_onsetdetection(m_onsetdet, m_fftgrain, m_onset); +#ifdef HAVE_AUBIO_LOCKED_TEMPO_HACK + float locked_tempo = 0; +#endif + if ( m_btcounter == m_btstep - 1 ) { +#ifdef HAVE_AUBIO_LOCKED_TEMPO_HACK + aubio_beattracking_do(m_beattracking,m_dfframe,m_btout,&locked_tempo); +#else aubio_beattracking_do(m_beattracking,m_dfframe,m_btout); +#endif /* rotate dfframe */ for (size_t i = 0 ; i < m_winlen - m_btstep; i++ ) m_dfframe->data[0][i] = m_dfframe->data[0][i+m_btstep]; @@ -253,7 +275,6 @@ Tempo::process(float **inputBuffers, Vamp::RealTime timestamp) &(m_dfframe->data[0][m_winlen - m_btstep + m_btcounter])); bool istactus = 0; - /* check if any of the predicted beat correspond to the current time */ for (size_t i = 1; i < m_btout->data[0][0]; i++ ) { if (m_btcounter == m_btout->data[0][i]) { @@ -279,6 +300,17 @@ Tempo::process(float **inputBuffers, Vamp::RealTime timestamp) } } +#ifdef HAVE_AUBIO_LOCKED_TEMPO_HACK + if (locked_tempo >= 30 && locked_tempo <= 206) { + if (locked_tempo > 145) locked_tempo /= 2; + std::cerr << "Locked tempo: " << locked_tempo << std::endl; + Feature tempo; + tempo.hasTimestamp = false; + tempo.values.push_back(locked_tempo); + returnFeatures[1].push_back(tempo); + } +#endif + return returnFeatures; } diff --git a/plugins/Tempo.h b/plugins/Tempo.h index ce746e8..a92c545 100644 --- a/plugins/Tempo.h +++ b/plugins/Tempo.h @@ -46,7 +46,7 @@ public: OutputList getOutputDescriptors() const; - FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp); FeatureSet getRemainingFeatures();