Merge branch 'yinfast'
authorPaul Brossier <piem@piem.org>
Mon, 24 Jul 2017 12:13:52 +0000 (14:13 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 24 Jul 2017 12:13:52 +0000 (14:13 +0200)
doc/web.cfg
python/demos/demo_yin_compare.py [new file with mode: 0755]
python/lib/gen_external.py
python/tests/test_pitch.py
src/aubio.h
src/pitch/pitch.c
src/pitch/pitch.h
src/pitch/pitchyinfast.c [new file with mode: 0644]
src/pitch/pitchyinfast.h [new file with mode: 0644]

index bac2c83..ccd6233 100644 (file)
@@ -835,6 +835,7 @@ EXCLUDE                = ../src/aubio_priv.h \
                          ../src/pitch/pitchmcomb.h \
                          ../src/pitch/pitchyin.h \
                          ../src/pitch/pitchyinfft.h \
+                         ../src/pitch/pitchyinfast.h \
                          ../src/pitch/pitchschmitt.h \
                          ../src/pitch/pitchfcomb.h \
                          ../src/pitch/pitchspecacf.h \
diff --git a/python/demos/demo_yin_compare.py b/python/demos/demo_yin_compare.py
new file mode 100755 (executable)
index 0000000..92dc015
--- /dev/null
@@ -0,0 +1,175 @@
+#! /usr/bin/env python
+# -*- coding: utf8 -*-
+
+""" Pure python implementation of the sum of squared difference
+
+    sqd_yin: original sum of squared difference [0]
+        d_t(tau) = x ⊗ kernel
+    sqd_yinfast: sum of squared diff using complex domain [0]
+    sqd_yinfftslow: tappered squared diff [1]
+    sqd_yinfft: modified squared diff using complex domain [1]
+
+[0]:http://audition.ens.fr/adc/pdf/2002_JASA_YIN.pdf
+[1]:https://aubio.org/phd/
+"""
+
+import sys
+import numpy as np
+import matplotlib.pyplot as plt
+
+def sqd_yin(samples):
+    """ compute original sum of squared difference
+
+    Brute-force computation (cost o(N**2), slow)."""
+    B = len(samples)
+    W = B//2
+    yin = np.zeros(W)
+    for j in range(W):
+      for tau in range(1, W):
+        yin[tau] += (samples[j] - samples[j+tau])**2
+    return yin
+
+def sqd_yinfast(samples):
+    """ compute approximate sum of squared difference
+
+    Using complex convolution (fast, cost o(n*log(n)) )"""
+    # yin_t(tau) = (r_t(0) + r_(t+tau)(0)) - 2r_t(tau)
+    B = len(samples)
+    W = B//2
+    yin = np.zeros(W)
+    sqdiff = np.zeros(W)
+    kernel = np.zeros(B)
+    # compute r_(t+tau)(0)
+    squares = samples**2
+    for tau in range(W):
+        sqdiff[tau] = squares[tau:tau+W].sum()
+    # add r_t(0)
+    sqdiff += sqdiff[0]
+    # compute r_t(tau) using kernel convolution in complex domain
+    samples_fft = np.fft.fft(samples)
+    kernel[1:W+1] = samples[W-1::-1] # first half, reversed
+    kernel_fft = np.fft.fft(kernel)
+    r_t_tau = np.fft.ifft(samples_fft * kernel_fft).real[W:]
+    # compute yin_t(tau)
+    yin = sqdiff - 2 * r_t_tau
+    return yin
+
+def sqd_yintapered(samples):
+    """ compute tappered sum of squared difference
+
+    Brute-force computation (cost o(N**2), slow)."""
+    B = len(samples)
+    W = B//2
+    yin = np.zeros(W)
+    for tau in range(1, W):
+        for j in range(W - tau):
+            yin[tau] += (samples[j] - samples[j+tau])**2
+    return yin
+
+def sqd_yinfft(samples):
+    """ compute yinfft modified sum of squared differences
+
+    Very fast, improved performance in transients.
+
+    FIXME: biased."""
+    B = len(samples)
+    W = B//2
+    yin = np.zeros(W)
+    def hanningz(W):
+        return .5 * (1. - np.cos(2. * np.pi * np.arange(W) / W))
+    #win = np.ones(B)
+    win = hanningz(B)
+    sqrmag = np.zeros(B)
+    fftout = np.fft.fft(win*samples)
+    sqrmag[0] = fftout[0].real**2
+    for l in range(1, W):
+        sqrmag[l] = fftout[l].real**2 + fftout[l].imag**2
+        sqrmag[B-l] = sqrmag[l]
+    sqrmag[W] = fftout[W].real**2
+    fftout = np.fft.fft(sqrmag)
+    sqrsum = 2.*sqrmag[:W + 1].sum()
+    yin[0] = 0
+    yin[1:] = sqrsum - fftout.real[1:W]
+    return yin / B
+
+def cumdiff(yin):
+    """ compute the cumulative mean normalized difference """
+    W = len(yin)
+    yin[0] = 1.
+    cumsum = 0.
+    for tau in range(1, W):
+        cumsum += yin[tau]
+        if cumsum != 0:
+            yin[tau] *= tau/cumsum
+        else:
+            yin[tau] = 1
+    return yin
+
+def compute_all(x):
+    import time
+    now = time.time()
+
+    yin     = sqd_yin(x)
+    t1 = time.time()
+    print ("yin took %.2fms" % ((t1-now) * 1000.))
+
+    yinfast = sqd_yinfast(x)
+    t2 = time.time()
+    print ("yinfast took: %.2fms" % ((t2-t1) * 1000.))
+
+    yintapered = sqd_yintapered(x)
+    t3 = time.time()
+    print ("yintapered took: %.2fms" % ((t3-t2) * 1000.))
+
+    yinfft  = sqd_yinfft(x)
+    t4 = time.time()
+    print ("yinfft took: %.2fms" % ((t4-t3) * 1000.))
+
+    return yin, yinfast, yintapered, yinfft
+
+def plot_all(yin, yinfast, yintapered, yinfft):
+    fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True, sharey='col')
+
+    axes[0, 0].plot(yin, label='yin')
+    axes[0, 0].plot(yintapered, label='yintapered')
+    axes[0, 0].set_ylim(bottom=0)
+    axes[0, 0].legend()
+    axes[1, 0].plot(yinfast, '-', label='yinfast')
+    axes[1, 0].plot(yinfft, label='yinfft')
+    axes[1, 0].legend()
+
+    axes[0, 1].plot(cumdiff(yin), label='yin')
+    axes[0, 1].plot(cumdiff(yintapered), label='yin tapered')
+    axes[0, 1].set_ylim(bottom=0)
+    axes[0, 1].legend()
+    axes[1, 1].plot(cumdiff(yinfast), '-', label='yinfast')
+    axes[1, 1].plot(cumdiff(yinfft), label='yinfft')
+    axes[1, 1].legend()
+
+    fig.tight_layout()
+
+testfreqs = [441., 800., 10000., 40.]
+
+if len(sys.argv) > 1:
+    testfreqs = map(float,sys.argv[1:])
+
+for f in testfreqs:
+    print ("Comparing yin implementations for sine wave at %.fHz" % f)
+    samplerate = 44100.
+    win_s = 4096
+
+    x = np.cos(2.*np.pi * np.arange(win_s) * f / samplerate)
+
+    n_times = 1#00
+    for n in range(n_times):
+        yin, yinfast, yinfftslow, yinfft = compute_all(x)
+    if 0: # plot difference
+        plt.plot(yin-yinfast)
+        plt.tight_layout()
+        plt.show()
+    if 1:
+        plt.plot(yinfftslow-yinfft)
+        plt.tight_layout()
+        plt.show()
+    plot_all(yin, yinfast, yinfftslow, yinfft)
+plt.show()
index f4abe87..cebfc94 100644 (file)
@@ -30,6 +30,7 @@ default_skip_objects = [
     'pitchspecacf',
     'pitchyin',
     'pitchyinfft',
+    'pitchyinfast',
     'sink',
     'sink_apple_audio',
     'sink_sndfile',
index 00c8eea..749c37b 100755 (executable)
@@ -70,8 +70,8 @@ class aubio_pitch_Sinusoid(TestCase):
         #print 'len(pitches), cut:', len(pitches), cut
         #print 'median errors: ', median(errors), 'median pitches: ', median(pitches)
 
-pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" , "specacf" ]
-pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" ]
+pitch_algorithms = [ "default", "yinfft", "yin", "yinfast", "schmitt", "mcomb", "fcomb" , "specacf" ]
+pitch_algorithms = [ "default", "yinfft", "yin", "yinfast", "schmitt", "mcomb", "fcomb" ]
 
 #freqs = [ 27.5, 55., 110., 220., 440., 880., 1760., 3520. ]
 freqs = [             110., 220., 440., 880., 1760., 3520. ]
index 6a2ca4e..0d02136 100644 (file)
@@ -214,6 +214,7 @@ extern "C"
 #include "pitch/pitchmcomb.h"
 #include "pitch/pitchyin.h"
 #include "pitch/pitchyinfft.h"
+#include "pitch/pitchyinfast.h"
 #include "pitch/pitchschmitt.h"
 #include "pitch/pitchfcomb.h"
 #include "pitch/pitchspecacf.h"
index 9febb36..40cd7fc 100644 (file)
@@ -32,6 +32,7 @@
 #include "pitch/pitchfcomb.h"
 #include "pitch/pitchschmitt.h"
 #include "pitch/pitchyinfft.h"
+#include "pitch/pitchyinfast.h"
 #include "pitch/pitchspecacf.h"
 #include "pitch/pitch.h"
 
@@ -45,6 +46,7 @@ typedef enum
   aubio_pitcht_schmitt,    /**< `schmitt`, Schmitt trigger */
   aubio_pitcht_fcomb,      /**< `fcomb`, Fast comb filter */
   aubio_pitcht_yinfft,     /**< `yinfft`, Spectral YIN */
+  aubio_pitcht_yinfast,    /**< `yinfast`, YIN fast */
   aubio_pitcht_specacf,    /**< `specacf`, Spectral autocorrelation */
   aubio_pitcht_default
     = aubio_pitcht_yinfft, /**< `default` */
@@ -94,6 +96,7 @@ static void aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t *
 static void aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
 static void aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
 static void aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
+static void aubio_pitch_do_yinfast (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
 static void aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
 
 /* internal functions for frequency conversion */
@@ -117,6 +120,8 @@ new_aubio_pitch (const char_t * pitch_mode,
   }
   if (strcmp (pitch_mode, "mcomb") == 0)
     pitch_type = aubio_pitcht_mcomb;
+  else if (strcmp (pitch_mode, "yinfast") == 0)
+    pitch_type = aubio_pitcht_yinfast;
   else if (strcmp (pitch_mode, "yinfft") == 0)
     pitch_type = aubio_pitcht_yinfft;
   else if (strcmp (pitch_mode, "yin") == 0)
@@ -192,6 +197,14 @@ new_aubio_pitch (const char_t * pitch_mode,
       p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfft_get_confidence;
       aubio_pitchyinfft_set_tolerance (p->p_object, 0.85);
       break;
+    case aubio_pitcht_yinfast:
+      p->buf = new_fvec (bufsize);
+      p->p_object = new_aubio_pitchyinfast (bufsize);
+      if (!p->p_object) goto beach;
+      p->detect_cb = aubio_pitch_do_yinfast;
+      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfast_get_confidence;
+      aubio_pitchyinfast_set_tolerance (p->p_object, 0.15);
+      break;
     case aubio_pitcht_specacf:
       p->buf = new_fvec (bufsize);
       p->p_object = new_aubio_pitchspecacf (bufsize);
@@ -239,6 +252,10 @@ del_aubio_pitch (aubio_pitch_t * p)
       del_fvec (p->buf);
       del_aubio_pitchyinfft (p->p_object);
       break;
+    case aubio_pitcht_yinfast:
+      del_fvec (p->buf);
+      del_aubio_pitchyinfast (p->p_object);
+      break;
     case aubio_pitcht_specacf:
       del_fvec (p->buf);
       del_aubio_pitchspecacf (p->p_object);
@@ -329,6 +346,9 @@ aubio_pitch_set_tolerance (aubio_pitch_t * p, smpl_t tol)
     case aubio_pitcht_yinfft:
       aubio_pitchyinfft_set_tolerance (p->p_object, tol);
       break;
+    case aubio_pitcht_yinfast:
+      aubio_pitchyinfast_set_tolerance (p->p_object, tol);
+      break;
     default:
       break;
   }
@@ -346,6 +366,9 @@ aubio_pitch_get_tolerance (aubio_pitch_t * p)
     case aubio_pitcht_yinfft:
       tolerance = aubio_pitchyinfft_get_tolerance (p->p_object);
       break;
+    case aubio_pitcht_yinfast:
+      tolerance = aubio_pitchyinfast_get_tolerance (p->p_object);
+      break;
     default:
       break;
   }
@@ -424,6 +447,21 @@ aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
 }
 
 void
