Centre for Digital Music, Queen Mary, University of London.
This file copyright 2006 Chris Cannam.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version. See the file
- COPYING included with this distribution for more information.
+ This file is part of vamp-aubio-plugins.
+
+ vamp-aubio is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ vamp-aubio is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
m_ibuf(0),
m_onset(0),
m_onsetdet(0),
- m_onsettype(OnsetComplex),
+ m_onsettype(OnsetDefault),
m_threshold(0.3),
- m_silence(-70),
+ m_silence(-90),
m_minioi(4)
{
+
}
Onset::~Onset()
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;
}
size_t
Onset::getPreferredStepSize() const
{
- return 512;
+ return 256;
}
size_t
ParameterDescriptor desc;
desc.identifier = "onsettype";
desc.name = "Onset Detection Function Type";
+ desc.description = "Type of onset detection function to use";
desc.minValue = 0;
desc.maxValue = 7;
- desc.defaultValue = (int)OnsetComplex;
+ desc.defaultValue = (int)OnsetDefault;
desc.isQuantized = true;
desc.quantizeStep = 1;
desc.valueNames.push_back("Energy Based");
desc.valueNames.push_back("Kullback-Liebler");
desc.valueNames.push_back("Modified Kullback-Liebler");
desc.valueNames.push_back("Spectral Flux");
+ desc.valueNames.push_back("Default");
list.push_back(desc);
desc = ParameterDescriptor();
desc.identifier = "peakpickthreshold";
desc.name = "Peak Picker Threshold";
+ desc.description = "Threshold used for peak picking, the higher the more detections";
desc.minValue = 0;
desc.maxValue = 1;
desc.defaultValue = 0.3;
desc = ParameterDescriptor();
desc.identifier = "silencethreshold";
desc.name = "Silence Threshold";
+ desc.description = "Silence threshold, the higher the least detection";
desc.minValue = -120;
desc.maxValue = 0;
- desc.defaultValue = -70;
+ desc.defaultValue = -90;
desc.unit = "dB";
desc.isQuantized = false;
list.push_back(desc);
desc = ParameterDescriptor();
desc.identifier = "minioi";
desc.name = "Minimum Inter-Onset Interval";
+ desc.description = "Time interval below which two consecutive onsets should be merged";
desc.minValue = 0;
desc.maxValue = 40;
desc.defaultValue = 4;
if (param == "onsettype") {
return m_onsettype;
} else if (param == "peakpickthreshold") {
- return m_threshold;
+ if (m_onsetdet) {
+ return aubio_onset_get_threshold(m_onsetdet);
+ } else {
+ return m_threshold;
+ }
} else if (param == "silencethreshold") {
- return m_silence;
+ if (m_onsetdet) {
+ return aubio_onset_get_silence(m_onsetdet);
+ } else {
+ return m_silence;
+ }
} else if (param == "minioi") {
- return m_minioi;
+ if (m_onsetdet) {
+ return aubio_onset_get_minioi(m_onsetdet);
+ } else {
+ return m_minioi;
+ }
} else {
return 0.0;
}
case 5: m_onsettype = OnsetKL; break;
case 6: m_onsettype = OnsetMKL; break;
case 7: m_onsettype = OnsetSpecFlux; break;
+ case 8: m_onsettype = OnsetDefault; break;
}
+ if (!m_onsetdet) initialise(1, 256, 512);
} else if (param == "peakpickthreshold") {
m_threshold = value;
+ if (m_onsetdet)
+ aubio_onset_set_threshold(m_onsetdet, m_threshold);
} else if (param == "silencethreshold") {
m_silence = value;
+ if (m_onsetdet)
+ aubio_onset_set_silence(m_onsetdet, m_silence);
} else if (param == "minioi") {
m_minioi = value;
+ if (m_onsetdet)
+ aubio_onset_set_minioi(m_onsetdet, m_minioi);
}
}
OutputDescriptor d;
d.identifier = "onsets";
d.name = "Onsets";
+ d.description = "List of times at which a note onset was detected";
d.unit = "";
d.hasFixedBinCount = true;
d.binCount = 0;
d.sampleRate = 0;
list.push_back(d);
+ d.identifier = "odf";
+ d.name = "Onset detection function";
+ d.description = "Output of the onset detection function";
+ d.binCount = 1;
+ d.isQuantized = true;
+ d.quantizeStep = 1.0;
+ d.sampleType = OutputDescriptor::OneSamplePerStep;
+ list.push_back(d);
+
+ d.identifier = "todf";
+ d.name = "Thresholded Onset detection function";
+ d.description = "Output of the thresholded onset detection function";
+ d.binCount = 1;
+ d.isQuantized = true;
+ d.quantizeStep = 1.0;
+ d.sampleType = OutputDescriptor::OneSamplePerStep;
+ list.push_back(d);
+
return list;
}
aubio_onset_do(m_onsetdet, m_ibuf, m_onset);
- bool isonset = m_onset->data[0];
+ smpl_t isonset = m_onset->data[0];
FeatureSet returnFeatures;
if (isonset) {
- if (timestamp - m_lastOnset >= m_delay) {
- Feature onsettime;
- onsettime.hasTimestamp = true;
- if (timestamp < m_delay) timestamp = m_delay;
- onsettime.timestamp = timestamp - m_delay;
- returnFeatures[0].push_back(onsettime);
- m_lastOnset = timestamp;
- }
+ Feature onsettime;
+ onsettime.hasTimestamp = true;
+ onsettime.timestamp = Vamp::RealTime::fromSeconds(aubio_onset_get_last_s(m_onsetdet));
+ returnFeatures[0].push_back(onsettime);
}
+ Feature odf;
+ odf.hasTimestamp = false;
+ odf.values.push_back(aubio_onset_get_descriptor(m_onsetdet));
+ returnFeatures[1].push_back(odf);
+
+ Feature todf;
+ todf.hasTimestamp = false;
+ todf.values.push_back(aubio_onset_get_thresholded_descriptor(m_onsetdet));
+ returnFeatures[2].push_back(todf);
+
return returnFeatures;
}