From: Paul Brossier Date: Mon, 3 Oct 2016 18:46:46 +0000 (+0200) Subject: src/notes/notes.h: add _{get,set}_silence methods X-Git-Tag: 0.4.4~165 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=ffd10fbbcc040cb91eed9d657c0d31a31b909394;p=aubio.git src/notes/notes.h: add _{get,set}_silence methods --- diff --git a/src/notes/notes.c b/src/notes/notes.c index 79b2ffef..8a1b8cc3 100644 --- a/src/notes/notes.c +++ b/src/notes/notes.c @@ -24,6 +24,8 @@ #include "onset/onset.h" #include "notes/notes.h" +#define DEFAULT_NOTES_SILENCE -50. + struct _aubio_notes_t { uint_t onset_buf_size; @@ -90,7 +92,7 @@ aubio_notes_t * new_aubio_notes (const char_t * method, o->curnote = -1.; o->newnote = 0.; - o->silence_threshold = -90.; + aubio_notes_set_silence(o, DEFAULT_NOTES_SILENCE); return o; @@ -99,6 +101,23 @@ fail: return NULL; } +uint_t aubio_notes_set_silence(aubio_notes_t *o, smpl_t silence) +{ + uint_t err = AUBIO_OK; + if (aubio_pitch_set_silence(o->pitch, silence) != AUBIO_OK) { + err = AUBIO_FAIL; + } + if (aubio_onset_set_silence(o->onset, silence) != AUBIO_OK) { + err = AUBIO_FAIL; + } + return err; +} + +smpl_t aubio_notes_get_silence(const aubio_notes_t *o) +{ + return aubio_pitch_get_silence(o->pitch); +} + /** append new note candidate to the note_buffer and return filtered value. we * need to copy the input array as fvec_median destroy its input data.*/ static void diff --git a/src/notes/notes.h b/src/notes/notes.h index fc12bad2..eab95ee2 100644 --- a/src/notes/notes.h +++ b/src/notes/notes.h @@ -51,12 +51,34 @@ void del_aubio_notes(aubio_notes_t * o); /** execute note detection on an input signal frame \param o note detection object as returned by new_aubio_notes() - \param in input signal of size [hop_size] - \param out output notes of size [3] ? FIXME + \param input input signal of size [hop_size] + \param output output notes, fvec of length 3 + + The notes output is a vector of length 3 containing: + - 0. the midi note value, or 0 if no note was found + - 1. the note velocity + - 2. the midi note to turn off */ void aubio_notes_do (aubio_notes_t *o, const fvec_t * input, fvec_t * output); +/** set notes detection silence threshold + + \param o notes detection object as returned by new_aubio_notes() + \param silence new silence detection threshold + +*/ +uint_t aubio_notes_set_silence(aubio_notes_t * o, smpl_t silence); + +/** get notes detection silence threshold + + \param o notes detection object as returned by new_aubio_notes() + + \return current silence threshold + +*/ +smpl_t aubio_notes_get_silence(const aubio_notes_t * o); + #ifdef __cplusplus } #endif