source: examples/aubioquiet.c @ ad1df9b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since ad1df9b was 340cb93, checked in by Paul Brossier <piem@piem.org>, 9 years ago

examples/: add time format option

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2  Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "utils.h"
22#include "parse_args.h"
23
24sint_t wassilence = 1, issilence;
25
26void process_block(fvec_t * ibuf, fvec_t * obuf) {
27  fvec_zeros (obuf);
28  if (aubio_silence_detection(ibuf, silence_threshold)==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;
36  }
37}
38
39void process_print (void) {
40  int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0;
41  if (issilence == -1 || issilence == 2) {
42    if (issilence == -1) {
43      outmsg ("NOISY: ");
44    } else { // if (issilence == 2) {
45      outmsg ("QUIET: ");
46    }
47    print_time (curblocks * hop_size);
48    outmsg ("\n");
49  }
50}
51
52int main(int argc, char **argv) {
53  examples_common_init(argc,argv);
54  verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
55  verbmsg ("buffer_size: %d, ", buffer_size);
56  verbmsg ("hop_size: %d\n", hop_size);
57  examples_common_process((aubio_process_func_t)process_block,process_print);
58  examples_common_del();
59  return 0;
60}
61
Note: See TracBrowser for help on using the repository browser.