wscript: first waf draft
[vamp-aubio-plugins.git] / plugins / Notes.cpp
index e2cbfe5..0f65110 100644 (file)
@@ -6,11 +6,20 @@
     Centre for Digital Music, Queen Mary, University of London.
     This file copyright 2006-2008 Chris Cannam and QMUL.
     
-    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/>.
 
 */
 
@@ -105,10 +114,21 @@ Notes::initialise(size_t channels, size_t stepSize, size_t blockSize)
     m_onset = new_fvec(1);
     m_pitch = new_fvec(1);
 
+    reset();
+
+    return true;
+}
+
+void
+Notes::reset()
+{
+    if (m_onsetdet) del_aubio_onset(m_onsetdet);
+    if (m_pitchdet) del_aubio_pitch(m_pitchdet);
+
     m_onsetdet = new_aubio_onset
         (const_cast<char *>(getAubioNameForOnsetType(m_onsettype)),
-         blockSize,
-         stepSize,
+         m_blockSize,
+         m_stepSize,
          lrintf(m_inputSampleRate));
     
     aubio_onset_set_threshold(m_onsetdet, m_threshold);
@@ -117,8 +137,8 @@ Notes::initialise(size_t channels, size_t stepSize, size_t blockSize)
 
     m_pitchdet = new_aubio_pitch
         (const_cast<char *>(getAubioNameForPitchType(m_pitchtype)),
-         blockSize,
-         stepSize,
+         m_blockSize,
+         m_stepSize,
          lrintf(m_inputSampleRate));
 
     aubio_pitch_set_unit(m_pitchdet, const_cast<char *>("freq"));
@@ -129,13 +149,6 @@ Notes::initialise(size_t channels, size_t stepSize, size_t blockSize)
     m_currentOnset = Vamp::RealTime::zeroTime;
     m_haveCurrent = false;
     m_prevPitch = -1;
-
-    return true;
-}
-
-void
-Notes::reset()
-{
 }
 
 size_t
@@ -158,6 +171,7 @@ Notes::getParameterDescriptors() const
     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;
@@ -176,6 +190,7 @@ Notes::getParameterDescriptors() const
     desc = ParameterDescriptor();
     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;
@@ -191,6 +206,7 @@ Notes::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "minpitch";
     desc.name = "Minimum Pitch";
+    desc.description = "Lowest pitch value to look for";
     desc.minValue = 0;
     desc.maxValue = 127;
     desc.defaultValue = 32;
@@ -202,6 +218,7 @@ Notes::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "maxpitch";
     desc.name = "Maximum Pitch";
+    desc.description = "Highest pitch value to look for";
     desc.minValue = 0;
     desc.maxValue = 127;
     desc.defaultValue = 95;
@@ -213,6 +230,7 @@ Notes::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "wraprange";
     desc.name = "Fold Higher or Lower Notes into Range";
+    desc.description = "Notes detected outside the range will be transposed to higher or lower octaves";
     desc.minValue = 0;
     desc.maxValue = 1;
     desc.defaultValue = 0;
@@ -223,6 +241,7 @@ Notes::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "avoidleaps";
     desc.name = "Avoid Multi-Octave Jumps";
+    desc.description = "Minimize octave jumps by transposing to the octave of the previously detected note";
     desc.minValue = 0;
     desc.maxValue = 1;
     desc.defaultValue = 0;
@@ -233,6 +252,7 @@ Notes::getParameterDescriptors() const
     desc = ParameterDescriptor();
     desc.identifier = "peakpickthreshold";
     desc.name = "Peak Picker Threshold";
+    desc.description = "Peak picking threshold, the higher the least detection";
     desc.minValue = 0;
     desc.maxValue = 1;
     desc.defaultValue = 0.3;
@@ -242,6 +262,7 @@ Notes::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 = -70;
@@ -252,6 +273,7 @@ Notes::getParameterDescriptors() const
     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;
@@ -336,6 +358,7 @@ Notes::getOutputDescriptors() const
     OutputDescriptor d;
     d.identifier = "notes";
     d.name = "Notes";
+    d.description = "List of notes detected, with their frequency and velocity";
     d.unit = "Hz";
     d.hasFixedBinCount = true;
 
@@ -357,7 +380,7 @@ Notes::FeatureSet
 Notes::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
 {
     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_onset_do(m_onsetdet, m_ibuf, m_onset);