.travis.yml: fix environment
[vamp-aubio-plugins.git] / plugins / Pitch.cpp
index 5fd3730..4201508 100644 (file)
@@ -6,11 +6,20 @@
     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/>.
 
 */
 
@@ -22,20 +31,14 @@ using std::vector;
 using std::cerr;
 using std::endl;
 
-static float
-getFrequencyForMIDIPitch(int midiPitch)
-{
-    return 440.f * powf(2.0, (float(midiPitch) - 69.0) / 12.0);
-}
-
 Pitch::Pitch(float inputSampleRate) :
     Plugin(inputSampleRate),
     m_ibuf(0),
     m_obuf(0),
     m_pitchdet(0),
     m_pitchtype(PitchYinFFT),
-    m_minfreq(getFrequencyForMIDIPitch(32)),
-    m_maxfreq(getFrequencyForMIDIPitch(95)),
+    m_minfreq(aubio_miditofreq(32)),
+    m_maxfreq(aubio_miditofreq(95)),
     m_silence(-90),
     m_wrapRange(false),
     m_stepSize(0),
@@ -139,6 +142,7 @@ Pitch::getParameterDescriptors() const
     ParameterDescriptor desc;
     desc.identifier = "pitchtype";
     desc.name = "Pitch Detection Function Type";
+    desc.description = "Type of pitch detection function to use";
     desc.minValue = 0;
     desc.maxValue = 4;
     desc.defaultValue = (int)PitchYinFFT;
@@ -154,9 +158,10 @@ Pitch::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "minfreq";
     desc.name = "Minimum Fundamental Frequency";
+    desc.description = "Lowest frequency to look for";
     desc.minValue = 1;
     desc.maxValue = m_inputSampleRate/2;
-    desc.defaultValue = getFrequencyForMIDIPitch(32);
+    desc.defaultValue = aubio_miditofreq(32);
     desc.unit = "Hz";
     desc.isQuantized = false;
     list.push_back(desc);
@@ -164,9 +169,10 @@ Pitch::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "maxfreq";
     desc.name = "Maximum Fundamental Frequency";
+    desc.description = "Highest frequency to look for";
     desc.minValue = 1;
     desc.maxValue = m_inputSampleRate/2;
-    desc.defaultValue = getFrequencyForMIDIPitch(95);
+    desc.defaultValue = aubio_miditofreq(95);
     desc.unit = "Hz";
     desc.isQuantized = false;
     list.push_back(desc);
@@ -174,6 +180,7 @@ Pitch::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "wraprange";
     desc.name = "Fold Higher or Lower Frequencies into Range";
+    desc.description = "Frequencies detected outside the range will be transposed to higher or lower octaves";
     desc.minValue = 0;
     desc.maxValue = 1;
     desc.defaultValue = 0;
@@ -184,6 +191,7 @@ Pitch::getParameterDescriptors() const
     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 = -90;
@@ -242,6 +250,7 @@ Pitch::getOutputDescriptors() const
     OutputDescriptor d;
     d.identifier = "frequency";
     d.name = "Fundamental Frequency";
+    d.description = "List of detected frequencies";
     d.unit = "Hz";
     d.hasFixedBinCount = true;
     d.binCount = 1;
@@ -269,7 +278,7 @@ Pitch::process(const float *const *inputBuffers,
     }
 
     for (size_t i = 0; i < m_stepSize; ++i) {
-        fvec_write_sample(m_ibuf, inputBuffers[0][i], i);
+        fvec_set_sample(m_ibuf, inputBuffers[0][i], i);
     }
 
     aubio_pitch_do(m_pitchdet, m_ibuf, m_obuf);