1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
4 Vamp feature extraction plugins using Paul Brossier's Aubio library.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
25 Pitch::Pitch(float inputSampleRate) :
26 Plugin(inputSampleRate),
29 m_pitchtype(aubio_pitch_yinfft),
30 m_pitchmode(aubio_pitchm_freq)
36 if (m_pitchdet) del_aubio_pitchdetection(m_pitchdet);
37 if (m_ibuf) del_fvec(m_ibuf);
41 Pitch::getName() const
47 Pitch::getDescription() const
49 return "Aubio Pitch Detector";
53 Pitch::getMaker() const
55 return "Paul Brossier (plugin by Chris Cannam)";
59 Pitch::getPluginVersion() const
65 Pitch::getCopyright() const
71 Pitch::initialise(size_t channels, size_t stepSize, size_t blockSize)
73 m_channelCount = channels;
74 m_stepSize = stepSize;
75 m_blockSize = blockSize;
77 m_ibuf = new_fvec(stepSize, channels);
79 m_pitchdet = new_aubio_pitchdetection(blockSize,
82 lrintf(m_inputSampleRate),
95 Pitch::getPreferredStepSize() const
101 Pitch::getPreferredBlockSize() const
107 Pitch::getParameterDescriptors() const
111 ParameterDescriptor desc;
112 desc.name = "pitchtype";
113 desc.description = "Pitch Detection Function Type";
116 desc.defaultValue = (int)aubio_pitch_yinfft;
117 desc.isQuantized = true;
118 desc.quantizeStep = 1;
119 desc.valueNames.push_back("YIN Frequency Estimator");
120 desc.valueNames.push_back("Spectral Comb");
121 desc.valueNames.push_back("Schmitt");
122 desc.valueNames.push_back("Fast Harmonic Comb");
123 desc.valueNames.push_back("YIN with FFT");
124 list.push_back(desc);
130 Pitch::getParameter(std::string param) const
132 if (param == "pitchtype") {
140 Pitch::setParameter(std::string param, float value)
142 if (param == "pitchtype") {
143 switch (lrintf(value)) {
144 case 0: m_pitchtype = aubio_pitch_yin; break;
145 case 1: m_pitchtype = aubio_pitch_mcomb; break;
146 case 2: m_pitchtype = aubio_pitch_schmitt; break;
147 case 3: m_pitchtype = aubio_pitch_fcomb; break;
148 case 4: m_pitchtype = aubio_pitch_yinfft; break;
154 Pitch::getOutputDescriptors() const
159 d.name = "frequency";
161 d.description = "Frequency";
162 d.hasFixedBinCount = true;
164 d.hasKnownExtents = false;
165 d.isQuantized = false;
166 d.sampleType = OutputDescriptor::OneSamplePerStep;
173 Pitch::process(const float *const *inputBuffers,
174 Vamp::RealTime /* timestamp */)
176 for (size_t i = 0; i < m_stepSize; ++i) {
177 for (size_t j = 0; j < m_channelCount; ++j) {
178 fvec_write_sample(m_ibuf, inputBuffers[j][i], j, i);
182 float pitch = aubio_pitchdetection(m_pitchdet, m_ibuf);
185 feature.hasTimestamp = false;
186 feature.values.push_back(pitch);
188 FeatureSet returnFeatures;
189 returnFeatures[0].push_back(feature);
190 return returnFeatures;
194 Pitch::getRemainingFeatures()