Changeset 95dc7f2 for src/pitch


Ignore:
Timestamp:
Apr 8, 2013, 6:50:55 PM (12 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, pitchshift, sampler, timestretch, yinfft+
Children:
0e75589
Parents:
ea912cc
Message:

src/pitch/: add first draft for specacf

Location:
src/pitch
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitch.c

    rea912cc r95dc7f2  
    3333#include "pitch/pitchschmitt.h"
    3434#include "pitch/pitchyinfft.h"
     35#include "pitch/pitchspecacf.h"
    3536#include "pitch/pitch.h"
    3637
     
    4344  aubio_pitcht_fcomb,      /**< `fcomb`, Fast comb filter */
    4445  aubio_pitcht_yinfft,     /**< `yinfft`, Spectral YIN */
     46  aubio_pitcht_specacf,    /**< `specacf`, Spectral autocorrelation */
    4547  aubio_pitcht_default
    4648    = aubio_pitcht_yinfft, /**< `default` */
     
    8991static void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    9092static void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
     93static void aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    9194
    9295/* conversion functions for frequency conversions */
     
    115118  else if (strcmp (pitch_mode, "fcomb") == 0)
    116119    pitch_type = aubio_pitcht_fcomb;
     120  else if (strcmp (pitch_mode, "specacf") == 0)
     121    pitch_type = aubio_pitcht_specacf;
    117122  else if (strcmp (pitch_mode, "default") == 0)
    118123    pitch_type = aubio_pitcht_default;
     
    159164      aubio_pitchyinfft_set_tolerance (p->p_object, 0.85);
    160165      break;
     166    case aubio_pitcht_specacf:
     167      p->buf = new_fvec (bufsize);
     168      p->p_object = new_aubio_pitchspecacf (bufsize);
     169      p->detect_cb = aubio_pitch_do_specacf;
     170      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchspecacf_get_tolerance;
     171      aubio_pitchspecacf_set_tolerance (p->p_object, 0.85);
     172      break;
    161173    default:
    162174      break;
     
    190202      del_fvec (p->buf);
    191203      del_aubio_pitchyinfft (p->p_object);
     204      break;
     205    case aubio_pitcht_specacf:
     206      del_fvec (p->buf);
     207      del_aubio_pitchspecacf (p->p_object);
    192208      break;
    193209    default:
     
    316332
    317333void
     334aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)
     335{
     336  aubio_pitch_slideblock (p, ibuf);
     337  aubio_pitchspecacf_do (p->p_object, p->buf, out);
     338  //out->data[0] = aubio_bintofreq (out->data[0], p->samplerate, p->bufsize);
     339  smpl_t pitch = 0., period = out->data[0];
     340  if (period > 0) {
     341    pitch = p->samplerate / period;
     342  } else {
     343    pitch = 0.;
     344  }
     345  out->data[0] = pitch;
     346}
     347
     348void
    318349aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)
    319350{
Note: See TracChangeset for help on using the changeset viewer.