Changeset 0b6a8a8 for src/notes


Ignore:
Timestamp:
Dec 17, 2016, 12:12:42 PM (7 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, sampler, yinfft+
Children:
6c85b3a
Parents:
17b08e6
Message:

src/notes/notes.c: use midi note to store pitch candidate, round to nearest note, add a variable to define precision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/notes/notes.c

    r17b08e6 r0b6a8a8  
    2525#include "notes/notes.h"
    2626
    27 #define DEFAULT_NOTES_SILENCE -50.
     27#define AUBIO_DEFAULT_NOTES_SILENCE -70.
     28// increase to 10. for .1  cent precision
     29//      or to 100. for .01 cent precision
     30#define AUBIO_DEFAULT_CENT_PRECISION 1.
     31#define AUBIO_DEFAULT_NOTES_MINIOI_MS 30.
    2832
    2933struct _aubio_notes_t {
     
    8185  o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate);
    8286  if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance);
     87  aubio_pitch_set_unit (o->pitch, "midi");
    8388  o->pitch_output = new_fvec (1);
    8489
     
    9398  o->newnote = 0.;
    9499
    95   aubio_notes_set_silence(o, DEFAULT_NOTES_SILENCE);
     100  aubio_notes_set_silence(o, AUBIO_DEFAULT_NOTES_SILENCE);
     101  aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS);
    96102
    97103  return o;
     
    143149    note_buffer->data[i] = note_buffer->data[i + 1];
    144150  }
    145   note_buffer->data[note_buffer->length - 1] = curnote;
     151  //note_buffer->data[note_buffer->length - 1] = ROUND(10.*curnote)/10.;
     152  note_buffer->data[note_buffer->length - 1] = ROUND(AUBIO_DEFAULT_CENT_PRECISION*curnote);
    146153  return;
    147154}
    148155
    149 static uint_t
     156static smpl_t
    150157aubio_notes_get_latest_note (aubio_notes_t *o)
    151158{
    152   uint_t i;
    153   for (i = 0; i < o->note_buffer->length; i++) {
    154     o->note_buffer2->data[i] = o->note_buffer->data[i];
    155   }
    156   return fvec_median (o->note_buffer2);
     159  fvec_copy(o->note_buffer, o->note_buffer2);
     160  return fvec_median (o->note_buffer2) / AUBIO_DEFAULT_CENT_PRECISION;
    157161}
    158162
Note: See TracChangeset for help on using the changeset viewer.