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.
24 Pitch::Pitch(float inputSampleRate) :
25 Plugin(inputSampleRate),
28 m_pitchtype(aubio_pitch_fcomb),
29 m_pitchmode(aubio_pitchm_freq)
35 if (m_pitchdet) del_aubio_pitchdetection(m_pitchdet);
36 if (m_ibuf) del_fvec(m_ibuf);
40 Pitch::getName() const
46 Pitch::getDescription() const
48 return "Aubio Pitch Detector";
52 Pitch::getMaker() const
54 return "Paul Brossier (plugin by Chris Cannam)";
58 Pitch::getPluginVersion() const
64 Pitch::getCopyright() const
70 Pitch::initialise(size_t channels, size_t stepSize, size_t blockSize)
72 m_channelCount = channels;
73 m_stepSize = stepSize;
74 m_blockSize = blockSize;
76 m_ibuf = new_fvec(stepSize, channels);
78 m_pitchdet = new_aubio_pitchdetection(blockSize * 4,
81 lrintf(m_inputSampleRate),
94 Pitch::getPreferredStepSize() const
100 Pitch::getPreferredBlockSize() const
106 Pitch::getParameterDescriptors() const
110 ParameterDescriptor desc;
111 desc.name = "pitchtype";
112 desc.description = "Pitch Detection Function Type";
115 desc.defaultValue = (int)aubio_pitch_fcomb;
116 desc.isQuantized = true;
117 desc.quantizeStep = 1;
118 desc.valueNames.push_back("YIN Frequency Estimator");
119 desc.valueNames.push_back("Spectral Comb");
120 desc.valueNames.push_back("Schmitt");
121 desc.valueNames.push_back("Fast Harmonic Comb");
122 desc.valueNames.push_back("YIN with FFT");
123 list.push_back(desc);
129 Pitch::getParameter(std::string param) const
131 if (param == "pitchtype") {
139 Pitch::setParameter(std::string param, float value)
141 if (param == "pitchtype") {
142 switch (lrintf(value)) {
143 case 0: m_pitchtype = aubio_pitch_yin; break;
144 case 1: m_pitchtype = aubio_pitch_mcomb; break;
145 case 2: m_pitchtype = aubio_pitch_schmitt; break;
146 case 3: m_pitchtype = aubio_pitch_fcomb; break;
147 case 4: m_pitchtype = aubio_pitch_yinfft; break;
153 Pitch::getOutputDescriptors() const
158 d.name = "frequency";
160 d.description = "Frequency";
161 d.hasFixedBinCount = true;
163 d.hasKnownExtents = false;
164 d.isQuantized = false;
165 d.sampleType = OutputDescriptor::OneSamplePerStep;
172 Pitch::process(float **inputBuffers, Vamp::RealTime /* timestamp */)
174 for (size_t i = 0; i < m_stepSize; ++i) {
175 for (size_t j = 0; j < m_channelCount; ++j) {
176 fvec_write_sample(m_ibuf, inputBuffers[j][i], j, i);
180 float pitch = aubio_pitchdetection(m_pitchdet, m_ibuf);
183 feature.hasTimestamp = false;
184 feature.values.push_back(pitch);
186 FeatureSet returnFeatures;
187 returnFeatures[0].push_back(feature);
188 return returnFeatures;
192 Pitch::getRemainingFeatures()