Ignore:
Timestamp:
Dec 4, 2009, 1:46:40 AM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
aea235c
Parents:
c17a0ee
Message:

examples: switch to mono

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/aubioonset.c

    rc17a0ee r4621cd6  
    3131  for (j=0;j<(unsigned)nframes;j++) {
    3232    if(usejack) {
    33       for (i=0;i<channels;i++) {
    34         /* write input to datanew */
    35         fvec_write_sample(ibuf, input[i][j], i, pos);
    36         /* put synthnew in output */
    37         output[i][j] = fvec_read_sample(obuf, i, pos);
    38       }
     33      /* write input to datanew */
     34      fvec_write_sample(ibuf, input[0][j], pos);
     35      /* put synthnew in output */
     36      output[0][j] = fvec_read_sample(obuf, pos);
    3937    }
    4038    /*time for fft*/
    41     if (pos == overlap_size-1) {         
     39    if (pos == overlap_size-1) {
    4240      /* block loop */
    4341      aubio_onset_do (o, ibuf, onset);
    44       if (fvec_read_sample(onset, 0, 0)) {
     42      if ( fvec_read_sample(onset, 0) ) {
    4543        fvec_copy (woodblock, obuf);
    4644      } else {
     
    5553}
    5654
    57 static void process_print (void) {
    58       /* output times in seconds, taking back some
    59        * delay to ensure the label is _before_ the
    60        * actual onset */
    61       if (!verbose && usejack) return;
    62       smpl_t onset_found = fvec_read_sample(onset, 0, 0);
    63       if (onset_found) {
    64         if(frames >= 4) {
    65           outmsg("%f\n",(frames - frames_delay + onset_found)
    66                   *overlap_size/(float)samplerate);
    67         } else if (frames < frames_delay) {
    68           outmsg("%f\n",0.);
    69         }
    70       }
     55static void
     56process_print (void)
     57{
     58  /* output times in seconds, taking back some delay to ensure the label is
     59   * _before_ the actual onset */
     60  if (!verbose && usejack)
     61    return;
     62  smpl_t onset_found = fvec_read_sample (onset, 0);
     63  if (onset_found) {
     64    if (frames >= 4) {
     65      outmsg ("%f\n", (frames - frames_delay + onset_found)
     66          * overlap_size / (float) samplerate);
     67    } else if (frames < frames_delay) {
     68      outmsg ("%f\n", 0.);
     69    }
     70  }
    7171}
    7272
     
    7575  examples_common_init(argc,argv);
    7676
    77   o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
    78           samplerate);
     77  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, samplerate);
    7978  if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
    80   onset = new_fvec (1, channels);
     79  onset = new_fvec (1);
    8180
    8281  examples_common_process(aubio_process,process_print);
Note: See TracChangeset for help on using the changeset viewer.