Mercurial > hg > vamp-aubio-plugins
changeset 35:bcb23bb4b7aa
Get the rest to build
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 10 Jul 2012 17:20:10 +0100 |
parents | 0f40399ca1ff |
children | 5c5deb8393b9 |
files | Makefile plugins/Notes.cpp plugins/Pitch.cpp plugins/Silence.cpp plugins/Silence.h plugins/Tempo.cpp plugins/Tempo.h |
diffstat | 7 files changed, 53 insertions(+), 124 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Jul 10 15:21:35 2012 +0100 +++ b/Makefile Tue Jul 10 17:20:10 2012 +0100 @@ -5,23 +5,25 @@ # Compile flags # -CXXFLAGS := -I../ -I../inst/include $(CXXFLAGS) -fPIC -DNDEBUG -O2 -Wall -I. +#CXXFLAGS := -I../ -I../inst/include $(CXXFLAGS) -fPIC -DNDEBUG -O2 -Wall -I. +CXXFLAGS := -I../ -I../inst/include $(CXXFLAGS) -fPIC -DDEBUG -g -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. +# Libraries required for the plugins. # -PLUGIN_LIBS = -L../inst/lib -lvamp-sdk -laubio +#PLUGIN_LIBS = -L../inst/lib -lvamp-sdk -laubio +PLUGIN_LIBS = ../vamp-plugin-sdk/libvamp-sdk.a /usr/local/lib/libaubio.a /usr/lib/libfftw3f.a # Flags required to tell the compiler to make a dynamically loadable object # +PLUGIN_LDFLAGS = -shared -Wl,-Bsymbolic -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 Tue Jul 10 15:21:35 2012 +0100 +++ b/plugins/Notes.cpp Tue Jul 10 17:20:10 2012 +0100 @@ -121,7 +121,7 @@ stepSize, lrintf(m_inputSampleRate)); - aubio_pitch_set_unit(m_pitchdet, "freq"); + aubio_pitch_set_unit(m_pitchdet, const_cast<char *>("freq")); m_count = 0; m_delay = Vamp::RealTime::frame2RealTime((4 + m_median) * m_stepSize, @@ -193,7 +193,7 @@ desc.name = "Minimum Pitch"; desc.minValue = 0; desc.maxValue = 127; - desc.defaultValue = 32; + desc.defaultValue = 27; desc.unit = "MIDI units"; desc.isQuantized = true; desc.quantizeStep = 1;
--- a/plugins/Pitch.cpp Tue Jul 10 15:21:35 2012 +0100 +++ b/plugins/Pitch.cpp Tue Jul 10 17:20:10 2012 +0100 @@ -31,6 +31,7 @@ Pitch::Pitch(float inputSampleRate) : Plugin(inputSampleRate), m_ibuf(0), + m_obuf(0), m_pitchdet(0), m_pitchtype(PitchYinFFT), m_minfreq(getFrequencyForMIDIPitch(32)), @@ -105,7 +106,7 @@ stepSize, lrintf(m_inputSampleRate)); - aubio_pitch_set_unit(m_pitchdet, "freq"); + aubio_pitch_set_unit(m_pitchdet, const_cast<char *>("freq")); return true; }
--- a/plugins/Silence.cpp Tue Jul 10 15:21:35 2012 +0100 +++ b/plugins/Silence.cpp Tue Jul 10 17:20:10 2012 +0100 @@ -25,7 +25,6 @@ Plugin(inputSampleRate), m_ibuf(0), m_pbuf(0), - m_tmpptrs(0), m_threshold(-80), m_prevSilent(false), m_first(true) @@ -36,7 +35,6 @@ { if (m_ibuf) del_fvec(m_ibuf); if (m_pbuf) del_fvec(m_pbuf); - if (m_tmpptrs) delete[] m_tmpptrs; } string @@ -88,7 +86,6 @@ m_ibuf = new_fvec(stepSize); m_pbuf = new_fvec(stepSize); - m_tmpptrs = new smpl_t *[channels]; return true; } @@ -199,9 +196,7 @@ Vamp::RealTime timestamp) { for (size_t i = 0; i < m_stepSize; ++i) { - for (size_t j = 0; j < m_channelCount; ++j) { - fvec_write_sample(m_ibuf, inputBuffers[j][i], j, i); - } + fvec_write_sample(m_ibuf, inputBuffers[0][i], i); } bool silent = aubio_silence_detection(m_ibuf, m_threshold); @@ -221,13 +216,9 @@ fvec_t vec; vec.length = incr * 4; - vec.channels = m_channelCount; - vec.data = m_tmpptrs; for (size_t i = 0; i < m_stepSize - incr * 4; i += incr) { - for (size_t j = 0; j < m_channelCount; ++j) { - m_tmpptrs[j] = m_ibuf->data[j] + i; - } + vec.data = m_ibuf->data + i; bool subsilent = aubio_silence_detection(&vec, m_threshold); if (silent == subsilent) { off = i; @@ -237,9 +228,7 @@ if (silent && (off == 0)) { for (size_t i = 0; i < m_stepSize - incr; i += incr) { - for (size_t j = 0; j < m_channelCount; ++j) { - m_tmpptrs[j] = m_pbuf->data[j] + m_stepSize - i - incr; - } + vec.data = m_pbuf->data + m_stepSize - i - incr; bool subsilent = aubio_silence_detection(&vec, m_threshold); if (!subsilent) { off = -(long)i; @@ -284,7 +273,7 @@ // swap ibuf and pbuf data pointers, so that this block's data is // available in pbuf when processing the next block, without // having to allocate new storage for it - smpl_t **tmpdata = m_ibuf->data; + smpl_t *tmpdata = m_ibuf->data; m_ibuf->data = m_pbuf->data; m_pbuf->data = tmpdata;
--- a/plugins/Silence.h Tue Jul 10 15:21:35 2012 +0100 +++ b/plugins/Silence.h Tue Jul 10 17:20:10 2012 +0100 @@ -55,7 +55,6 @@ protected: fvec_t *m_ibuf; fvec_t *m_pbuf; - smpl_t **m_tmpptrs; float m_threshold; size_t m_stepSize; size_t m_blockSize;
--- a/plugins/Tempo.cpp Tue Jul 10 15:21:35 2012 +0100 +++ b/plugins/Tempo.cpp Tue Jul 10 17:20:10 2012 +0100 @@ -22,37 +22,23 @@ using std::cerr; using std::endl; -//#define HAVE_AUBIO_LOCKED_TEMPO_HACK - Tempo::Tempo(float inputSampleRate) : Plugin(inputSampleRate), m_ibuf(0), - m_fftgrain(0), - m_onset(0), - m_pv(0), - m_peakpick(0), - m_onsetdet(0), - m_onsettype(aubio_onset_specdiff), - m_beattracking(0), - m_dfframe(0), - m_btout(0), - m_btcounter(0), + m_beat(0), + m_bpm(0), + m_onsettype(OnsetComplex), + m_tempo(0), m_threshold(0.3), - m_silence(-90) + m_silence(-70) { } Tempo::~Tempo() { - if (m_onsetdet) aubio_onsetdetection_free(m_onsetdet); if (m_ibuf) del_fvec(m_ibuf); - if (m_onset) del_fvec(m_onset); - if (m_fftgrain) del_cvec(m_fftgrain); - if (m_pv) del_aubio_pvoc(m_pv); - if (m_peakpick) del_aubio_peakpicker(m_peakpick); - if (m_beattracking) del_aubio_beattracking(m_beattracking); - if (m_dfframe) del_fvec(m_dfframe); - if (m_btout) del_fvec(m_btout); + if (m_beat) del_fvec(m_beat); + if (m_tempo) del_aubio_tempo(m_tempo); } string @@ -103,23 +89,21 @@ m_blockSize = blockSize; m_ibuf = new_fvec(stepSize); - m_onset = new_fvec(1); - m_fftgrain = new_cvec(blockSize); - m_pv = new_aubio_pvoc(blockSize, stepSize); - m_peakpick = new_aubio_peakpicker(m_threshold); - - m_onsetdet = new_aubio_onsetdetection(m_onsettype, blockSize); + m_beat = new_fvec(2); m_delay = Vamp::RealTime::frame2RealTime(3 * stepSize, lrintf(m_inputSampleRate)); m_lastBeat = Vamp::RealTime::zeroTime - m_delay - m_delay; - m_winlen = 512*512/stepSize; - m_dfframe = new_fvec(m_winlen,channels); - m_btstep = m_winlen/4; - m_btout = new_fvec(m_btstep,channels); - m_beattracking = new_aubio_beattracking(m_winlen,channels); + m_tempo = new_aubio_tempo + (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)), + blockSize, + stepSize, + lrintf(m_inputSampleRate)); + + aubio_tempo_set_silence(m_tempo, m_silence); + aubio_tempo_set_threshold(m_tempo, m_threshold); return true; } @@ -150,8 +134,8 @@ desc.identifier = "onsettype"; desc.name = "Onset Detection Function Type"; desc.minValue = 0; - desc.maxValue = 6; - desc.defaultValue = (int)aubio_onset_complex; + desc.maxValue = 7; + desc.defaultValue = (int)OnsetComplex; desc.isQuantized = true; desc.quantizeStep = 1; desc.valueNames.push_back("Energy Based"); @@ -161,6 +145,7 @@ desc.valueNames.push_back("Phase Deviation"); desc.valueNames.push_back("Kullback-Liebler"); desc.valueNames.push_back("Modified Kullback-Liebler"); + desc.valueNames.push_back("Spectral Flux"); list.push_back(desc); desc = ParameterDescriptor(); @@ -177,7 +162,7 @@ desc.name = "Silence Threshold"; desc.minValue = -120; desc.maxValue = 0; - desc.defaultValue = -90; + desc.defaultValue = -70; desc.unit = "dB"; desc.isQuantized = false; list.push_back(desc); @@ -204,13 +189,14 @@ { if (param == "onsettype") { switch (lrintf(value)) { - case 0: m_onsettype = aubio_onset_energy; break; - case 1: m_onsettype = aubio_onset_specdiff; break; - case 2: m_onsettype = aubio_onset_hfc; break; - case 3: m_onsettype = aubio_onset_complex; break; - case 4: m_onsettype = aubio_onset_phase; break; - case 5: m_onsettype = aubio_onset_kl; break; - case 6: m_onsettype = aubio_onset_mkl; break; + case 0: m_onsettype = OnsetEnergy; break; + case 1: m_onsettype = OnsetSpecDiff; break; + case 2: m_onsettype = OnsetHFC; break; + case 3: m_onsettype = OnsetComplex; break; + case 4: m_onsettype = OnsetPhase; break; + case 5: m_onsettype = OnsetKL; break; + case 6: m_onsettype = OnsetMKL; break; + case 7: m_onsettype = OnsetSpecFlux; break; } } else if (param == "peakpickthreshold") { m_threshold = value; @@ -234,7 +220,6 @@ d.sampleRate = 0; list.push_back(d); -#ifdef HAVE_AUBIO_LOCKED_TEMPO_HACK d.identifier = "tempo"; d.name = "Tempo"; d.unit = "bpm"; @@ -244,7 +229,6 @@ d.isQuantized = false; d.sampleType = OutputDescriptor::OneSamplePerStep; list.push_back(d); -#endif return list; } @@ -253,48 +237,14 @@ 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) { - fvec_write_sample(m_ibuf, inputBuffers[j][i], j, i); - } + fvec_write_sample(m_ibuf, inputBuffers[0][i], i); } - aubio_pvoc_do(m_pv, m_ibuf, m_fftgrain); - aubio_onsetdetection(m_onsetdet, m_fftgrain, m_onset); + aubio_tempo_do(m_tempo, m_ibuf, m_beat); -#ifdef HAVE_AUBIO_LOCKED_TEMPO_HACK - float locked_tempo = 0; -#endif + bool istactus = m_beat->data[0]; - 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]; - for (size_t i = m_winlen - m_btstep ; i < m_winlen; i++ ) - m_dfframe->data[0][i] = 0.; - - m_btcounter = -1; - } - m_btcounter++; - bool isonset = aubio_peakpick_pimrt_wt( m_onset, m_peakpick, - &(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]) { - if (aubio_silence_detection(m_ibuf, m_silence)) { - isonset = false; - istactus = false; - } else { - istactus = true; - } - } - } + m_bpm = aubio_tempo_get_bpm(m_tempo); FeatureSet returnFeatures; @@ -309,16 +259,12 @@ } } -#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; + if (m_bpm >= 30 && m_bpm <= 206) { Feature tempo; tempo.hasTimestamp = false; - tempo.values.push_back(locked_tempo); + tempo.values.push_back(m_bpm); returnFeatures[1].push_back(tempo); } -#endif return returnFeatures; }
--- a/plugins/Tempo.h Tue Jul 10 15:21:35 2012 +0100 +++ b/plugins/Tempo.h Tue Jul 10 17:20:10 2012 +0100 @@ -55,18 +55,10 @@ protected: fvec_t *m_ibuf; - cvec_t *m_fftgrain; - fvec_t *m_onset; - aubio_pvoc_t *m_pv; - aubio_peakpicker_t *m_peakpick; - aubio_onset_t *m_onsetdet; + fvec_t *m_beat; + smpl_t m_bpm; OnsetType m_onsettype; aubio_tempo_t *m_tempo; - fvec_t *m_dfframe; - fvec_t *m_btout; - uint_t m_winlen; - sint_t m_btstep; - sint_t m_btcounter; float m_threshold; float m_silence; size_t m_stepSize;