[96fb8ad] | 1 | /* |
---|
| 2 | Copyright (C) 2003 Paul Brossier |
---|
| 3 | |
---|
| 4 | This program is free software; you can redistribute it and/or modify |
---|
| 5 | it under the terms of the GNU General Public License as published by |
---|
| 6 | the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | (at your option) any later version. |
---|
| 8 | |
---|
| 9 | This program is distributed in the hope that it will be useful, |
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | GNU General Public License for more details. |
---|
| 13 | |
---|
| 14 | You should have received a copy of the GNU General Public License |
---|
| 15 | along with this program; if not, write to the Free Software |
---|
| 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 17 | |
---|
| 18 | */ |
---|
| 19 | |
---|
[bd2f2ab] | 20 | #include <stdio.h> |
---|
| 21 | #include <stdlib.h> |
---|
| 22 | #include <stdarg.h> |
---|
| 23 | #include <getopt.h> |
---|
| 24 | #include <unistd.h> |
---|
| 25 | #include <math.h> |
---|
| 26 | #include <aubio.h> |
---|
| 27 | #include <aubioext.h> |
---|
| 28 | |
---|
[a3e24ec] | 29 | #ifdef HAVE_C99_VARARGS_MACROS |
---|
| 30 | #define debug(...) if (verbose) fprintf (stderr, __VA_ARGS__) |
---|
| 31 | #define errmsg(...) fprintf (stderr, __VA_ARGS__) |
---|
| 32 | #define outmsg(...) fprintf (stdout, __VA_ARGS__) |
---|
| 33 | #else |
---|
| 34 | #define debug(format, args...) if (verbose) fprintf(stderr, format , ##args) |
---|
| 35 | #define errmsg(format, args...) fprintf(stderr, format , ##args) |
---|
| 36 | #define outmsg(format, args...) fprintf(stdout, format , ##args) |
---|
| 37 | #endif |
---|
| 38 | |
---|
[96fb8ad] | 39 | |
---|
[bd2f2ab] | 40 | extern int frames; |
---|
[96fb8ad] | 41 | extern int verbose; |
---|
| 42 | extern int usejack; |
---|
[62c6075] | 43 | extern int usedoubled; |
---|
[e24378a] | 44 | extern int frames_delay; |
---|
[bd2f2ab] | 45 | extern unsigned int median; |
---|
[96fb8ad] | 46 | extern const char * output_filename; |
---|
| 47 | extern const char * input_filename; |
---|
| 48 | /* defined in utils.c */ |
---|
| 49 | void usage (FILE * stream, int exit_code); |
---|
| 50 | int parse_args (int argc, char **argv); |
---|
[bd2f2ab] | 51 | void examples_common_init(int argc, char **argv); |
---|
| 52 | void examples_common_del(void); |
---|
| 53 | typedef void (aubio_print_func_t)(void); |
---|
[b511fa9] | 54 | #ifndef HAVE_JACK |
---|
[5a1ff62] | 55 | typedef int (*aubio_process_func_t) |
---|
[c423c3d] | 56 | (smpl_t **input, smpl_t **output, int nframes); |
---|
[5a1ff62] | 57 | #endif |
---|
[bd2f2ab] | 58 | void examples_common_process(aubio_process_func_t process_func, aubio_print_func_t print); |
---|
[16e0f16] | 59 | void flush_process(aubio_process_func_t process_func, aubio_print_func_t print); |
---|
[bd2f2ab] | 60 | |
---|
| 61 | |
---|
| 62 | void send_noteon(int pitch, int velo); |
---|
| 63 | /** append new note candidate to the note_buffer and return filtered value. we |
---|
| 64 | * need to copy the input array as vec_median destroy its input data.*/ |
---|
| 65 | void note_append(fvec_t * note_buffer, smpl_t curnote); |
---|
| 66 | uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2); |
---|
| 67 | |
---|
| 68 | extern const char * output_filename; |
---|
| 69 | extern const char * input_filename; |
---|
| 70 | extern const char * onset_filename; |
---|
| 71 | extern int verbose; |
---|
| 72 | extern int usejack; |
---|
| 73 | extern int usedoubled; |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | /* energy,specdiff,hfc,complexdomain,phase */ |
---|
| 77 | extern aubio_onsetdetection_type type_onset; |
---|
| 78 | extern aubio_onsetdetection_type type_onset2; |
---|
| 79 | extern smpl_t threshold; |
---|
[660cad22] | 80 | extern smpl_t silence; |
---|
[bd2f2ab] | 81 | extern uint_t buffer_size; |
---|
| 82 | extern uint_t overlap_size; |
---|
| 83 | extern uint_t channels; |
---|
| 84 | extern uint_t samplerate; |
---|
| 85 | |
---|
| 86 | |
---|
[5e9c68a] | 87 | extern aubio_sndfile_t * file; |
---|
| 88 | extern aubio_sndfile_t * fileout; |
---|
[bd2f2ab] | 89 | |
---|
| 90 | extern aubio_pvoc_t * pv; |
---|
| 91 | extern fvec_t * ibuf; |
---|
| 92 | extern fvec_t * obuf; |
---|
| 93 | extern cvec_t * fftgrain; |
---|
| 94 | extern fvec_t * woodblock; |
---|
| 95 | extern aubio_onsetdetection_t *o; |
---|
| 96 | extern aubio_onsetdetection_t *o2; |
---|
| 97 | extern fvec_t *onset; |
---|
| 98 | extern fvec_t *onset2; |
---|
| 99 | extern int isonset; |
---|
| 100 | extern aubio_pickpeak_t * parms; |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | /* pitch objects */ |
---|
| 104 | extern smpl_t pitch; |
---|
| 105 | extern aubio_pitchdetection_t * pitchdet; |
---|
| 106 | extern aubio_pitchdetection_type mode; |
---|
| 107 | extern uint_t median; |
---|
| 108 | |
---|
| 109 | extern fvec_t * note_buffer; |
---|
| 110 | extern fvec_t * note_buffer2; |
---|
| 111 | extern smpl_t curlevel; |
---|
| 112 | extern smpl_t maxonset; |
---|
| 113 | |
---|
| 114 | /* midi objects */ |
---|
| 115 | extern aubio_midi_player_t * mplay; |
---|
| 116 | extern aubio_midi_driver_t * mdriver; |
---|
| 117 | extern aubio_midi_event_t * event; |
---|
| 118 | |
---|
| 119 | extern smpl_t curnote; |
---|
| 120 | extern smpl_t newnote; |
---|
| 121 | extern uint_t isready; |
---|
| 122 | |
---|
| 123 | /* per example param */ |
---|
| 124 | extern uint_t usepitch; |
---|
[96fb8ad] | 125 | |
---|