Changes in src/notes/notes.c [1f6a9f8:790b6d7]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/notes/notes.c
r1f6a9f8 r790b6d7 24 24 #include "onset/onset.h" 25 25 #include "notes/notes.h" 26 27 #define AUBIO_DEFAULT_NOTES_SILENCE -70.28 // increase to 10. for .1 cent precision29 // or to 100. for .01 cent precision30 #define AUBIO_DEFAULT_CENT_PRECISION 1.31 #define AUBIO_DEFAULT_NOTES_MINIOI_MS 30.32 26 33 27 struct _aubio_notes_t { … … 85 79 o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate); 86 80 if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance); 87 aubio_pitch_set_unit (o->pitch, "midi");88 81 o->pitch_output = new_fvec (1); 89 82 … … 98 91 o->newnote = 0.; 99 92 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.; 102 94 103 95 return o; … … 106 98 del_aubio_notes(o); 107 99 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);140 100 } 141 101 … … 149 109 note_buffer->data[i] = note_buffer->data[i + 1]; 150 110 } 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; 153 112 return; 154 113 } 155 114 156 static smpl_t115 static uint_t 157 116 aubio_notes_get_latest_note (aubio_notes_t *o) 158 117 { 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); 161 123 } 162 124
Note: See TracChangeset
for help on using the changeset viewer.