Changeset 81abf91 for src/notes/notes.c
- Timestamp:
- Oct 30, 2018, 1:22:06 PM (5 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- 8986239
- Parents:
- 92948ab (diff), 4bc10e2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/notes/notes.c
r92948ab r81abf91 1 1 /* 2 Copyright (C) 2014 Paul Brossier <piem@aubio.org>2 Copyright (C) 2014-2018 Paul Brossier <piem@aubio.org> 3 3 4 4 This file is part of aubio. … … 26 26 27 27 #define AUBIO_DEFAULT_NOTES_SILENCE -70. 28 #define AUBIO_DEFAULT_NOTES_RELEASE_DROP 10. 28 29 // increase to 10. for .1 cent precision 29 30 // or to 100. for .01 cent precision … … 57 58 58 59 uint_t isready; 60 61 smpl_t last_onset_level; 62 smpl_t release_drop_level; 59 63 }; 60 64 … … 102 106 aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS); 103 107 108 o->last_onset_level = AUBIO_DEFAULT_NOTES_SILENCE; 109 o->release_drop_level = AUBIO_DEFAULT_NOTES_RELEASE_DROP; 110 104 111 return o; 105 112 … … 139 146 { 140 147 return aubio_onset_get_minioi_ms(o->onset); 148 } 149 150 uint_t aubio_notes_set_release_drop(aubio_notes_t *o, smpl_t release_drop_level) 151 { 152 uint_t err = AUBIO_OK; 153 if (release_drop_level <= 0.) { 154 AUBIO_ERR("notes: release_drop should be >= 0, got %f\n", release_drop_level); 155 err = AUBIO_FAIL; 156 } else { 157 o->release_drop_level = release_drop_level; 158 } 159 return err; 160 } 161 162 smpl_t aubio_notes_get_release_drop(const aubio_notes_t *o) 163 { 164 return o->release_drop_level; 141 165 } 142 166 … … 185 209 //notes->data[0] = o->curnote; 186 210 //notes->data[1] = 0.; 211 //AUBIO_WRN("notes: sending note-off at onset, not enough level\n"); 187 212 notes->data[2] = o->curnote; 188 213 } else { … … 192 217 /* kill old note */ 193 218 //send_noteon(o->curnote,0, o->samplerate); 219 //AUBIO_WRN("notes: sending note-off at onset, new onset detected\n"); 194 220 notes->data[2] = o->curnote; 195 221 /* get and send new one */ … … 199 225 o->curnote = new_pitch; 200 226 } 227 o->last_onset_level = curlevel; 201 228 } 202 229 } else { 203 if (o->median) { 230 if (curlevel < o->last_onset_level - o->release_drop_level) 231 { 232 // send note off 233 //AUBIO_WRN("notes: sending note-off, release detected\n"); 234 notes->data[0] = 0; 235 notes->data[1] = 0; 236 notes->data[2] = o->curnote; 237 // reset last_onset_level to silence_threshold 238 o->last_onset_level = o->silence_threshold; 239 o->curnote = 0; 240 } 241 else if (o->median) 242 { 204 243 if (o->isready > 0) 205 244 o->isready++; … … 208 247 /* kill old note */ 209 248 //send_noteon(curnote,0); 210 notes->data[2] = o->curnote; 249 if (o->curnote != 0) 250 { 251 //AUBIO_WRN("notes: sending note-off, new note detected\n"); 252 notes->data[2] = o->curnote; 253 } 211 254 o->newnote = aubio_notes_get_latest_note(o); 212 255 o->curnote = o->newnote;
Note: See TracChangeset
for help on using the changeset viewer.