From c8bf888df19bc45aac2c0ea6eda54655df0b55b0 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 28 Sep 2016 02:17:35 +0200 Subject: [PATCH] src/aubiopitch~.c: parse method, return NULL if new_aubio_pitch failed --- src/aubiopitch~.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/aubiopitch~.c b/src/aubiopitch~.c index 1f188ca..4a9e4e8 100644 --- a/src/aubiopitch~.c +++ b/src/aubiopitch~.c @@ -24,6 +24,7 @@ typedef struct _aubiopitch_tilde t_int pos; /*frames%dspblocksize*/ t_int bufsize; t_int hopsize; + char_t *method; aubio_pitch_t *o; fvec_t *vec; fvec_t *pitchvec; @@ -75,9 +76,17 @@ static void *aubiopitch_tilde_new (t_symbol * s) x->bufsize = 2048; x->hopsize = x->bufsize / 2; - x->o = new_aubio_pitch(s->s_name, x->bufsize, - x->hopsize, (uint_t)sys_getsr() ); - aubio_pitch_set_tolerance (x->o, 0.7); + if (!*s->s_name) { + x->method = "default"; + } else { + x->method = s->s_name; + } + + x->o = new_aubio_pitch(x->method, x->bufsize, x->hopsize, + (uint_t)sys_getsr()); + + if (x->o == NULL) return NULL; + x->vec = (fvec_t *)new_fvec(x->hopsize); x->pitchvec = (fvec_t *)new_fvec(1); -- 2.11.0