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::getIdentifier() const
47 Pitch::getName() const
49 return "Aubio Pitch Detector";
53 Pitch::getDescription() const
55 return "Track estimated note pitches";
59 Pitch::getMaker() const
61 return "Paul Brossier (plugin by Chris Cannam)";
65 Pitch::getPluginVersion() const
71 Pitch::getCopyright() const
77 Pitch::initialise(size_t channels, size_t stepSize, size_t blockSize)
79 m_channelCount = channels;
80 m_stepSize = stepSize;
81 m_blockSize = blockSize;
83 m_ibuf = new_fvec(stepSize, channels);
85 m_pitchdet = new_aubio_pitchdetection(blockSize,
88 lrintf(m_inputSampleRate),
101 Pitch::getPreferredStepSize() const
107 Pitch::getPreferredBlockSize() const
113 Pitch::getParameterDescriptors() const
117 ParameterDescriptor desc;
118 desc.identifier = "pitchtype";
119 desc.name = "Pitch Detection Function Type";
122 desc.defaultValue = (int)aubio_pitch_yinfft;
123 desc.isQuantized = true;
124 desc.quantizeStep = 1;
125 desc.valueNames.push_back("YIN Frequency Estimator");
126 desc.valueNames.push_back("Spectral Comb");
127 desc.valueNames.push_back("Schmitt");
128 desc.valueNames.push_back("Fast Harmonic Comb");
129 desc.valueNames.push_back("YIN with FFT");
130 list.push_back(desc);
136 Pitch::getParameter(std::string param) const
138 if (param == "pitchtype") {
146 Pitch::setParameter(std::string param, float value)
148 if (param == "pitchtype") {
149 switch (lrintf(value)) {
150 case 0: m_pitchtype = aubio_pitch_yin; break;
151 case 1: m_pitchtype = aubio_pitch_mcomb; break;
152 case 2: m_pitchtype = aubio_pitch_schmitt; break;
153 case 3: m_pitchtype = aubio_pitch_fcomb; break;
154 case 4: m_pitchtype = aubio_pitch_yinfft; break;
160 Pitch::getOutputDescriptors() const
165 d.identifier = "frequency";
166 d.name = "Frequency";
168 d.hasFixedBinCount = true;
170 d.hasKnownExtents = false;
171 d.isQuantized = false;
172 d.sampleType = OutputDescriptor::OneSamplePerStep;
179 Pitch::process(const float *const *inputBuffers,
180 Vamp::RealTime /* timestamp */)
182 for (size_t i = 0; i < m_stepSize; ++i) {
183 for (size_t j = 0; j < m_channelCount; ++j) {
184 fvec_write_sample(m_ibuf, inputBuffers[j][i], j, i);
188 float pitch = aubio_pitchdetection(m_pitchdet, m_ibuf);
191 feature.hasTimestamp = false;
192 feature.values.push_back(pitch);
194 FeatureSet returnFeatures;
195 returnFeatures[0].push_back(feature);
196 return returnFeatures;
200 Pitch::getRemainingFeatures()