m_pv(0),
m_peakpick(0),
m_onsetdet(0),
- m_onsettype(aubio_onset_complex),
+ m_onsettype(OnsetComplex),
m_threshold(0.3),
m_silence(-90)
{
Onset::~Onset()
{
- if (m_onsetdet) aubio_onsetdetection_free(m_onsetdet);
+ 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);
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_peakpick = new_aubio_peakpicker();
+ aubio_peakpicker_set_threshold(m_peakpick, m_threshold);
+
+ m_onsetdet = new_aubio_onset
+ (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)),
+ blockSize,
+ stepSize,
+ lrintf(m_inputSampleRate));
m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize,
lrintf(m_inputSampleRate));
desc.name = "Onset Detection Function Type";
desc.minValue = 0;
desc.maxValue = 6;
- desc.defaultValue = (int)aubio_onset_complex;
+ desc.defaultValue = (int)OnsetComplex;
desc.isQuantized = true;
desc.quantizeStep = 1;
desc.valueNames.push_back("Energy Based");
{
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;
}
} else if (param == "peakpickthreshold") {
m_threshold = value;
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);
bool isonset = aubio_peakpick_pimrt(m_onset, m_peakpick);
fvec_t *m_onset;
aubio_pvoc_t *m_pv;
aubio_peakpicker_t *m_peakpick;
- aubio_specdesc_t *m_onsetdet;
+ aubio_onset_t *m_onsetdet;
OnsetType m_onsettype;
float m_threshold;
float m_silence;
{
if (m_pitchdet) del_aubio_pitch(m_pitchdet);
if (m_ibuf) del_fvec(m_ibuf);
+ if (m_obuf) del_fvec(m_obuf);
}
string
m_blockSize = blockSize;
m_ibuf = new_fvec(stepSize);
+ m_obuf = new_fvec(1);
- m_pitchdet = new_aubio_pitchdetection(blockSize,
- stepSize,
- channels,
- 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");
return true;
}
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");
{
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 == "minfreq") {
m_minfreq = value;
}
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);
}
- float freq = aubio_pitchdetection(m_pitchdet, m_ibuf);
+ aubio_pitch_do(m_pitchdet, m_ibuf, m_obuf);
+
+ float freq = m_obuf->data[0];
bool silent = aubio_silence_detection(m_ibuf, m_silence);
if (silent) {
protected:
fvec_t *m_ibuf;
+ fvec_t *m_obuf;
aubio_pitch_t *m_pitchdet;
PitchType m_pitchtype;
float m_minfreq;
const char *getAubioNameForOnsetType(OnsetType t)
{
- switch (t) {
- case OnsetEnergy: return "energy";
- case OnsetSpecDiff: return "specdiff";
- case OnsetHFC: return "hfc";
- case OnsetComplex: return "complex";
- case OnsetPhase: return "phase";
- case OnsetMKL: return "mkl";
- case OnsetKL: return "kl";
- case OnsetSpecFlux: return "specflux";
- }
+ // 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];
}
const char *getAubioNameForPitchType(PitchType t)
{
- switch (t) {
- case PitchMComb: return "mcomb";
- case PitchYinFFT: return "yinfft";
- case PitchYin: return "yin";
- case PitchSchmitt: return "schmitt";
- case PitchFComb: return "fcomb";
- }
+ // In the same order as the enum elements in the header
+ static const char *const names[] = {
+ "yin", "mcomb", "schmitt", "fcomb", "yinfft"
+ };
+ return names[(int)t];
}