[96fb8ad] | 1 | /* |
---|
[466dff3] | 2 | Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org> |
---|
[96fb8ad] | 3 | |
---|
[6a2478c] | 4 | This file is part of aubio. |
---|
[96fb8ad] | 5 | |
---|
[6a2478c] | 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/>. |
---|
[96fb8ad] | 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #include "utils.h" |
---|
[1b25a70] | 22 | #define PROG_HAS_PITCH 1 |
---|
| 23 | #define PROG_HAS_ONSET 1 |
---|
[3da8187] | 24 | #define PROG_HAS_JACK 1 |
---|
| 25 | // TODO add PROG_HAS_OUTPUT |
---|
[1b25a70] | 26 | #include "parse_args.h" |
---|
[96fb8ad] | 27 | |
---|
[ba303e8] | 28 | aubio_notes_t *notes; |
---|
| 29 | uint_t lastnote = 0; |
---|
[d4c5de7] | 30 | |
---|
[d389e23] | 31 | void process_block (fvec_t *ibuf, fvec_t *obuf) |
---|
| 32 | { |
---|
[ba303e8] | 33 | aubio_notes_do (notes, ibuf, obuf); |
---|
| 34 | // did we get a note off? |
---|
| 35 | if (obuf->data[2] != 0) { |
---|
| 36 | send_noteon(obuf->data[2], 0); |
---|
[466dff3] | 37 | } |
---|
[ba303e8] | 38 | // did we get a note on? |
---|
| 39 | if (obuf->data[0] != 0) { |
---|
| 40 | send_noteon(obuf->data[0], obuf->data[1]); |
---|
| 41 | lastnote = (uint_t) floor(obuf->data[0]); |
---|
[96fb8ad] | 42 | } |
---|
| 43 | } |
---|
| 44 | |
---|
[d389e23] | 45 | void process_print (void) |
---|
| 46 | { |
---|
[466dff3] | 47 | //if (verbose) outmsg("%f\n",pitch_obuf->data[0]); |
---|
[a0fd4e4] | 48 | } |
---|
[96fb8ad] | 49 | |
---|
[bd2f2ab] | 50 | int main(int argc, char **argv) { |
---|
| 51 | examples_common_init(argc,argv); |
---|
[d4c5de7] | 52 | |
---|
[466dff3] | 53 | verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); |
---|
| 54 | |
---|
| 55 | verbmsg ("onset method: %s, ", onset_method); |
---|
| 56 | verbmsg ("buffer_size: %d, ", buffer_size); |
---|
| 57 | verbmsg ("hop_size: %d, ", hop_size); |
---|
| 58 | verbmsg ("threshold: %f\n", onset_threshold); |
---|
| 59 | |
---|
| 60 | verbmsg ("pitch method: %s, ", pitch_method); |
---|
| 61 | verbmsg ("buffer_size: %d, ", buffer_size * 4); |
---|
| 62 | verbmsg ("hop_size: %d, ", hop_size); |
---|
| 63 | verbmsg ("tolerance: %f\n", pitch_tolerance); |
---|
| 64 | |
---|
[ba303e8] | 65 | notes = new_aubio_notes ("default", buffer_size, hop_size, samplerate); |
---|
[d4c5de7] | 66 | |
---|
[466dff3] | 67 | examples_common_process((aubio_process_func_t)process_block, process_print); |
---|
[d4c5de7] | 68 | |
---|
[466dff3] | 69 | // send a last note off |
---|
[ba303e8] | 70 | send_noteon (lastnote, 0); |
---|
[466dff3] | 71 | |
---|
[ba303e8] | 72 | del_aubio_notes (notes); |
---|
[d4c5de7] | 73 | |
---|
[bd2f2ab] | 74 | examples_common_del(); |
---|
[96fb8ad] | 75 | return 0; |
---|
| 76 | } |
---|
| 77 | |
---|