Changeset d4c5de7 for examples/utils.c
- Timestamp:
- Oct 16, 2009, 11:03:08 PM (15 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, pitchshift, sampler, timestretch, yinfft+
- Children:
- 6107f4c
- Parents:
- 2828382
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/utils.c
r2828382 rd4c5de7 16 16 You should have received a copy of the GNU General Public License 17 17 along with aubio. If not, see <http://www.gnu.org/licenses/>. 18 19 */ 20 21 /** 22 23 This file includes some tools common to all examples. Code specific to the 24 algorithm performed by each program should go in the source file of that 25 program instead. 18 26 19 27 */ … … 41 49 int verbose = 0; 42 50 int usejack = 0; 43 int usedoubled = 1;44 51 int frames_delay = 0; 45 52 53 54 char_t * pitch_unit = "default"; 55 char_t * pitch_mode = "default"; 46 56 47 57 /* energy,specdiff,hfc,complexdomain,phase */ … … 58 68 aubio_sndfile_t *fileout = NULL; 59 69 60 aubio_pvoc_t *pv;61 70 fvec_t *ibuf; 62 71 fvec_t *obuf; 63 fvec_t *pitch_obuf;64 cvec_t *fftgrain;65 72 fvec_t *woodblock; 66 aubio_onsetdetection_t *o;67 fvec_t *onset;68 fvec_t *onset2;69 smpl_t isonset = 0;70 aubio_peakpicker_t *parms;71 72 73 /* pitch objects */74 smpl_t pitch = 0.;75 aubio_pitchdetection_t *pitchdet;76 char_t * pitch_unit = "default";77 char_t * pitch_mode = "default";78 uint_t median = 6;79 80 fvec_t *note_buffer = NULL;81 fvec_t *note_buffer2 = NULL;82 smpl_t curlevel = 0.;83 smpl_t maxonset = 0.;84 85 smpl_t curnote = 0.;86 smpl_t newnote = 0.;87 uint_t isready = 0;88 89 90 73 91 74 /* badly redeclare some things */ … … 93 76 smpl_t averaging; 94 77 const char *prog_name; 78 79 void flush_process (aubio_process_func_t process_func, 80 aubio_print_func_t print); 95 81 96 82 void … … 222 208 { 223 209 210 uint_t found_wood = 0; 224 211 225 212 aubio_sndfile_t *onsetfile = NULL; … … 230 217 if (output_filename || usejack) { 231 218 /* dummy assignement to keep egcs happy */ 232 isonset= (onsetfile = new_aubio_sndfile_ro (onset_filename)) ||219 found_wood = (onsetfile = new_aubio_sndfile_ro (onset_filename)) || 233 220 (onsetfile = new_aubio_sndfile_ro ("sounds/woodblock.aiff")) || 234 221 (onsetfile = new_aubio_sndfile_ro ("../sounds/woodblock.aiff")); … … 277 264 ibuf = new_fvec (overlap_size, channels); 278 265 obuf = new_fvec (overlap_size, channels); 279 fftgrain = new_cvec (buffer_size, channels);280 281 if (usepitch) {282 pitchdet = new_aubio_pitchdetection (pitch_mode, buffer_size * 4,283 overlap_size, channels, samplerate);284 aubio_pitchdetection_set_tolerance (pitchdet, 0.7);285 pitch_obuf = new_fvec (1, channels);286 287 if (median) {288 note_buffer = new_fvec (median, 1);289 note_buffer2 = new_fvec (median, 1);290 }291 }292 /* phase vocoder */293 pv = new_aubio_pvoc (buffer_size, overlap_size, channels);294 /* onsets */295 parms = new_aubio_peakpicker (threshold);296 o = new_aubio_onsetdetection (onset_mode, buffer_size, channels);297 onset = new_fvec (1, channels);298 266 299 267 } … … 303 271 examples_common_del (void) 304 272 { 305 if (usepitch) { 306 send_noteon (curnote, 0); 307 del_aubio_pitchdetection (pitchdet); 308 if (median) { 309 del_fvec (note_buffer); 310 del_fvec (note_buffer2); 311 } 312 del_fvec (pitch_obuf); 313 } 314 del_aubio_onsetdetection (o); 315 del_aubio_peakpicker (parms); 316 del_aubio_pvoc (pv); 273 del_fvec (ibuf); 317 274 del_fvec (obuf); 318 del_fvec (ibuf);319 del_cvec (fftgrain);320 del_fvec (onset);321 275 del_fvec (woodblock); 322 276 aubio_cleanup (); … … 355 309 while ((signed) overlap_size == aubio_sndfile_read (file, overlap_size, 356 310 ibuf)) { 357 isonset = 0;358 311 process_func (ibuf->data, obuf->data, overlap_size); 359 312 print (); … … 416 369 417 370 418 void419 note_append (fvec_t * note_buffer, smpl_t curnote)420 {421 uint_t i = 0;422 for (i = 0; i < note_buffer->length - 1; i++) {423 note_buffer->data[0][i] = note_buffer->data[0][i + 1];424 }425 note_buffer->data[0][note_buffer->length - 1] = curnote;426 return;427 }428 429 uint_t430 get_note (fvec_t * note_buffer, fvec_t * note_buffer2)431 {432 uint_t i = 0;433 for (i = 0; i < note_buffer->length; i++) {434 note_buffer2->data[0][i] = note_buffer->data[0][i];435 }436 return fvec_median (note_buffer2);437 }438 439 371 #if HAVE_LASH 440 372
Note: See TracChangeset
for help on using the changeset viewer.