Changeset f5699b9 for src


Ignore:
Timestamp:
Dec 29, 2021, 5:51:57 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe
Children:
259c33b
Parents:
57630f6
git-author:
Paul Brossier <piem@piem.org> (01/08/19 16:50:03)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:51:57)
Message:

[pitch] add crepe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitch.c

    r57630f6 rf5699b9  
    4949  aubio_pitcht_yinfast,    /**< `yinfast`, YIN fast */
    5050  aubio_pitcht_specacf,    /**< `specacf`, Spectral autocorrelation */
     51  aubio_pitcht_crepe,      /**< `crepe`, convolutional neural network */
    5152  aubio_pitcht_default
    5253    = aubio_pitcht_yinfft, /**< `default` */
     
    99100static void aubio_pitch_do_yinfast (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
    100101static void aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
     102static void aubio_pitch_do_crepe (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf);
    101103
    102104/* internal functions for frequency conversion */
     
    104106static smpl_t freqconvmidi (smpl_t f, uint_t samplerate, uint_t bufsize);
    105107static smpl_t freqconvpass (smpl_t f, uint_t samplerate, uint_t bufsize);
     108
     109typedef struct _aubio_pitch_crepe_t aubio_pitch_crepe_t;
     110extern aubio_pitch_crepe_t *new_aubio_pitch_crepe(void);
     111extern void aubio_pitch_crepe_do(aubio_pitch_crepe_t *t, fvec_t *input, fvec_t *out);
     112extern void del_aubio_pitch_crepe(aubio_pitch_crepe_t *t);
     113extern smpl_t aubio_pitch_crepe_get_confidence (aubio_pitch_crepe_t * o);
     114uint_t aubio_pitch_crepe_set_tolerance(aubio_pitch_crepe_t * o, smpl_t
     115    tolerance);
     116smpl_t aubio_pitch_crepe_get_tolerance (aubio_pitch_crepe_t * o);
    106117
    107118/* adapter to stack ibuf new samples at the end of buf, and trim `buf` to `bufsize` */
     
    133144  else if (strcmp (pitch_mode, "specacf") == 0)
    134145    pitch_type = aubio_pitcht_specacf;
     146  else if (strcmp (pitch_mode, "crepe") == 0)
     147    pitch_type = aubio_pitcht_crepe;
    135148  else if (strcmp (pitch_mode, "default") == 0)
    136149    pitch_type = aubio_pitcht_default;
     
    214227      aubio_pitchspecacf_set_tolerance (p->p_object, 0.85);
    215228      break;
     229    case aubio_pitcht_crepe:
     230      p->buf = new_fvec (bufsize);
     231      p->p_object = new_aubio_pitch_crepe();
     232      if (!p->p_object) goto beach;
     233      p->detect_cb = aubio_pitch_do_crepe;
     234      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitch_crepe_get_confidence;
     235      //aubio_pitch_crepe_set_tolerance (p->p_object, 0.85);
     236      break;
    216237    default:
    217238      break;
     
    260281      del_fvec (p->buf);
    261282      del_aubio_pitchspecacf (p->p_object);
     283      break;
     284    case aubio_pitcht_crepe:
     285      del_fvec (p->buf);
     286      del_aubio_pitch_crepe (p->p_object);
    262287      break;
    263288    default:
     
    350375      aubio_pitchyinfast_set_tolerance (p->p_object, tol);
    351376      break;
     377    case aubio_pitcht_crepe:
     378      aubio_pitch_crepe_set_tolerance (p->p_object, tol);
     379      break;
    352380    default:
    353381      break;
     
    369397    case aubio_pitcht_yinfast:
    370398      tolerance = aubio_pitchyinfast_get_tolerance (p->p_object);
     399      break;
     400    case aubio_pitcht_crepe:
     401      tolerance = aubio_pitch_crepe_get_tolerance (p->p_object);
    371402      break;
    372403    default:
     
    479510
    480511void
     512aubio_pitch_do_crepe (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out)
     513{
     514  //smpl_t pitch = 0., period;
     515  aubio_pitch_slideblock (p, ibuf);
     516  aubio_pitch_crepe_do(p->p_object, p->buf, out);
     517  out->data[0] = aubio_miditofreq(out->data[0]);
     518}
     519
     520void
    481521aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out)
    482522{
Note: See TracChangeset for help on using the changeset viewer.