[96fb8ad] | 1 | /* |
---|
[50bc5f2] | 2 | Copyright (C) 2003-2009 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 | |
---|
[96fb8ad] | 19 | */ |
---|
| 20 | |
---|
[bd2f2ab] | 21 | #include <stdio.h> |
---|
| 22 | #include <stdlib.h> |
---|
| 23 | #include <stdarg.h> |
---|
| 24 | #include <getopt.h> |
---|
| 25 | #include <unistd.h> |
---|
[50bc5f2] | 26 | #include <math.h> /* for isfinite */ |
---|
[bd2f2ab] | 27 | #include <aubio.h> |
---|
| 28 | #include <aubioext.h> |
---|
| 29 | |
---|
[a3e24ec] | 30 | #ifdef HAVE_C99_VARARGS_MACROS |
---|
| 31 | #define debug(...) if (verbose) fprintf (stderr, __VA_ARGS__) |
---|
| 32 | #define errmsg(...) fprintf (stderr, __VA_ARGS__) |
---|
| 33 | #define outmsg(...) fprintf (stdout, __VA_ARGS__) |
---|
| 34 | #else |
---|
| 35 | #define debug(format, args...) if (verbose) fprintf(stderr, format , ##args) |
---|
| 36 | #define errmsg(format, args...) fprintf(stderr, format , ##args) |
---|
| 37 | #define outmsg(format, args...) fprintf(stdout, format , ##args) |
---|
| 38 | #endif |
---|
| 39 | |
---|
[96fb8ad] | 40 | |
---|
[bd2f2ab] | 41 | extern int frames; |
---|
[96fb8ad] | 42 | extern int verbose; |
---|
| 43 | extern int usejack; |
---|
[62c6075] | 44 | extern int usedoubled; |
---|
[e24378a] | 45 | extern int frames_delay; |
---|
[bd2f2ab] | 46 | extern unsigned int median; |
---|
[50bc5f2] | 47 | extern const char *output_filename; |
---|
| 48 | extern const char *input_filename; |
---|
[96fb8ad] | 49 | /* defined in utils.c */ |
---|
| 50 | void usage (FILE * stream, int exit_code); |
---|
| 51 | int parse_args (int argc, char **argv); |
---|
[50bc5f2] | 52 | void examples_common_init (int argc, char **argv); |
---|
| 53 | void examples_common_del (void); |
---|
| 54 | typedef void (aubio_print_func_t) (void); |
---|
[b511fa9] | 55 | #ifndef HAVE_JACK |
---|
[5a1ff62] | 56 | typedef int (*aubio_process_func_t) |
---|
[50bc5f2] | 57 | (smpl_t ** input, smpl_t ** output, int nframes); |
---|
[5a1ff62] | 58 | #endif |
---|
[50bc5f2] | 59 | void examples_common_process (aubio_process_func_t process_func, |
---|
| 60 | aubio_print_func_t print); |
---|
| 61 | void flush_process (aubio_process_func_t process_func, |
---|
| 62 | aubio_print_func_t print); |
---|
[bd2f2ab] | 63 | |
---|
| 64 | |
---|
[50bc5f2] | 65 | void send_noteon (int pitch, int velo); |
---|
[bd2f2ab] | 66 | /** append new note candidate to the note_buffer and return filtered value. we |
---|
| 67 | * need to copy the input array as vec_median destroy its input data.*/ |
---|
[50bc5f2] | 68 | void note_append (fvec_t * note_buffer, smpl_t curnote); |
---|
| 69 | uint_t get_note (fvec_t * note_buffer, fvec_t * note_buffer2); |
---|
[bd2f2ab] | 70 | |
---|
[50bc5f2] | 71 | extern const char *output_filename; |
---|
| 72 | extern const char *input_filename; |
---|
| 73 | extern const char *onset_filename; |
---|
[bd2f2ab] | 74 | extern int verbose; |
---|
| 75 | extern int usejack; |
---|
| 76 | extern int usedoubled; |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /* energy,specdiff,hfc,complexdomain,phase */ |
---|
| 80 | extern aubio_onsetdetection_type type_onset; |
---|
| 81 | extern aubio_onsetdetection_type type_onset2; |
---|
| 82 | extern smpl_t threshold; |
---|
[660cad22] | 83 | extern smpl_t silence; |
---|
[bd2f2ab] | 84 | extern uint_t buffer_size; |
---|
| 85 | extern uint_t overlap_size; |
---|
| 86 | extern uint_t channels; |
---|
| 87 | extern uint_t samplerate; |
---|
| 88 | |
---|
| 89 | |
---|
[50bc5f2] | 90 | extern aubio_sndfile_t *file; |
---|
| 91 | extern aubio_sndfile_t *fileout; |
---|
[bd2f2ab] | 92 | |
---|
[50bc5f2] | 93 | extern aubio_pvoc_t *pv; |
---|
| 94 | extern fvec_t *ibuf; |
---|
| 95 | extern fvec_t *obuf; |
---|
| 96 | extern cvec_t *fftgrain; |
---|
| 97 | extern fvec_t *woodblock; |
---|
[bd2f2ab] | 98 | extern aubio_onsetdetection_t *o; |
---|
| 99 | extern aubio_onsetdetection_t *o2; |
---|
| 100 | extern fvec_t *onset; |
---|
| 101 | extern fvec_t *onset2; |
---|
| 102 | extern int isonset; |
---|
[50bc5f2] | 103 | extern aubio_pickpeak_t *parms; |
---|
[bd2f2ab] | 104 | |
---|
| 105 | |
---|
| 106 | /* pitch objects */ |
---|
| 107 | extern smpl_t pitch; |
---|
[50bc5f2] | 108 | extern aubio_pitchdetection_t *pitchdet; |
---|
[bd2f2ab] | 109 | extern aubio_pitchdetection_type mode; |
---|
| 110 | extern uint_t median; |
---|
| 111 | |
---|
[50bc5f2] | 112 | extern fvec_t *note_buffer; |
---|
| 113 | extern fvec_t *note_buffer2; |
---|
[bd2f2ab] | 114 | extern smpl_t curlevel; |
---|
| 115 | extern smpl_t maxonset; |
---|
| 116 | |
---|
| 117 | /* midi objects */ |
---|
[50bc5f2] | 118 | extern aubio_midi_player_t *mplay; |
---|
| 119 | extern aubio_midi_driver_t *mdriver; |
---|
| 120 | extern aubio_midi_event_t *event; |
---|
[bd2f2ab] | 121 | |
---|
| 122 | extern smpl_t curnote; |
---|
| 123 | extern smpl_t newnote; |
---|
| 124 | extern uint_t isready; |
---|
| 125 | |
---|
| 126 | /* per example param */ |
---|
| 127 | extern uint_t usepitch; |
---|