merged commmon code between aubionotes.c and aubioonset.c into utils.c
[aubio.git] / examples / utils.h
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
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
29 #define debug(...) if (verbose) fprintf (stderr, __VA_ARGS__)
30 #define errmsg(...) fprintf (stderr, __VA_ARGS__)
31 #define outmsg(...) fprintf (stdout, __VA_ARGS__)
32
33 extern int frames;
34 extern int verbose;
35 extern int usejack;
36 extern int usedoubled;
37 extern unsigned int median;
38 extern const char * output_filename;
39 extern const char * input_filename;
40 /* defined in utils.c */
41 void usage (FILE * stream, int exit_code);
42 int parse_args (int argc, char **argv);
43 void examples_common_init(int argc, char **argv);
44 void examples_common_del(void);
45 typedef void (aubio_print_func_t)(void);
46 void examples_common_process(aubio_process_func_t process_func, aubio_print_func_t print);
47
48
49 void send_noteon(int pitch, int velo);
50 /** append new note candidate to the note_buffer and return filtered value. we
51  * need to copy the input array as vec_median destroy its input data.*/
52 void note_append(fvec_t * note_buffer, smpl_t curnote); 
53 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2);
54
55 extern const char * output_filename;
56 extern const char * input_filename;
57 extern const char * onset_filename;
58 extern int verbose;
59 extern int usejack;
60 extern int usedoubled;
61
62
63 /* energy,specdiff,hfc,complexdomain,phase */
64 extern aubio_onsetdetection_type type_onset;
65 extern aubio_onsetdetection_type type_onset2;
66 extern smpl_t threshold;
67 extern smpl_t threshold2;
68 extern uint_t buffer_size;
69 extern uint_t overlap_size;
70 extern uint_t channels;
71 extern uint_t samplerate;
72
73
74 extern aubio_file_t * file;
75 extern aubio_file_t * fileout;
76
77 extern aubio_pvoc_t * pv;
78 extern fvec_t * ibuf;
79 extern fvec_t * obuf;
80 extern cvec_t * fftgrain;
81 extern fvec_t * woodblock;
82 extern aubio_onsetdetection_t *o;
83 extern aubio_onsetdetection_t *o2;
84 extern fvec_t *onset;
85 extern fvec_t *onset2;
86 extern int isonset;
87 extern aubio_pickpeak_t * parms;
88
89
90 /* pitch objects */
91 extern smpl_t pitch;
92 extern aubio_pitchdetection_t * pitchdet;
93 extern aubio_pitchdetection_type mode;
94 extern uint_t median;
95
96 extern fvec_t * note_buffer;
97 extern fvec_t * note_buffer2;
98 extern smpl_t curlevel;
99 extern smpl_t maxonset;
100
101 /* midi objects */
102 extern aubio_midi_player_t * mplay; 
103 extern aubio_midi_driver_t * mdriver; 
104 extern aubio_midi_event_t  * event;
105
106 extern smpl_t curnote;
107 extern smpl_t newnote;
108 extern uint_t isready;
109
110 /* per example param */
111 extern uint_t usepitch;
112