Ignore:
Timestamp:
Dec 7, 2013, 4:09:00 AM (10 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:
3da8187
Parents:
44e94f3c
Message:

examples/: large refactoring, improve option management, remove old stuff, move blocking logic to jackio

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/aubioonset.c

    r44e94f3c r466dff3  
    11/*
    2   Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
     2  Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
    33
    44  This file is part of aubio.
     
    2020
    2121#include "utils.h"
    22 #define PROG_HAS_ONSET
     22#define PROG_HAS_ONSET 1
    2323#include "parse_args.h"
    24 
    25 uint_t pos = 0; /*frames%dspblocksize*/
    2624
    2725aubio_onset_t *o;
     
    2927fvec_t *onset;
    3028
    31 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    32   unsigned int j;       /*frames*/
    33   for (j=0;j<(unsigned)nframes;j++) {
    34     if(usejack) {
    35       /* write input to datanew */
    36       fvec_write_sample(ibuf, input[0][j], pos);
    37       /* put synthnew in output */
    38       output[0][j] = fvec_read_sample(obuf, pos);
    39     }
    40     /*time for fft*/
    41     if (pos == overlap_size-1) {
    42       /* block loop */
    43       fvec_zeros(obuf);
    44       aubio_onset_do (o, ibuf, onset);
    45       if ( fvec_read_sample(onset, 0) ) {
    46         aubio_wavetable_play ( wavetable );
    47       } else {
    48         aubio_wavetable_stop ( wavetable );
    49       }
    50       aubio_wavetable_do (wavetable, obuf, obuf);
    51       /* end of block loop */
    52       pos = -1; /* so it will be zero next j loop */
    53     }
    54     pos++;
     29void
     30process_block(fvec_t *ibuf, fvec_t *obuf) {
     31  fvec_zeros(obuf);
     32  aubio_onset_do (o, ibuf, onset);
     33  if ( fvec_read_sample(onset, 0) ) {
     34    aubio_wavetable_play ( wavetable );
     35  } else {
     36    aubio_wavetable_stop ( wavetable );
    5537  }
    56   return 1;
     38  aubio_wavetable_do (wavetable, obuf, obuf);
    5739}
    5840
    59 static void
     41void
    6042process_print (void)
    6143{
    62   /* output times in seconds, taking back some delay to ensure the label is
    63    * _before_ the actual onset */
    64   if (!verbose && usejack)
    65     return;
    6644  smpl_t onset_found = fvec_read_sample (onset, 0);
    6745  if (onset_found) {
     
    7351  examples_common_init(argc,argv);
    7452
    75   o = new_aubio_onset (onset_method, buffer_size, overlap_size, samplerate);
     53  verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
     54  verbmsg ("onset method: %s, ", onset_method);
     55  verbmsg ("buffer_size: %d, ", buffer_size);
     56  verbmsg ("hop_size: %d, ", hop_size);
     57  verbmsg ("threshold: %f\n", onset_threshold);
     58
     59  o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate);
    7660  if (onset_threshold != 0.) aubio_onset_set_threshold (o, onset_threshold);
    7761  onset = new_fvec (1);
    7862
    79   wavetable = new_aubio_wavetable (samplerate, overlap_size);
     63  wavetable = new_aubio_wavetable (samplerate, hop_size);
    8064  aubio_wavetable_set_freq ( wavetable, 2450.);
    8165  //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff");
    8266
    83   examples_common_process(aubio_process,process_print);
     67  examples_common_process((aubio_process_func_t)process_block, process_print);
    8468
    8569  del_aubio_onset (o);
     
    8872
    8973  examples_common_del();
    90   debug("End of program.\n");
    91   fflush(stderr);
    9274  return 0;
    9375}
    94 
Note: See TracChangeset for help on using the changeset viewer.