Changeset c268bf2 for src


Ignore:
Timestamp:
May 9, 2017, 4:04:03 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
48fa81d
Parents:
67b2dbcc
Message:

src/pitch/pitch.c: add yinfast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitch.c

    r67b2dbcc rc268bf2  
    3333#include "pitch/pitchschmitt.h"
    3434#include "pitch/pitchyinfft.h"
     35#include "pitch/pitchyinfast.h"
    3536#include "pitch/pitchspecacf.h"
    3637#include "pitch/pitch.h"
     
    4647  aubio_pitcht_fcomb,      /**< `fcomb`, Fast comb filter */
    4748  aubio_pitcht_yinfft,     /**< `yinfft`, Spectral YIN */
     49  aubio_pitcht_yinfast,    /**< `yinfast`, YIN fast */
    4850  aubio_pitcht_specacf,    /**< `specacf`, Spectral autocorrelation */
    4951  aubio_pitcht_default
     
    9597static void aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
    9698static void aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
     99static void aubio_pitch_do_yinfast (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
    97100static void aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
    98101
     
    118121  if (strcmp (pitch_mode, "mcomb") == 0)
    119122    pitch_type = aubio_pitcht_mcomb;
     123  else if (strcmp (pitch_mode, "yinfast") == 0)
     124    pitch_type = aubio_pitcht_yinfast;
    120125  else if (strcmp (pitch_mode, "yinfft") == 0)
    121126    pitch_type = aubio_pitcht_yinfft;
     
    193198      aubio_pitchyinfft_set_tolerance (p->p_object, 0.85);
    194199      break;
     200    case aubio_pitcht_yinfast:
     201      p->buf = new_fvec (bufsize);
     202      p->p_object = new_aubio_pitchyinfast (bufsize);
     203      if (!p->p_object) goto beach;
     204      p->detect_cb = aubio_pitch_do_yinfast;
     205      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfast_get_confidence;
     206      aubio_pitchyinfast_set_tolerance (p->p_object, 0.15);
     207      break;
    195208    case aubio_pitcht_specacf:
    196209      p->buf = new_fvec (bufsize);
     
    239252      del_fvec (p->buf);
    240253      del_aubio_pitchyinfft (p->p_object);
     254      break;
     255    case aubio_pitcht_yinfast:
     256      del_fvec (p->buf);
     257      del_aubio_pitchyinfast (p->p_object);
    241258      break;
    242259    case aubio_pitcht_specacf:
     
    330347      aubio_pitchyinfft_set_tolerance (p->p_object, tol);
    331348      break;
     349    case aubio_pitcht_yinfast:
     350      aubio_pitchyinfast_set_tolerance (p->p_object, tol);
     351      break;
    332352    default:
    333353      break;
     
    346366    case aubio_pitcht_yinfft:
    347367      tolerance = aubio_pitchyinfft_get_tolerance (p->p_object);
     368      break;
     369    case aubio_pitcht_yinfast:
     370      tolerance = aubio_pitchyinfast_get_tolerance (p->p_object);
    348371      break;
    349372    default:
     
    415438  aubio_pitch_slideblock (p, ibuf);
    416439  aubio_pitchyinfft_do (p->p_object, p->buf, obuf);
     440  pitch = obuf->data[0];
     441  if (pitch > 0) {
     442    pitch = p->samplerate / (pitch + 0.);
     443  } else {
     444    pitch = 0.;
     445  }
     446  obuf->data[0] = pitch;
     447}
     448
     449void
     450aubio_pitch_do_yinfast (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
     451{
     452  smpl_t pitch = 0.;
     453  aubio_pitch_slideblock (p, ibuf);
     454  aubio_pitchyinfast_do (p->p_object, p->buf, obuf);
    417455  pitch = obuf->data[0];
    418456  if (pitch > 0) {
Note: See TracChangeset for help on using the changeset viewer.