+aubio_pitch_do_yinfast (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
+{
+  smpl_t pitch = 0.;
+  aubio_pitch_slideblock (p, ibuf);
+  aubio_pitchyinfast_do (p->p_object, p->buf, obuf);
+  pitch = obuf->data[0];
+  if (pitch > 0) {
+    pitch = p->samplerate / (pitch + 0.);
+  } else {
+    pitch = 0.;
+  }
+  obuf->data[0] = pitch;
+}
+
+void
 aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out)
 {
   smpl_t pitch = 0., period;
index 253ee64..b807a6a 100644 (file)
@@ -81,6 +81,11 @@ extern "C" {
 
   see http://recherche.ircam.fr/equipes/pcm/pub/people/cheveign.html
 
+  \b \p yinfast : Yinfast algorithm
+
+  This algorithm is equivalent to the YIN algorithm, but computed in the
+  spectral domain for efficiency. See also `python/demos/demo_yin_compare.py`.
+
   \b \p yinfft : Yinfft algorithm
 
   This algorithm was derived from the YIN algorithm. In this implementation, a
diff --git a/src/pitch/pitchyinfast.c b/src/pitch/pitchyinfast.c
new file mode 100644 (file)
index 0000000..45d312f
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+  Copyright (C) 2003-2017 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  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.
+
+  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/>.
+
+*/
+
+/* This algorithm was developed by A. de Cheveigné and H. Kawahara and
+ * published in:
+ *
+ * de Cheveigné, A., Kawahara, H. (2002) "YIN, a fundamental frequency
+ * estimator for speech and music", J. Acoust. Soc. Am. 111, 1917-1930.
+ *
+ * see http://recherche.ircam.fr/equipes/pcm/pub/people/cheveign.html
+ */
+
+#include "aubio_priv.h"
+#include "fvec.h"
+#include "mathutils.h"
+#include "cvec.h"
+#include "spectral/fft.h"
+#include "pitch/pitchyinfast.h"
+
+struct _aubio_pitchyinfast_t
+{
+  fvec_t *yin;
+  smpl_t tol;
+  smpl_t confidence;
+  fvec_t *tmpdata;
+  fvec_t *sqdiff;
+  fvec_t *kernel;
+  fvec_t *samples_fft;
+  fvec_t *kernel_fft;
+  aubio_fft_t *fft;
+};
+
+aubio_pitchyinfast_t *
+new_aubio_pitchyinfast (uint_t bufsize)
+{
+  aubio_pitchyinfast_t *o = AUBIO_NEW (aubio_pitchyinfast_t);
+  o->yin = new_fvec (bufsize / 2);
+  o->tmpdata = new_fvec (bufsize);
+  o->sqdiff = new_fvec (bufsize / 2);
+  o->kernel = new_fvec (bufsize);
+  o->samples_fft = new_fvec (bufsize);
+  o->kernel_fft = new_fvec (bufsize);
+  o->fft = new_aubio_fft (bufsize);
+  o->tol = 0.15;
+  return o;
+}
+
+void
+del_aubio_pitchyinfast (aubio_pitchyinfast_t * o)
+{
+  del_fvec (o->yin);
+  del_fvec (o->tmpdata);
+  del_fvec (o->sqdiff);
+  del_fvec (o->kernel);
+  del_fvec (o->samples_fft);
+  del_fvec (o->kernel_fft);
+  del_aubio_fft (o->fft);
+  AUBIO_FREE (o);
+}
+
+/* all the above in one */
+void
+aubio_pitchyinfast_do (aubio_pitchyinfast_t * o, const fvec_t * input, fvec_t * out)
+{
+  const smpl_t tol = o->tol;
+  fvec_t* yin = o->yin;
+  const uint_t length = yin->length;
+  uint_t B = o->tmpdata->length;
+  uint_t W = o->yin->length; // B / 2
+  fvec_t tmp_slice, kernel_ptr;
+  smpl_t *yin_data = yin->data;
+  uint_t tau;
+  sint_t period;
+  smpl_t tmp2 = 0.;
+
+  // compute r_t(0) + r_t+tau(0)
+  {
+    fvec_t *squares = o->tmpdata;
+    fvec_weighted_copy(input, input, squares);
+#if 0
+    for (tau = 0; tau < W; tau++) {
+      tmp_slice.data = squares->data + tau;
+      tmp_slice.length = W;
+      o->sqdiff->data[tau] = fvec_sum(&tmp_slice);
+    }
+#else
+    tmp_slice.data = squares->data;
+    tmp_slice.length = W;
+    o->sqdiff->data[0] = fvec_sum(&tmp_slice);
+    for (tau = 1; tau < W; tau++) {
+      o->sqdiff->data[tau] = o->sqdiff->data[tau-1];
+      o->sqdiff->data[tau] -= squares->data[tau-1];
+      o->sqdiff->data[tau] += squares->data[W+tau-1];
+    }
+#endif
+    fvec_add(o->sqdiff, o->sqdiff->data[0]);
+  }
+  // compute r_t(tau) = -2.*ifft(fft(samples)*fft(samples[W-1::-1]))
+  {
+    fvec_t *compmul = o->tmpdata;
+    fvec_t *rt_of_tau = o->samples_fft;
+    aubio_fft_do_complex(o->fft, input, o->samples_fft);
+    // build kernel, take a copy of first half of samples
+    tmp_slice.data = input->data;
+    tmp_slice.length = W;
+    kernel_ptr.data = o->kernel->data + 1;
+    kernel_ptr.length = W;
+    fvec_copy(&tmp_slice, &kernel_ptr);
+    // reverse them
+    fvec_rev(&kernel_ptr);
+    // compute fft(kernel)
+    aubio_fft_do_complex(o->fft, o->kernel, o->kernel_fft);
+    // compute complex product
+    compmul->data[0]  = o->kernel_fft->data[0] * o->samples_fft->data[0];
+    for (tau = 1; tau < W; tau++) {
+      compmul->data[tau]    = o->kernel_fft->data[tau] * o->samples_fft->data[tau];
+      compmul->data[tau]   -= o->kernel_fft->data[B-tau] * o->samples_fft->data[B-tau];
+    }
+    compmul->data[W]    = o->kernel_fft->data[W] * o->samples_fft->data[W];
+    for (tau = 1; tau < W; tau++) {
+      compmul->data[B-tau]  = o->kernel_fft->data[B-tau] * o->samples_fft->data[tau];
+      compmul->data[B-tau] += o->kernel_fft->data[tau] * o->samples_fft->data[B-tau];
+    }
+    // compute inverse fft
+    aubio_fft_rdo_complex(o->fft, compmul, rt_of_tau);
+    // compute square difference r_t(tau) = sqdiff - 2 * r_t_tau[W-1:-1]
+    for (tau = 0; tau < W; tau++) {
+      yin_data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W];
+    }
+  }
+
+  // now build yin and look for first minimum
+  fvec_set_all(out, 0.);
+  yin_data[0] = 1.;
+  for (tau = 1; tau < length; tau++) {
+    tmp2 += yin_data[tau];
+    if (tmp2 != 0) {
+      yin->data[tau] *= tau / tmp2;
+    } else {
+      yin->data[tau] = 1.;
+    }
+    period = tau - 3;
+    if (tau > 4 && (yin_data[period] < tol) &&
+        (yin_data[period] < yin_data[period + 1])) {
+      out->data[0] = fvec_quadratic_peak_pos (yin, period);
+      goto beach;
+    }
+  }
+  out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin) );
+beach:
+  return;
+}
+
+smpl_t
+aubio_pitchyinfast_get_confidence (aubio_pitchyinfast_t * o) {
+  o->confidence = 1. - fvec_min (o->yin);
+  return o->confidence;
+}
+
+uint_t
+aubio_pitchyinfast_set_tolerance (aubio_pitchyinfast_t * o, smpl_t tol)
+{
+  o->tol = tol;
+  return 0;
+}
+
+smpl_t
+aubio_pitchyinfast_get_tolerance (aubio_pitchyinfast_t * o)
+{
+  return o->tol;
+}
diff --git a/src/pitch/pitchyinfast.h b/src/pitch/pitchyinfast.h
new file mode 100644 (file)
index 0000000..abb8139
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+  Copyright (C) 2003-2017 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  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.
+
+  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/>.
+
+*/
+
+/** \file
+
+  Pitch detection using YIN algorithm (fast implementation)
+
+  This algorithm was developed by A. de Cheveigne and H. Kawahara and
+  published in:
+
+  De Cheveigné, A., Kawahara, H. (2002) "YIN, a fundamental frequency
+  estimator for speech and music", J. Acoust. Soc. Am. 111, 1917-1930.
+
+  This implementation compute the autocorrelation function using time domain
+  convolution computed in the spectral domain.
+
+  see http://recherche.ircam.fr/equipes/pcm/pub/people/cheveign.html
+      http://recherche.ircam.fr/equipes/pcm/cheveign/ps/2002_JASA_YIN_proof.pdf
+
+*/
+
+#ifndef AUBIO_PITCHYINFAST_H
+#define AUBIO_PITCHYINFAST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** pitch detection object */
+typedef struct _aubio_pitchyinfast_t aubio_pitchyinfast_t;
+
+/** creation of the pitch detection object
+
+  \param buf_size size of the input buffer to analyse
+
+*/
+aubio_pitchyinfast_t *new_aubio_pitchyinfast (uint_t buf_size);
+
+/** deletion of the pitch detection object
+
+  \param o pitch detection object as returned by new_aubio_pitchyin()
+
+*/
+void del_aubio_pitchyinfast (aubio_pitchyinfast_t * o);
+
+/** execute pitch detection an input buffer
+
+  \param o pitch detection object as returned by new_aubio_pitchyin()
+  \param samples_in input signal vector (length as specified at creation time)
+  \param cands_out pitch period candidates, in samples
+
+*/
+void aubio_pitchyinfast_do (aubio_pitchyinfast_t * o, const fvec_t * samples_in, fvec_t * cands_out);
+
+
+/** set tolerance parameter for YIN algorithm
+
+  \param o YIN pitch detection object
+  \param tol tolerance parameter for minima selection [default 0.15]
+
+*/
+uint_t aubio_pitchyinfast_set_tolerance (aubio_pitchyinfast_t * o, smpl_t tol);
+
+/** get tolerance parameter for YIN algorithm
+
+  \param o YIN pitch detection object
+  \return tolerance parameter for minima selection [default 0.15]
+
+*/
+smpl_t aubio_pitchyinfast_get_tolerance (aubio_pitchyinfast_t * o);
+
+/** get current confidence of YIN algorithm
+
+  \param o YIN pitch detection object
+  \return confidence parameter
+
+*/
+smpl_t aubio_pitchyinfast_get_confidence (aubio_pitchyinfast_t * o);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AUBIO_PITCHYINFAST_H */
+