Mercurial > hg > vamp-aubio-plugins
changeset 34:0f40399ca1ff
Get Onset and Notes to build against new aubio
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 10 Jul 2012 15:21:35 +0100 |
parents | a2301c902711 |
children | bcb23bb4b7aa |
files | plugins/Notes.cpp plugins/Notes.h plugins/Onset.cpp plugins/Onset.h |
diffstat | 4 files changed, 90 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/Notes.cpp Mon Jul 09 17:51:30 2012 +0100 +++ b/plugins/Notes.cpp Tue Jul 10 15:21:35 2012 +0100 @@ -27,16 +27,15 @@ Notes::Notes(float inputSampleRate) : Plugin(inputSampleRate), m_ibuf(0), - m_fftgrain(0), m_onset(0), - m_pv(0), - m_peakpick(0), + m_pitch(0), m_onsetdet(0), m_onsettype(OnsetComplex), m_pitchdet(0), m_pitchtype(PitchYinFFT), m_threshold(0.3), - m_silence(-90), + m_silence(-70), + m_minioi(4), m_median(6), m_minpitch(27), m_maxpitch(95), @@ -52,9 +51,7 @@ 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); - if (m_pv) del_aubio_pvoc(m_pv); - if (m_peakpick) del_aubio_peakpicker(m_peakpick); + if (m_pitch) del_fvec(m_pitch); } string @@ -104,27 +101,27 @@ m_stepSize = stepSize; m_blockSize = blockSize; - size_t processingBlockSize; - if (m_onsettype == OnsetEnergy || - m_onsettype == OnsetHFC) { - processingBlockSize = stepSize * 2; - } else { - processingBlockSize = stepSize * 4; - } - m_ibuf = new_fvec(stepSize); m_onset = new_fvec(1); - m_fftgrain = new_cvec(processingBlockSize); - m_pv = new_aubio_pvoc(processingBlockSize, stepSize); - m_peakpick = new_aubio_peakpicker(m_threshold); + m_pitch = new_fvec(1); - m_onsetdet = new_aubio_onsetdetection(m_onsettype, processingBlockSize); + m_onsetdet = new_aubio_onset + (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)), + blockSize, + stepSize, + lrintf(m_inputSampleRate)); + + aubio_onset_set_threshold(m_onsetdet, m_threshold); + aubio_onset_set_silence(m_onsetdet, m_silence); + aubio_onset_set_minioi(m_onsetdet, m_minioi); - m_pitchdet = new_aubio_pitchdetection(processingBlockSize * 4, - stepSize, - lrintf(m_inputSampleRate), - m_pitchtype, - m_pitchmode); + m_pitchdet = new_aubio_pitch + (const_cast<char *>(getAubioNameForPitchType(m_pitchtype)), + blockSize, + stepSize, + lrintf(m_inputSampleRate)); + + aubio_pitch_set_unit(m_pitchdet, "freq"); m_count = 0; m_delay = Vamp::RealTime::frame2RealTime((4 + m_median) * m_stepSize, @@ -162,8 +159,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"); @@ -173,6 +170,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(); @@ -180,7 +178,7 @@ desc.name = "Pitch Detection Function Type"; desc.minValue = 0; desc.maxValue = 4; - desc.defaultValue = (int)aubio_pitch_yinfft; + desc.defaultValue = (int)PitchYinFFT; desc.isQuantized = true; desc.quantizeStep = 1; desc.valueNames.push_back("YIN Frequency Estimator"); @@ -246,11 +244,22 @@ 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); + desc = ParameterDescriptor(); + desc.identifier = "minioi"; + desc.name = "Minimum Inter-Onset Interval"; + desc.minValue = 0; + desc.maxValue = 40; + desc.defaultValue = 4; + desc.unit = "ms"; + desc.isQuantized = true; + desc.quantizeStep = 1; + list.push_back(desc); + return list; } @@ -273,6 +282,8 @@ return m_wrapRange ? 1.0 : 0.0; } else if (param == "avoidleaps") { return m_avoidLeaps ? 1.0 : 0.0; + } else if (param == "minioi") { + return m_minioi; } else { return 0.0; } @@ -283,21 +294,22 @@ { 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 == "pitchtype") { switch (lrintf(value)) { - case 0: m_pitchtype = aubio_pitch_yin; break; - case 1: m_pitchtype = aubio_pitch_mcomb; break; - case 2: m_pitchtype = aubio_pitch_schmitt; break; - case 3: m_pitchtype = aubio_pitch_fcomb; break; - case 4: m_pitchtype = aubio_pitch_yinfft; break; + case 0: m_pitchtype = PitchYin; break; + case 1: m_pitchtype = PitchMComb; break; + case 2: m_pitchtype = PitchSchmitt; break; + case 3: m_pitchtype = PitchFComb; break; + case 4: m_pitchtype = PitchYinFFT; break; } } else if (param == "peakpickthreshold") { m_threshold = value; @@ -311,6 +323,8 @@ m_wrapRange = (value > 0.5); } else if (param == "avoidleaps") { m_avoidLeaps = (value > 0.5); + } else if (param == "minioi") { + m_minioi = value; } } @@ -343,17 +357,14 @@ 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) { - 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_onset_do(m_onsetdet, m_ibuf, m_onset); + aubio_pitch_do(m_pitchdet, m_ibuf, m_pitch); - bool isonset = aubio_peakpick_pimrt(m_onset, m_peakpick); - - float frequency = aubio_pitchdetection(m_pitchdet, m_ibuf); + bool isonset = m_onset->data[0]; + float frequency = m_pitch->data[0]; m_notebuf.push_back(frequency); if (m_notebuf.size() > m_median) m_notebuf.pop_front();
--- a/plugins/Notes.h Mon Jul 09 17:51:30 2012 +0100 +++ b/plugins/Notes.h Tue Jul 10 15:21:35 2012 +0100 @@ -58,16 +58,15 @@ protected: fvec_t *m_ibuf; - cvec_t *m_fftgrain; fvec_t *m_onset; - aubio_pvoc_t *m_pv; - aubio_peakpicker_t *m_peakpick; + fvec_t *m_pitch; aubio_onset_t *m_onsetdet; OnsetType m_onsettype; aubio_pitch_t *m_pitchdet; PitchType m_pitchtype; float m_threshold; float m_silence; + float m_minioi; size_t m_median; size_t m_stepSize; size_t m_blockSize;
--- a/plugins/Onset.cpp Mon Jul 09 17:51:30 2012 +0100 +++ b/plugins/Onset.cpp Tue Jul 10 15:21:35 2012 +0100 @@ -25,14 +25,12 @@ Onset::Onset(float inputSampleRate) : Plugin(inputSampleRate), m_ibuf(0), - m_fftgrain(0), m_onset(0), - m_pv(0), - m_peakpick(0), m_onsetdet(0), m_onsettype(OnsetComplex), m_threshold(0.3), - m_silence(-90) + m_silence(-70), + m_minioi(4) { } @@ -41,9 +39,6 @@ if (m_onsetdet) del_aubio_onset(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); } string @@ -95,10 +90,6 @@ 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(); - aubio_peakpicker_set_threshold(m_peakpick, m_threshold); m_onsetdet = new_aubio_onset (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)), @@ -106,6 +97,10 @@ stepSize, lrintf(m_inputSampleRate)); + aubio_onset_set_threshold(m_onsetdet, m_threshold); + aubio_onset_set_silence(m_onsetdet, m_silence); + aubio_onset_set_minioi(m_onsetdet, m_minioi); + m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize, lrintf(m_inputSampleRate)); @@ -140,7 +135,7 @@ desc.identifier = "onsettype"; desc.name = "Onset Detection Function Type"; desc.minValue = 0; - desc.maxValue = 6; + desc.maxValue = 7; desc.defaultValue = (int)OnsetComplex; desc.isQuantized = true; desc.quantizeStep = 1; @@ -151,6 +146,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(); @@ -167,11 +163,22 @@ 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); + desc = ParameterDescriptor(); + desc.identifier = "minioi"; + desc.name = "Minimum Inter-Onset Interval"; + desc.minValue = 0; + desc.maxValue = 40; + desc.defaultValue = 4; + desc.unit = "ms"; + desc.isQuantized = true; + desc.quantizeStep = 1; + list.push_back(desc); + return list; } @@ -184,6 +191,8 @@ return m_threshold; } else if (param == "silencethreshold") { return m_silence; + } else if (param == "minioi") { + return m_minioi; } else { return 0.0; } @@ -201,11 +210,14 @@ 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; } else if (param == "silencethreshold") { m_silence = value; + } else if (param == "minioi") { + m_minioi = value; } } @@ -248,13 +260,7 @@ aubio_onset_do(m_onsetdet, m_ibuf, m_onset); - bool isonset = aubio_peakpick_pimrt(m_onset, m_peakpick); - - if (isonset) { - if (aubio_silence_detection(m_ibuf, m_silence)) { - isonset = false; - } - } + bool isonset = m_onset->data[0]; FeatureSet returnFeatures; @@ -268,12 +274,13 @@ m_lastOnset = timestamp; } } +/*!!! todo! Feature feature; for (size_t j = 0; j < m_channelCount; ++j) { feature.values.push_back(m_onset->data[j][0]); } returnFeatures[1].push_back(feature); - +*/ return returnFeatures; }
--- a/plugins/Onset.h Mon Jul 09 17:51:30 2012 +0100 +++ b/plugins/Onset.h Tue Jul 10 15:21:35 2012 +0100 @@ -56,14 +56,12 @@ 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; OnsetType m_onsettype; float m_threshold; float m_silence; + float m_minioi; size_t m_stepSize; size_t m_blockSize; Vamp::RealTime m_delay;