Ignore:
Timestamp:
Oct 16, 2009, 11:03:08 PM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

examples/: make use of aubio_onset in aubioonset and aubionotes, simplify, keep only general stuff in utils

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/aubioonset.c

    r2828382 rd4c5de7  
    2020
    2121unsigned int pos = 0; /*frames%dspblocksize*/
    22 uint_t usepitch = 0;
    2322
    24 int aubio_process(smpl_t **input, smpl_t **output, int nframes);
    25 int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
     23aubio_onset_t *o;
     24fvec_t *onset;
     25
     26static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    2627  unsigned int i;       /*channels*/
    2728  unsigned int j;       /*frames*/
     
    3839    if (pos == overlap_size-1) {         
    3940      /* block loop */
    40       aubio_pvoc_do (pv,ibuf, fftgrain);
    41       aubio_onsetdetection_do (o,fftgrain, onset);
    42       isonset = aubio_peakpicker_do(parms, onset);
    43       if (isonset) {
    44         /* test for silence */
    45         if (aubio_silence_detection(ibuf, silence)==1)
    46           isonset=0.;
    47         else
    48           for (pos = 0; pos < overlap_size; pos++){
    49             obuf->data[0][pos] = woodblock->data[0][pos];
    50           }
     41      aubio_onset_do (o, ibuf, onset);
     42      if (fvec_read_sample(onset, 0, 0)) {
     43        for (pos = 0; pos < overlap_size; pos++){
     44          obuf->data[0][pos] = woodblock->data[0][pos];
     45        }
    5146      } else {
    52         for (pos = 0; pos < overlap_size; pos++)
     47        for (pos = 0; pos < overlap_size; pos++) {
    5348          obuf->data[0][pos] = 0.;
     49        }
    5450      }
    5551      /* end of block loop */
     
    6157}
    6258
    63 void process_print (void);
    64 void process_print (void) {
     59static void process_print (void) {
    6560      /* output times in seconds, taking back some
    6661       * delay to ensure the label is _before_ the
    6762       * actual onset */
    68       if (isonset && output_filename == NULL) {
     63      if (!verbose && usejack) return;
     64      smpl_t onset_found = fvec_read_sample(onset, 0, 0);
     65      if (onset_found) {
    6966        if(frames >= 4) {
    70           outmsg("%f\n",(frames - frames_delay + isonset)*overlap_size/(float)samplerate);
     67          outmsg("%f\n",(frames - frames_delay + onset_found)
     68                  *overlap_size/(float)samplerate);
    7169        } else if (frames < frames_delay) {
    7270          outmsg("%f\n",0.);
     
    7876  frames_delay = 3;
    7977  examples_common_init(argc,argv);
     78
     79  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
     80          samplerate);
     81  onset = new_fvec (1, channels);
     82
    8083  examples_common_process(aubio_process,process_print);
     84
     85  del_aubio_onset (o);
     86  del_fvec (onset);
     87
    8188  examples_common_del();
    8289  debug("End of program.\n");
Note: See TracChangeset for help on using the changeset viewer.