Changes in / [cefa29d:4bc10e2]
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/aubionotes.txt
rcefa29d r4bc10e2 7 7 aubionotes [[-i] source] 8 8 [-r rate] [-B win] [-H hop] 9 [-O method] [-t thres] 9 [-O method] [-t thres] [-d drop] 10 10 [-p method] [-u unit] [-l thres] 11 11 [-T time-format] … … 69 69 loudest ones. A value of -90.0 would select all onsets. Defaults to -90.0. 70 70 71 -d, --release-drop Set the release drop threshold, in dB. If the level is 72 found to drop more than this amount since the last note has started, the 73 note will be turned-off. Defaults to 10. 74 71 75 -T, --timeformat format Set time format (samples, ms, seconds). Defaults to 72 76 seconds. -
examples/aubionotes.c
rcefa29d r4bc10e2 22 22 #define PROG_HAS_PITCH 1 23 23 #define PROG_HAS_ONSET 1 24 #define PROG_HAS_NOTES 1 24 25 #define PROG_HAS_SILENCE 1 25 26 #define PROG_HAS_JACK 1 … … 83 84 } 84 85 } 86 if (release_drop != 10.) { 87 if (aubio_notes_set_release_drop (notes, release_drop) != 0) { 88 errmsg ("failed setting notes release drop to %.2f\n", 89 release_drop); 90 } 91 } 85 92 86 93 examples_common_process((aubio_process_func_t)process_block, process_print); -
examples/parse_args.h
rcefa29d r4bc10e2 48 48 // more general stuff 49 49 extern smpl_t silence_threshold; 50 extern smpl_t release_drop; 50 51 extern uint_t mix_input; 51 52 // midi tap … … 108 109 " a value in dB, for instance -70, or -100; default=-90\n" 109 110 #endif /* PROG_HAS_SILENCE */ 111 #ifdef PROG_HAS_NOTES 112 " -d --release-drop select release drop threshold\n" 113 " a positive value in dB; default=10\n" 114 #endif 110 115 " -T --time-format select time values output format\n" 111 116 " (samples, ms, seconds) default=seconds\n" … … 158 163 "s:" 159 164 #endif /* PROG_HAS_SILENCE */ 165 #ifdef PROG_HAS_NOTES 166 "d:" 167 #endif /* PROG_HAS_SILENCE */ 160 168 #ifdef PROG_HAS_OUTPUT 161 169 "mf" … … 193 201 {"silence", 1, NULL, 's'}, 194 202 #endif /* PROG_HAS_SILENCE */ 203 #ifdef PROG_HAS_NOTES 204 {"release-drop", 1, NULL, 'd'}, 205 #endif /* PROG_HAS_NOTES */ 195 206 {"time-format", 1, NULL, 'T'}, 196 207 #ifdef PROG_HAS_OUTPUT … … 274 285 case 's': /* silence threshold */ 275 286 silence_threshold = (smpl_t) atof (optarg); 287 break; 288 case 'd': /* release-drop threshold */ 289 release_drop = (smpl_t) atof (optarg); 276 290 break; 277 291 case 'm': /* mix_input flag */ -
examples/utils.c
rcefa29d r4bc10e2 55 55 // more general stuff 56 56 smpl_t silence_threshold = -90.; 57 smpl_t release_drop = 10.; 57 58 uint_t mix_input = 0; 58 59 -
python/lib/aubio/cmd.py
rcefa29d r4bc10e2 102 102 subparser.add_input() 103 103 subparser.add_buf_hop_size() 104 subparser.add_silence() 105 subparser.add_release_drop() 104 106 subparser.add_time_format() 105 107 subparser.add_verbose_help() … … 207 209 action="store", dest="silence", default=-70, 208 210 help="silence threshold") 211 212 def add_release_drop(self): 213 self.add_argument("-d", "--release-drop", 214 metavar = "<value>", type=float, 215 action="store", dest="release_drop", default=10, 216 help="release drop threshold") 209 217 210 218 def add_minioi(self, default="12ms"): … … 383 391 self.parse_options(args, self.valid_opts) 384 392 self.notes = aubio.notes(**self.options) 393 if args.silence is not None: 394 self.notes.set_silence(args.silence) 395 if args.release_drop is not None: 396 self.notes.set_release_drop(args.release_drop) 385 397 super(process_notes, self).__init__(args) 386 398 def __call__(self, block): -
python/tests/test_notes.py
rcefa29d r4bc10e2 6 6 7 7 AUBIO_DEFAULT_NOTES_SILENCE = -70. 8 AUBIO_DEFAULT_NOTES_RELEASE_DROP = 10. 8 9 AUBIO_DEFAULT_NOTES_MINIOI_MS = 30. 9 10 … … 38 39 self.o.set_silence(val) 39 40 assert_equal (self.o.get_silence(), val) 41 42 def test_get_release_drop(self): 43 assert_equal (self.o.get_release_drop(), AUBIO_DEFAULT_NOTES_RELEASE_DROP) 44 45 def test_set_release_drop(self): 46 val = 50 47 self.o.set_release_drop(val) 48 assert_equal (self.o.get_release_drop(), val) 49 50 def test_set_release_drop_wrong(self): 51 val = -10 52 with self.assertRaises(ValueError): 53 self.o.set_release_drop(val) 40 54 41 55 from .utils import list_all_sounds -
src/notes/notes.c
rcefa29d r4bc10e2 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; -
src/notes/notes.h
rcefa29d r4bc10e2 107 107 uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms); 108 108 109 /** get notes object release drop level, in dB 110 111 \param o notes detection object as returned by new_aubio_notes() 112 113 \return current release drop level, in dB 114 115 */ 116 smpl_t aubio_notes_get_release_drop (const aubio_notes_t *o); 117 118 /** set note release drop level, in dB 119 120 This function sets the release_drop_level parameter, in dB. When a new note 121 is found, the current level in dB is measured. If the measured level drops 122 under that initial level - release_drop_level, then a note-off will be 123 emitted. 124 125 Defaults to `10`, in dB. 126 127 \note This parameter was added in version `0.4.8`. Results obtained with 128 earlier versions can be reproduced by setting this value to `100`, so that 129 note-off will not be played until the next note. 130 131 \param o notes detection object as returned by new_aubio_notes() 132 \param release_drop new release drop level, in dB 133 134 \return 0 on success, non-zero otherwise 135 136 */ 137 uint_t aubio_notes_set_release_drop (aubio_notes_t *o, smpl_t release_drop); 138 109 139 #ifdef __cplusplus 110 140 }
Note: See TracChangeset
for help on using the changeset viewer.