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 | #define PROG_HAS_SILENCE 1 |
---|
23 | #include "parse_args.h" |
---|
24 | |
---|
25 | sint_t wassilence = 1, issilence; |
---|
26 | |
---|
27 | void process_block(fvec_t * ibuf, fvec_t * obuf) { |
---|
28 | fvec_zeros (obuf); |
---|
29 | if (aubio_silence_detection(ibuf, silence_threshold)==1) { |
---|
30 | if (wassilence==1) issilence = 1; |
---|
31 | else issilence = 2; |
---|
32 | wassilence=1; |
---|
33 | } else { |
---|
34 | if (wassilence<=0) issilence = 0; |
---|
35 | else issilence = -1; |
---|
36 | wassilence=0; |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | void process_print (void) { |
---|
41 | int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0; |
---|
42 | if (issilence == -1 || issilence == 2) { |
---|
43 | if (issilence == -1) { |
---|
44 | outmsg ("NOISY: "); |
---|
45 | } else { // if (issilence == 2) { |
---|
46 | outmsg ("QUIET: "); |
---|
47 | } |
---|
48 | print_time (curblocks * hop_size); |
---|
49 | outmsg ("\n"); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | int main(int argc, char **argv) { |
---|
54 | examples_common_init(argc,argv); |
---|
55 | verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); |
---|
56 | verbmsg ("buffer_size: %d, ", buffer_size); |
---|
57 | verbmsg ("hop_size: %d\n", hop_size); |
---|
58 | examples_common_process((aubio_process_func_t)process_block,process_print); |
---|
59 | examples_common_del(); |
---|
60 | return 0; |
---|
61 | } |
---|
62 | |
---|