Ignore:
Timestamp:
Dec 4, 2009, 1:46:40 AM (14 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:
aea235c
Parents:
c17a0ee
Message:

examples: switch to mono

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/aubionotes.c

    rc17a0ee r4621cd6  
    1919*/
    2020
    21 #define AUBIO_UNSTABLE 1 // for fvec_median_channel
     21#define AUBIO_UNSTABLE 1 // for fvec_median
    2222
    2323#include "utils.h"
     
    5050
    5151static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    52   unsigned int i;       /*channels*/
    5352  unsigned int j;       /*frames*/
    5453  for (j=0;j<(unsigned)nframes;j++) {
    5554    if(usejack) {
    56       for (i=0;i<channels;i++) {
    57         /* write input to datanew */
    58         fvec_write_sample(ibuf, input[i][j], i, pos);
    59         /* put synthnew in output */
    60         output[i][j] = fvec_read_sample(obuf, i, pos);
    61       }
     55      /* write input to datanew */
     56      fvec_write_sample(ibuf, input[0][j], pos);
     57      /* put synthnew in output */
     58      output[0][j] = fvec_read_sample(obuf, pos);
    6259    }
    6360    /*time for fft*/
     
    6764     
    6865      aubio_pitch_do (pitchdet, ibuf, pitch_obuf);
    69       pitch = fvec_read_sample(pitch_obuf, 0, 0);
     66      pitch = fvec_read_sample(pitch_obuf, 0);
    7067      if(median){
    7168              note_append(note_buffer, pitch);
     
    7471      /* curlevel is negatif or 1 if silence */
    7572      curlevel = aubio_level_detection(ibuf, silence);
    76       if (fvec_read_sample(onset, 0, 0)) {
     73      if (fvec_read_sample(onset, 0)) {
    7774              /* test for silence */
    7875              if (curlevel == 1.) {
     
    9289
    9390                      for (pos = 0; pos < overlap_size; pos++){
    94                               obuf->data[0][pos] = woodblock->data[0][pos];
     91                              obuf->data[pos] = woodblock->data[pos];
    9592                      }
    9693              }
     
    112109              } // if median
    113110        for (pos = 0; pos < overlap_size; pos++)
    114           obuf->data[0][pos] = 0.;
     111          obuf->data[pos] = 0.;
    115112      }
    116113      /* end of block loop */
     
    131128  uint_t i = 0;
    132129  for (i = 0; i < note_buffer->length - 1; i++) {
    133     note_buffer->data[0][i] = note_buffer->data[0][i + 1];
     130    note_buffer->data[i] = note_buffer->data[i + 1];
    134131  }
    135   note_buffer->data[0][note_buffer->length - 1] = curnote;
     132  note_buffer->data[note_buffer->length - 1] = curnote;
    136133  return;
    137134}
     
    142139  uint_t i;
    143140  for (i = 0; i < note_buffer->length; i++) {
    144     note_buffer2->data[0][i] = note_buffer->data[0][i];
     141    note_buffer2->data[i] = note_buffer->data[i];
    145142  }
    146   return fvec_median_channel (note_buffer2, 0);
     143  return fvec_median (note_buffer2);
    147144}
    148145
     
    150147  examples_common_init(argc,argv);
    151148
    152   o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
    153           samplerate);
     149  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, samplerate);
    154150  if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
    155   onset = new_fvec (1, channels);
     151  onset = new_fvec (1);
    156152
    157153  pitchdet = new_aubio_pitch (pitch_mode, buffer_size * 4,
    158           overlap_size, channels, samplerate);
     154          overlap_size, samplerate);
    159155  aubio_pitch_set_tolerance (pitchdet, 0.7);
    160   pitch_obuf = new_fvec (1, channels);
     156  pitch_obuf = new_fvec (1);
    161157  if (median) {
    162       note_buffer = new_fvec (median, 1);
    163       note_buffer2 = new_fvec (median, 1);
     158      note_buffer = new_fvec (median);
     159      note_buffer2 = new_fvec (median);
    164160  }
    165161
Note: See TracChangeset for help on using the changeset viewer.