Changes in src/notes/notes.c [790b6d7:1f6a9f8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/notes/notes.c
r790b6d7 r1f6a9f8 25 25 #include "notes/notes.h" 26 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. 32 27 33 struct _aubio_notes_t { 28 34 … … 79 85 o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate); 80 86 if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance); 87 aubio_pitch_set_unit (o->pitch, "midi"); 81 88 o->pitch_output = new_fvec (1); 82 89 … … 91 98 o->newnote = 0.; 92 99 93 o->silence_threshold = -90.; 100 aubio_notes_set_silence(o, AUBIO_DEFAULT_NOTES_SILENCE); 101 aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS); 94 102 95 103 return o; … … 98 106 del_aubio_notes(o); 99 107 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); 100 140 } 101 141 … … 109 149 note_buffer->data[i] = note_buffer->data[i + 1]; 110 150 } 111 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); 112 153 return; 113 154 } 114 155 115 static uint_t156 static smpl_t 116 157 aubio_notes_get_latest_note (aubio_notes_t *o) 117 158 { 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); 159 fvec_copy(o->note_buffer, o->note_buffer2); 160 return fvec_median (o->note_buffer2) / AUBIO_DEFAULT_CENT_PRECISION; 123 161 } 124 162
Note: See TracChangeset
for help on using the changeset viewer.