aubio 3+4 compat
This commit is contained in:
parent
75e21d3ab4
commit
a919ac8a86
|
@ -247,7 +247,9 @@ def configure(conf):
|
||||||
'LIBARDOUR_API', 'ardour/libardour_visibility.h')
|
'LIBARDOUR_API', 'ardour/libardour_visibility.h')
|
||||||
autowaf.configure(conf)
|
autowaf.configure(conf)
|
||||||
autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO',
|
autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO',
|
||||||
exact_version='0.3.2')
|
atleast_version='0.3.2')
|
||||||
|
autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO4',
|
||||||
|
atleast_version='0.4.0', mandatory=False)
|
||||||
autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
|
autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
|
||||||
if Options.options.dist_target != 'mingw':
|
if Options.options.dist_target != 'mingw':
|
||||||
autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF',
|
autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF',
|
||||||
|
|
|
@ -25,29 +25,51 @@ using std::vector;
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
const char *getAubioNameForOnsetType(OnsetType t)
|
||||||
|
{
|
||||||
|
// In the same order as the enum elements in the header
|
||||||
|
static const char *const names[] = {
|
||||||
|
"energy", "specdiff", "hfc", "complex", "phase", "kl", "mkl", "specflux"
|
||||||
|
};
|
||||||
|
return names[(int)t];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Onset::Onset(float inputSampleRate) :
|
Onset::Onset(float inputSampleRate) :
|
||||||
Plugin(inputSampleRate),
|
Plugin(inputSampleRate),
|
||||||
m_ibuf(0),
|
m_ibuf(0),
|
||||||
m_fftgrain(0),
|
|
||||||
m_onset(0),
|
m_onset(0),
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
m_onsetdet(0),
|
||||||
|
m_onsettype(OnsetComplex),
|
||||||
|
m_minioi(4),
|
||||||
|
m_silence(-70),
|
||||||
|
#else
|
||||||
|
m_fftgrain(0),
|
||||||
m_pv(0),
|
m_pv(0),
|
||||||
m_peakpick(0),
|
m_peakpick(0),
|
||||||
m_onsetdet(0),
|
m_onsetdet(0),
|
||||||
m_onsettype(aubio_onset_complex),
|
m_onsettype(aubio_onset_complex),
|
||||||
m_threshold(0.3),
|
m_channelCount(1),
|
||||||
m_silence(-90),
|
m_silence(-90),
|
||||||
m_channelCount(1)
|
#endif
|
||||||
|
m_threshold(0.3)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Onset::~Onset()
|
Onset::~Onset()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
if (m_onsetdet) del_aubio_onset(m_onsetdet);
|
||||||
|
#else
|
||||||
if (m_onsetdet) aubio_onsetdetection_free(m_onsetdet);
|
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_fftgrain) del_cvec(m_fftgrain);
|
||||||
if (m_pv) del_aubio_pvoc(m_pv);
|
if (m_pv) del_aubio_pvoc(m_pv);
|
||||||
if (m_peakpick) del_aubio_peakpicker(m_peakpick);
|
if (m_peakpick) del_aubio_peakpicker(m_peakpick);
|
||||||
|
#endif
|
||||||
|
if (m_ibuf) del_fvec(m_ibuf);
|
||||||
|
if (m_onset) del_fvec(m_onset);
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
@ -77,7 +99,11 @@ Onset::getMaker() const
|
||||||
int
|
int
|
||||||
Onset::getPluginVersion() const
|
Onset::getPluginVersion() const
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
return 2;
|
||||||
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
@ -89,10 +115,20 @@ Onset::getCopyright() const
|
||||||
bool
|
bool
|
||||||
Onset::initialise(size_t channels, size_t stepSize, size_t blockSize)
|
Onset::initialise(size_t channels, size_t stepSize, size_t blockSize)
|
||||||
{
|
{
|
||||||
m_channelCount = channels;
|
|
||||||
m_stepSize = stepSize;
|
m_stepSize = stepSize;
|
||||||
m_blockSize = blockSize;
|
m_blockSize = blockSize;
|
||||||
|
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
if (channels != 1) {
|
||||||
|
std::cerr << "Onset::initialise: channels must be 1" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_ibuf = new_fvec(stepSize);
|
||||||
|
m_onset = new_fvec(1);
|
||||||
|
reset();
|
||||||
|
#else
|
||||||
|
m_channelCount = channels;
|
||||||
|
|
||||||
m_ibuf = new_fvec(stepSize, channels);
|
m_ibuf = new_fvec(stepSize, channels);
|
||||||
m_onset = new_fvec(1, channels);
|
m_onset = new_fvec(1, channels);
|
||||||
m_fftgrain = new_cvec(blockSize, channels);
|
m_fftgrain = new_cvec(blockSize, channels);
|
||||||
|
@ -106,13 +142,32 @@ Onset::initialise(size_t channels, size_t stepSize, size_t blockSize)
|
||||||
|
|
||||||
m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay;
|
m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay;
|
||||||
|
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
void
|
void
|
||||||
Onset::reset()
|
Onset::reset()
|
||||||
{
|
{
|
||||||
|
if (m_onsetdet) del_aubio_onset(m_onsetdet);
|
||||||
|
|
||||||
|
m_onsetdet = new_aubio_onset
|
||||||
|
(const_cast<char *>(getAubioNameForOnsetType(m_onsettype)),
|
||||||
|
m_blockSize,
|
||||||
|
m_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 * m_stepSize,
|
||||||
|
lrintf(m_inputSampleRate));
|
||||||
|
|
||||||
|
m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
Onset::getPreferredStepSize() const
|
Onset::getPreferredStepSize() const
|
||||||
|
@ -135,8 +190,13 @@ Onset::getParameterDescriptors() const
|
||||||
desc.identifier = "onsettype";
|
desc.identifier = "onsettype";
|
||||||
desc.name = "Onset Detection Function Type";
|
desc.name = "Onset Detection Function Type";
|
||||||
desc.minValue = 0;
|
desc.minValue = 0;
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
desc.maxValue = 7;
|
||||||
|
desc.defaultValue = (int)OnsetComplex;
|
||||||
|
#else
|
||||||
desc.maxValue = 6;
|
desc.maxValue = 6;
|
||||||
desc.defaultValue = (int)aubio_onset_complex;
|
desc.defaultValue = (int)aubio_onset_complex;
|
||||||
|
#endif
|
||||||
desc.isQuantized = true;
|
desc.isQuantized = true;
|
||||||
desc.quantizeStep = 1;
|
desc.quantizeStep = 1;
|
||||||
desc.valueNames.push_back("Energy Based");
|
desc.valueNames.push_back("Energy Based");
|
||||||
|
@ -146,6 +206,9 @@ Onset::getParameterDescriptors() const
|
||||||
desc.valueNames.push_back("Phase Deviation");
|
desc.valueNames.push_back("Phase Deviation");
|
||||||
desc.valueNames.push_back("Kullback-Liebler");
|
desc.valueNames.push_back("Kullback-Liebler");
|
||||||
desc.valueNames.push_back("Modified Kullback-Liebler");
|
desc.valueNames.push_back("Modified Kullback-Liebler");
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
desc.valueNames.push_back("Spectral Flux");
|
||||||
|
#endif
|
||||||
list.push_back(desc);
|
list.push_back(desc);
|
||||||
|
|
||||||
desc = ParameterDescriptor();
|
desc = ParameterDescriptor();
|
||||||
|
@ -162,11 +225,27 @@ Onset::getParameterDescriptors() const
|
||||||
desc.name = "Silence Threshold";
|
desc.name = "Silence Threshold";
|
||||||
desc.minValue = -120;
|
desc.minValue = -120;
|
||||||
desc.maxValue = 0;
|
desc.maxValue = 0;
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
desc.defaultValue = -70;
|
||||||
|
#else
|
||||||
desc.defaultValue = -90;
|
desc.defaultValue = -90;
|
||||||
|
#endif
|
||||||
desc.unit = "dB";
|
desc.unit = "dB";
|
||||||
desc.isQuantized = false;
|
desc.isQuantized = false;
|
||||||
list.push_back(desc);
|
list.push_back(desc);
|
||||||
|
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +258,10 @@ Onset::getParameter(std::string param) const
|
||||||
return m_threshold;
|
return m_threshold;
|
||||||
} else if (param == "silencethreshold") {
|
} else if (param == "silencethreshold") {
|
||||||
return m_silence;
|
return m_silence;
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
} else if (param == "minioi") {
|
||||||
|
return m_minioi;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
@ -189,6 +272,16 @@ Onset::setParameter(std::string param, float value)
|
||||||
{
|
{
|
||||||
if (param == "onsettype") {
|
if (param == "onsettype") {
|
||||||
switch (lrintf(value)) {
|
switch (lrintf(value)) {
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
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
|
||||||
case 0: m_onsettype = aubio_onset_energy; break;
|
case 0: m_onsettype = aubio_onset_energy; break;
|
||||||
case 1: m_onsettype = aubio_onset_specdiff; break;
|
case 1: m_onsettype = aubio_onset_specdiff; break;
|
||||||
case 2: m_onsettype = aubio_onset_hfc; break;
|
case 2: m_onsettype = aubio_onset_hfc; break;
|
||||||
|
@ -196,11 +289,16 @@ Onset::setParameter(std::string param, float value)
|
||||||
case 4: m_onsettype = aubio_onset_phase; break;
|
case 4: m_onsettype = aubio_onset_phase; break;
|
||||||
case 5: m_onsettype = aubio_onset_kl; break;
|
case 5: m_onsettype = aubio_onset_kl; break;
|
||||||
case 6: m_onsettype = aubio_onset_mkl; break;
|
case 6: m_onsettype = aubio_onset_mkl; break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else if (param == "peakpickthreshold") {
|
} else if (param == "peakpickthreshold") {
|
||||||
m_threshold = value;
|
m_threshold = value;
|
||||||
} else if (param == "silencethreshold") {
|
} else if (param == "silencethreshold") {
|
||||||
m_silence = value;
|
m_silence = value;
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
} else if (param == "minioi") {
|
||||||
|
m_minioi = value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +317,7 @@ Onset::getOutputDescriptors() const
|
||||||
d.sampleRate = 0;
|
d.sampleRate = 0;
|
||||||
list.push_back(d);
|
list.push_back(d);
|
||||||
|
|
||||||
|
#ifndef HAVE_AUBIO4
|
||||||
d = OutputDescriptor();
|
d = OutputDescriptor();
|
||||||
d.identifier = "detectionfunction";
|
d.identifier = "detectionfunction";
|
||||||
d.name = "Onset Detection Function";
|
d.name = "Onset Detection Function";
|
||||||
|
@ -229,7 +328,7 @@ Onset::getOutputDescriptors() const
|
||||||
d.isQuantized = false;
|
d.isQuantized = false;
|
||||||
d.sampleType = OutputDescriptor::OneSamplePerStep;
|
d.sampleType = OutputDescriptor::OneSamplePerStep;
|
||||||
list.push_back(d);
|
list.push_back(d);
|
||||||
|
#endif
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +336,15 @@ Onset::FeatureSet
|
||||||
Onset::process(const float *const *inputBuffers,
|
Onset::process(const float *const *inputBuffers,
|
||||||
Vamp::RealTime timestamp)
|
Vamp::RealTime timestamp)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
for (size_t i = 0; i < m_stepSize; ++i) {
|
||||||
|
fvec_set_sample(m_ibuf, inputBuffers[0][i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
aubio_onset_do(m_onsetdet, m_ibuf, m_onset);
|
||||||
|
|
||||||
|
bool isonset = m_onset->data[0];
|
||||||
|
#else
|
||||||
for (size_t i = 0; i < m_stepSize; ++i) {
|
for (size_t i = 0; i < m_stepSize; ++i) {
|
||||||
for (size_t j = 0; j < m_channelCount; ++j) {
|
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[j][i], j, i);
|
||||||
|
@ -253,6 +361,7 @@ Onset::process(const float *const *inputBuffers,
|
||||||
isonset = false;
|
isonset = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FeatureSet returnFeatures;
|
FeatureSet returnFeatures;
|
||||||
|
|
||||||
|
@ -266,11 +375,13 @@ Onset::process(const float *const *inputBuffers,
|
||||||
m_lastOnset = timestamp;
|
m_lastOnset = timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef HAVE_AUBIO4
|
||||||
Feature feature;
|
Feature feature;
|
||||||
for (size_t j = 0; j < m_channelCount; ++j) {
|
for (size_t j = 0; j < m_channelCount; ++j) {
|
||||||
feature.values.push_back(m_onset->data[j][0]);
|
feature.values.push_back(m_onset->data[j][0]);
|
||||||
}
|
}
|
||||||
returnFeatures[1].push_back(feature);
|
returnFeatures[1].push_back(feature);
|
||||||
|
#endif
|
||||||
|
|
||||||
return returnFeatures;
|
return returnFeatures;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,19 @@
|
||||||
#include <vamp-sdk/Plugin.h>
|
#include <vamp-sdk/Plugin.h>
|
||||||
#include <aubio/aubio.h>
|
#include <aubio/aubio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
enum OnsetType {
|
||||||
|
OnsetEnergy,
|
||||||
|
OnsetSpecDiff,
|
||||||
|
OnsetHFC,
|
||||||
|
OnsetComplex,
|
||||||
|
OnsetPhase,
|
||||||
|
OnsetKL,
|
||||||
|
OnsetMKL,
|
||||||
|
OnsetSpecFlux // new in 0.4!
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class Onset : public Vamp::Plugin
|
class Onset : public Vamp::Plugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -54,20 +67,25 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
fvec_t *m_ibuf;
|
fvec_t *m_ibuf;
|
||||||
cvec_t *m_fftgrain;
|
|
||||||
fvec_t *m_onset;
|
fvec_t *m_onset;
|
||||||
|
#ifdef HAVE_AUBIO4
|
||||||
|
aubio_onset_t *m_onsetdet;
|
||||||
|
OnsetType m_onsettype;
|
||||||
|
float m_minioi;
|
||||||
|
#else
|
||||||
|
cvec_t *m_fftgrain;
|
||||||
aubio_pvoc_t *m_pv;
|
aubio_pvoc_t *m_pv;
|
||||||
aubio_pickpeak_t *m_peakpick;
|
aubio_pickpeak_t *m_peakpick;
|
||||||
aubio_onsetdetection_t *m_onsetdet;
|
aubio_onsetdetection_t *m_onsetdet;
|
||||||
aubio_onsetdetection_type m_onsettype;
|
aubio_onsetdetection_type m_onsettype;
|
||||||
float m_threshold;
|
size_t m_channelCount;
|
||||||
|
#endif
|
||||||
float m_silence;
|
float m_silence;
|
||||||
|
float m_threshold;
|
||||||
size_t m_stepSize;
|
size_t m_stepSize;
|
||||||
size_t m_blockSize;
|
size_t m_blockSize;
|
||||||
size_t m_channelCount;
|
|
||||||
Vamp::RealTime m_delay;
|
Vamp::RealTime m_delay;
|
||||||
Vamp::RealTime m_lastOnset;
|
Vamp::RealTime m_lastOnset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,8 +26,10 @@ def configure(conf):
|
||||||
conf.load('compiler_cxx')
|
conf.load('compiler_cxx')
|
||||||
autowaf.configure(conf)
|
autowaf.configure(conf)
|
||||||
autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW3F', mandatory=True)
|
autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW3F', mandatory=True)
|
||||||
autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', mandatory=False,
|
autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO',
|
||||||
exact_version='0.3.2')
|
atleast_version='0.3.2')
|
||||||
|
autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO4',
|
||||||
|
atleast_version='0.4.0', mandatory=False)
|
||||||
conf.write_config_header('libvampplugins-config.h', remove=False)
|
conf.write_config_header('libvampplugins-config.h', remove=False)
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user