shithub: aubio

Download patch

ref: ffd10fbbcc040cb91eed9d657c0d31a31b909394
parent: 61a1e5d4835dffd7f352e05e25f798fb3c178179
author: Paul Brossier <piem@piem.org>
date: Mon Oct 3 16:46:46 EDT 2016

src/notes/notes.h: add _{get,set}_silence methods

--- 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 @@
   o->curnote = -1.;
   o->newnote = 0.;
 
-  o->silence_threshold = -90.;
+  aubio_notes_set_silence(o, DEFAULT_NOTES_SILENCE);
 
   return o;
 
@@ -97,6 +99,23 @@
 fail:
   del_aubio_notes(o);
   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
--- a/src/notes/notes.h
+++ b/src/notes/notes.h
@@ -51,11 +51,33 @@
 /** 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
 }