Changeset bd2f2ab for examples/aubioonset.c
- Timestamp:
- Apr 11, 2005, 6:37:51 PM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- dc27a81
- Parents:
- 84941cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubioonset.c
r84941cb rbd2f2ab 17 17 */ 18 18 19 #include <stdio.h>20 #include <stdlib.h>21 #include <stdarg.h>22 #include <getopt.h>23 #include <unistd.h>24 #include "aubio.h"25 #include "aubioext.h"26 19 #include "utils.h" 27 20 21 unsigned int pos = 0; /*frames%dspblocksize*/ 22 uint_t usepitch = 0; 23 28 24 int aubio_process(float **input, float **output, int nframes); 29 30 const char * output_filename = NULL;31 const char * input_filename = NULL;32 const char * onset_filename = "/usr/share/sounds/aubio/woodblock.aiff";33 34 /* settings */35 int verbose = 0;36 int usejack = 0;37 int usedoubled = 1;38 39 40 /* energy,specdiff,hfc,complexdomain,phase */41 aubio_onsetdetection_type type_onset = hfc;42 aubio_onsetdetection_type type_onset2 = complexdomain;43 smpl_t threshold = 0.1;44 smpl_t threshold2 = -90.;45 uint_t buffer_size = 1024;46 uint_t overlap_size = 512;47 uint_t channels = 1;48 uint_t samplerate = 44100;49 50 /* global objects */51 aubio_pvoc_t * pv;52 fvec_t * ibuf;53 fvec_t * obuf;54 cvec_t * fftgrain;55 fvec_t * woodblock;56 aubio_onsetdetection_t *o;57 aubio_onsetdetection_t *o2;58 fvec_t *onset;59 fvec_t *onset2;60 int isonset = 0;61 aubio_pickpeak_t * parms;62 unsigned int pos = 0; /*frames%dspblocksize*/63 64 25 int aubio_process(float **input, float **output, int nframes) { 65 26 unsigned int i; /*channels*/ … … 96 57 obuf->data[0][pos] = 0.; 97 58 } 98 //aubio_pvoc_rdo(pv,fftgrain, obuf);99 59 /* end of block loop */ 100 60 pos = -1; /* so it will be zero next j loop */ … … 105 65 } 106 66 107 int main(int argc, char **argv) { 108 int frames; 109 110 aubio_file_t * file = NULL; 111 aubio_file_t * fileout = NULL; 112 113 aubio_file_t * onsetfile = new_file_ro(onset_filename); 114 parse_args(argc, argv); 115 116 if(!usejack) 117 { 118 debug("Opening files ...\n"); 119 file = new_file_ro (input_filename); 120 if (verbose) file_info(file); 121 channels = aubio_file_channels(file); 122 samplerate = aubio_file_samplerate(file); 123 if (output_filename != NULL) 124 fileout = new_file_wo(file, output_filename); 125 } 126 127 ibuf = new_fvec(overlap_size, channels); 128 obuf = new_fvec(overlap_size, channels); 129 woodblock = new_fvec(buffer_size,1); 130 fftgrain = new_cvec(buffer_size, channels); 131 132 /* read the output sound once */ 133 file_read(onsetfile, overlap_size, woodblock); 134 135 /* phase vocoder */ 136 debug("Phase voc init ... \n"); 137 pv = new_aubio_pvoc(buffer_size, overlap_size, channels); 138 139 /* onsets */ 140 parms = new_aubio_peakpicker(threshold); 141 o = new_aubio_onsetdetection(type_onset,buffer_size,channels); 142 onset = new_fvec(1, channels); 143 if (usedoubled) { 144 o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); 145 onset2 = new_fvec(1 , channels); 146 } 147 148 if(usejack) { 149 #ifdef JACK_SUPPORT 150 aubio_jack_t * jack_setup; 151 debug("Jack init ...\n"); 152 jack_setup = new_aubio_jack(channels, channels, 153 (aubio_process_func_t)aubio_process); 154 debug("Jack activation ...\n"); 155 aubio_jack_activate(jack_setup); 156 debug("Processing (Ctrl+C to quit) ...\n"); 157 pause(); 158 aubio_jack_close(jack_setup); 159 #else 160 outmsg("Compiled without jack output, exiting."); 161 #endif 162 163 } else { 164 /* phasevoc */ 165 debug("Processing ...\n"); 166 167 frames = 0; 168 169 while (overlap_size == file_read(file, overlap_size, ibuf)) 170 { 171 isonset=0; 172 aubio_process(ibuf->data, obuf->data, overlap_size); 67 void process_print (void); 68 void process_print (void) { 173 69 /* output times in seconds, taking back some 174 70 * delay to ensure the label is _before_ the … … 181 77 } 182 78 } 183 if (output_filename != NULL) { 184 file_write(fileout,overlap_size,obuf); 185 } 186 frames++; 187 } 79 } 188 80 189 debug("Processed %d frames of %d samples.\n", frames, buffer_size); 190 del_file(file); 191 192 if (output_filename != NULL) 193 del_file(fileout); 194 195 } 196 197 del_aubio_pvoc(pv); 198 del_fvec(obuf); 199 del_fvec(ibuf); 200 del_cvec(fftgrain); 201 del_fvec(onset); 202 81 int main(int argc, char **argv) { 82 examples_common_init(argc,argv); 83 examples_common_process(aubio_process,process_print); 84 examples_common_del(); 203 85 debug("End of program.\n"); 204 86 fflush(stderr);
Note: See TracChangeset
for help on using the changeset viewer.