From e20f267267ec3610d3f5314906197fd2819e80c3 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 16 May 2006 15:43:21 +0000 Subject: [PATCH] include math.h, add onset timestamps, fix default block and step sizes, switch to onset_complex and pitch_yinfft --- plugins/Notes.cpp | 18 +++++++----------- plugins/Onset.cpp | 32 +++++++++++--------------------- plugins/Pitch.cpp | 9 +++++---- 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/plugins/Notes.cpp b/plugins/Notes.cpp index 0a64dce..35f4be9 100644 --- a/plugins/Notes.cpp +++ b/plugins/Notes.cpp @@ -14,6 +14,7 @@ */ +#include #include "Notes.h" using std::string; @@ -29,9 +30,9 @@ Notes::Notes(float inputSampleRate) : m_pv(0), m_peakpick(0), m_onsetdet(0), - m_onsettype(aubio_onset_mkl), + m_onsettype(aubio_onset_complex), m_pitchdet(0), - m_pitchtype(aubio_pitch_fcomb), + m_pitchtype(aubio_pitch_yinfft), m_pitchmode(aubio_pitchm_freq), m_threshold(0.3), m_silence(-90), @@ -125,18 +126,13 @@ Notes::reset() size_t Notes::getPreferredStepSize() const { - if (m_onsettype == aubio_onset_energy || - m_onsettype == aubio_onset_hfc) { - return 512; - } else { - return 128; - } + return 512; } size_t Notes::getPreferredBlockSize() const { - return getPreferredStepSize(); + return 4*getPreferredStepSize(); } Notes::ParameterList @@ -149,7 +145,7 @@ Notes::getParameterDescriptors() const desc.description = "Onset Detection Function Type"; desc.minValue = 0; desc.maxValue = 6; - desc.defaultValue = (int)aubio_onset_mkl; + desc.defaultValue = (int)aubio_onset_complex; desc.isQuantized = true; desc.quantizeStep = 1; desc.valueNames.push_back("Energy Based"); @@ -166,7 +162,7 @@ Notes::getParameterDescriptors() const desc.description = "Pitch Detection Function Type"; desc.minValue = 0; desc.maxValue = 4; - desc.defaultValue = (int)aubio_pitch_fcomb; + desc.defaultValue = (int)aubio_pitch_yinfft; desc.isQuantized = true; desc.quantizeStep = 1; desc.valueNames.push_back("YIN Frequency Estimator"); diff --git a/plugins/Onset.cpp b/plugins/Onset.cpp index 68322d8..c4bc76a 100644 --- a/plugins/Onset.cpp +++ b/plugins/Onset.cpp @@ -14,6 +14,7 @@ */ +#include #include "Onset.h" using std::string; @@ -29,7 +30,7 @@ Onset::Onset(float inputSampleRate) : m_pv(0), m_peakpick(0), m_onsetdet(0), - m_onsettype(aubio_onset_mkl), + m_onsettype(aubio_onset_complex), m_threshold(0.3), m_silence(-90), m_channelCount(1) @@ -83,21 +84,13 @@ Onset::initialise(size_t channels, size_t stepSize, size_t blockSize) m_stepSize = stepSize; m_blockSize = blockSize; - size_t processingBlockSize; - if (m_onsettype == aubio_onset_energy || - m_onsettype == aubio_onset_hfc) { - processingBlockSize = stepSize * 2; - } else { - processingBlockSize = stepSize * 4; - } - m_ibuf = new_fvec(stepSize, channels); m_onset = new_fvec(1, channels); - m_fftgrain = new_cvec(processingBlockSize, channels); - m_pv = new_aubio_pvoc(processingBlockSize, stepSize, channels); + m_fftgrain = new_cvec(blockSize, channels); + m_pv = new_aubio_pvoc(blockSize, stepSize, channels); m_peakpick = new_aubio_peakpicker(m_threshold); - m_onsetdet = new_aubio_onsetdetection(m_onsettype, processingBlockSize, channels); + m_onsetdet = new_aubio_onsetdetection(m_onsettype, blockSize, channels); return true; } @@ -110,18 +103,13 @@ Onset::reset() size_t Onset::getPreferredStepSize() const { - if (m_onsettype == aubio_onset_energy || - m_onsettype == aubio_onset_hfc) { - return 512; - } else { - return 128; - } + return 512; } size_t Onset::getPreferredBlockSize() const { - return getPreferredStepSize(); + return 2*getPreferredStepSize(); } Onset::ParameterList @@ -134,7 +122,7 @@ Onset::getParameterDescriptors() const desc.description = "Onset Detection Function Type"; desc.minValue = 0; desc.maxValue = 6; - desc.defaultValue = (int)aubio_onset_mkl; + desc.defaultValue = (int)aubio_onset_complex; desc.isQuantized = true; desc.quantizeStep = 1; desc.valueNames.push_back("Energy Based"); @@ -253,7 +241,9 @@ Onset::process(float **inputBuffers, Vamp::RealTime /* timestamp */) FeatureSet returnFeatures; if (isonset) { - returnFeatures[0].push_back(Feature()); + Feature onsettime; + onsettime.hasTimestamp = false; + returnFeatures[0].push_back(onsettime); } Feature feature; for (size_t j = 0; j < m_channelCount; ++j) { diff --git a/plugins/Pitch.cpp b/plugins/Pitch.cpp index 2c43f45..60ba4fe 100644 --- a/plugins/Pitch.cpp +++ b/plugins/Pitch.cpp @@ -14,6 +14,7 @@ */ +#include #include "Pitch.h" using std::string; @@ -25,7 +26,7 @@ Pitch::Pitch(float inputSampleRate) : Plugin(inputSampleRate), m_ibuf(0), m_pitchdet(0), - m_pitchtype(aubio_pitch_fcomb), + m_pitchtype(aubio_pitch_yinfft), m_pitchmode(aubio_pitchm_freq) { } @@ -75,7 +76,7 @@ Pitch::initialise(size_t channels, size_t stepSize, size_t blockSize) m_ibuf = new_fvec(stepSize, channels); - m_pitchdet = new_aubio_pitchdetection(blockSize * 4, + m_pitchdet = new_aubio_pitchdetection(blockSize, stepSize, channels, lrintf(m_inputSampleRate), @@ -99,7 +100,7 @@ Pitch::getPreferredStepSize() const size_t Pitch::getPreferredBlockSize() const { - return 1024; + return 2048; } Pitch::ParameterList @@ -112,7 +113,7 @@ Pitch::getParameterDescriptors() const desc.description = "Pitch Detection Function Type"; desc.minValue = 0; desc.maxValue = 4; - desc.defaultValue = (int)aubio_pitch_fcomb; + desc.defaultValue = (int)aubio_pitch_yinfft; desc.isQuantized = true; desc.quantizeStep = 1; desc.valueNames.push_back("YIN Frequency Estimator"); -- 2.11.0