Ignore:
Timestamp:
Dec 7, 2013, 4:09:00 AM (11 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/aubioquiet.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.
     
    2222#include "parse_args.h"
    2323
    24 unsigned int pos = 0; /*frames%dspblocksize*/
    2524sint_t wassilence = 1, issilence;
    2625
    27 int aubio_process(smpl_t **input, smpl_t **output, int nframes);
    28 int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    29   unsigned int j;       /*frames*/
    30   for (j=0;j<(unsigned)nframes;j++) {
    31     if(usejack) {
    32       /* write input to datanew */
    33       fvec_write_sample(ibuf, input[0][j], pos);
    34       /* put synthnew in output */
    35       output[0][j] = fvec_read_sample(obuf, pos);
    36     }
    37     /*time for fft*/
    38     if (pos == overlap_size-1) {         
    39       /* test for silence */
    40       if (aubio_silence_detection(ibuf, silence)==1) {
    41         if (wassilence==1) issilence = 1;
    42         else issilence = 2;
    43         wassilence=1;
    44       } else {
    45         if (wassilence<=0) issilence = 0;
    46         else issilence = -1;
    47         wassilence=0;
    48       }
    49       /* end of block loop */
    50       pos = -1; /* so it will be zero next j loop */
    51     }
    52     pos++;
     26void process_block(fvec_t * ibuf, fvec_t * obuf) {
     27  fvec_zeros (obuf);
     28  if (aubio_silence_detection(ibuf, silence)==1) {
     29    if (wassilence==1) issilence = 1;
     30    else issilence = 2;
     31    wassilence=1;
     32  } else {
     33    if (wassilence<=0) issilence = 0;
     34    else issilence = -1;
     35    wassilence=0;
    5336  }
    54   return 1;
    5537}
    5638
    5739static void process_print (void) {
    58       int curframes = (frames - 4) > 0 ? frames -4 : 0;
    59       if (issilence == -1) {
    60           outmsg("NOISY: %f\n",curframes*overlap_size/(float)samplerate);
    61       } else if (issilence == 2) {
    62           outmsg("QUIET: %f\n",curframes*overlap_size/(float)samplerate);
    63       }
     40  int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0;
     41  if (issilence == -1) {
     42    outmsg("NOISY: %f\n",curblocks*hop_size/(float)samplerate);
     43  } else if (issilence == 2) {
     44    outmsg("QUIET: %f\n",curblocks*hop_size/(float)samplerate);
     45  }
    6446}
    6547
    6648int main(int argc, char **argv) {
    6749  examples_common_init(argc,argv);
    68   examples_common_process(aubio_process,process_print);
     50  verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
     51  verbmsg ("buffer_size: %d, ", buffer_size);
     52  verbmsg ("hop_size: %d\n", hop_size);
     53  examples_common_process((aubio_process_func_t)process_block,process_print);
    6954  examples_common_del();
    70   debug("End of program.\n");
    71   fflush(stderr);
    7255  return 0;
    7356}
Note: See TracChangeset for help on using the changeset viewer.