Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/notes/notes.c

    r1f6a9f8 r790b6d7  
    2424#include "onset/onset.h"
    2525#include "notes/notes.h"
    26 
    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.
    3226
    3327struct _aubio_notes_t {
     
    8579  o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate);
    8680  if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance);
    87   aubio_pitch_set_unit (o->pitch, "midi");
    8881  o->pitch_output = new_fvec (1);
    8982
     
    9891  o->newnote = 0.;
    9992
    100   aubio_notes_set_silence(o, AUBIO_DEFAULT_NOTES_SILENCE);
    101   aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS);
     93  o->silence_threshold = -90.;
    10294
    10395  return o;
     
    10698  del_aubio_notes(o);
    10799  return NULL;
    108 }
    109 
    110 uint_t aubio_notes_set_silence(aubio_notes_t *o, smpl_t silence)
    111 {
    112   uint_t err = AUBIO_OK;
    113   if (aubio_pitch_set_silence(o->pitch, silence) != AUBIO_OK) {
    114     err = AUBIO_FAIL;
    115   }
    116   if (aubio_onset_set_silence(o->onset, silence) != AUBIO_OK) {
    117     err = AUBIO_FAIL;
    118   }
    119   o->silence_threshold = silence;
    120   return err;
    121 }
    122 
    123 smpl_t aubio_notes_get_silence(const aubio_notes_t *o)
    124 {
    125   return aubio_pitch_get_silence(o->pitch);
    126 }
    127 
    128 uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms)
    129 {
    130   uint_t err = AUBIO_OK;
    131   if (!o->onset || (aubio_onset_set_minioi_ms(o->onset, minioi_ms) != 0)) {
    132     err = AUBIO_FAIL;
    133   }
    134   return err;
    135 }
    136 
    137 smpl_t aubio_notes_get_minioi_ms(const aubio_notes_t *o)
    138 {
    139   return aubio_onset_get_minioi_ms(o->onset);
    140100}
    141101
     
    149109    note_buffer->data[i] = note_buffer->data[i + 1];
    150110  }
    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);
     111  note_buffer->data[note_buffer->length - 1] = curnote;
    153112  return;
    154113}
    155114
    156 static smpl_t
     115static uint_t
    157116aubio_notes_get_latest_note (aubio_notes_t *o)
    158117{
    159   fvec_copy(o->note_buffer, o->note_buffer2);
    160   return fvec_median (o->note_buffer2) / AUBIO_DEFAULT_CENT_PRECISION;
     118  uint_t i;
     119  for (i = 0; i < o->note_buffer->length; i++) {
     120    o->note_buffer2->data[i] = o->note_buffer->data[i];
     121  }
     122  return fvec_median (o->note_buffer2);
    161123}
    162124
Note: See TracChangeset for help on using the changeset viewer.