- Timestamp:
- Apr 2, 2005, 3:29:23 PM (20 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:
- cf7c76a
- Parents:
- e50b695
- Location:
- examples
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/Makefile.am
re50b695 ra0fd4e4 9 9 bin_PROGRAMS = \ 10 10 aubioonset \ 11 aubionotesmedian \12 11 aubionotes 13 12 … … 17 16 aubioonset_SOURCES = aubioonset.c utils.c 18 17 aubionotes_SOURCES = aubionotes.c utils.c 19 aubionotesmedian_SOURCES = aubionotesmedian.c utils.c -
examples/aubionotes.c
re50b695 ra0fd4e4 22 22 #include <getopt.h> 23 23 #include <unistd.h> 24 #include <math.h> // how do i do a floorf with a mask again ?24 #include <math.h> 25 25 #include "aubio.h" 26 26 #include "aubioext.h" … … 35 35 int usedoubled = 1; 36 36 int usemidi = 1; 37 int median = 0; 37 38 38 39 /* energy,specdiff,hfc,complexdomain,phase */ 39 40 aubio_onsetdetection_type type_onset = hfc; 40 aubio_onsetdetection_type type_onset2 = hfc;41 aubio_onsetdetection_type type_onset2 = complexdomain; 41 42 smpl_t threshold = 0.3; 42 43 smpl_t threshold2 = -90.; … … 61 62 62 63 /* pitch objects */ 63 int curnote = 0;64 64 smpl_t pitch = 0.; 65 65 aubio_pitchdetection_t * pitchdet; 66 int bufpos = 0; 67 smpl_t curlevel = 0; 66 67 fvec_t * note_buffer = NULL; 68 fvec_t * note_buffer2 = NULL; 69 uint_t medianfiltlen = 6; 70 smpl_t curlevel = 0.; 68 71 smpl_t maxonset = 0.; 69 72 … … 101 104 } 102 105 106 107 /** append new note candidate to the note_buffer and return filtered value. we 108 * need to copy the input array as vec_median destroy its input data.*/ 109 110 void note_append(fvec_t * note_buffer, smpl_t curnote); 111 void note_append(fvec_t * note_buffer, smpl_t curnote) { 112 uint_t i = 0; 113 for (i = 0; i < note_buffer->length - 1; i++) { 114 note_buffer->data[0][i] = note_buffer->data[0][i+1]; 115 } 116 note_buffer->data[0][note_buffer->length - 1] = curnote; 117 return; 118 } 119 120 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2); 121 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2){ 122 uint_t i = 0; 123 for (i = 0; i < note_buffer->length; i++) { 124 note_buffer2->data[0][i] = note_buffer->data[0][i]; 125 } 126 return vec_median(note_buffer2); 127 } 128 129 130 smpl_t curnote = 0.; 131 smpl_t newnote = 0.; 132 uint_t isready = 0; 133 103 134 int aubio_process(float **input, float **output, int nframes); 104 135 int aubio_process(float **input, float **output, int nframes) { … … 126 157 127 158 pitch = aubio_pitchdetection(pitchdet,ibuf); 159 if(median){ 160 newnote = (FLOOR)(bintomidi(pitch,samplerate,buffer_size*4)+.5); 161 note_append(note_buffer, newnote); 162 } 128 163 129 164 /* curlevel is negatif or 1 if silence */ … … 133 168 if (curlevel == 1.) { 134 169 isonset=0; 170 if (median) isready = 0; 135 171 /* send note off */ 136 172 send_noteon(mdriver,curnote,0); 137 173 } else { 174 if (median) { 175 isready = 1; 176 } else { 138 177 /* kill old note */ 139 178 send_noteon(mdriver,curnote,0); … … 147 186 send_noteon(mdriver,curnote,127+(int)FLOOR(curlevel)); 148 187 } 188 } 189 149 190 for (pos = 0; pos < overlap_size; pos++){ 150 191 obuf->data[0][pos] = woodblock->data[0][pos]; … … 152 193 } 153 194 } else { 195 if (median) { 196 // if (curlevel != 1) { 197 // if (bufpos == note_buffer->length) 198 // curnote = aubio_getnote(note_buffer); 199 // } 200 // 201 if (isready > 0) 202 isready++; 203 if (isready == note_buffer->length) 204 { 205 //outmsg("%d, %f\n", isready, curnote); 206 send_noteon(mdriver,curnote,0); 207 /* kill old note */ 208 newnote = get_note(note_buffer, note_buffer2); 209 curnote = newnote; 210 /* get and send new one */ 211 /*if (curnote<45){ 212 send_noteon(mdriver,curnote,0); 213 } else {*/ 214 if (curnote>45){ 215 send_noteon(mdriver,curnote,127+(int)FLOOR(curlevel)); 216 } 217 } 218 } // if median 154 219 for (pos = 0; pos < overlap_size; pos++) 155 220 obuf->data[0][pos] = 0.; … … 188 253 fftgrain = new_cvec(buffer_size, channels); 189 254 190 pitchdet = new_aubio_pitchdetection(buffer_size*4, overlap_size, channels, samplerate, mcomb, freq);191 //pitchdet = new_aubio_pitchdetection(buffer_size*2, overlap_size, channels, samplerate, yin, freq);255 aubio_pitchdetection_type mode = yin; // mcomb 256 pitchdet = new_aubio_pitchdetection(buffer_size*4, overlap_size, channels, samplerate, mode, freq); 192 257 258 if (median) { 259 note_buffer = new_fvec(medianfiltlen, 1); 260 note_buffer2= new_fvec(medianfiltlen, 1); 261 } 193 262 /* read the output sound once */ 194 263 file_read(onsetfile, overlap_size, woodblock); … … 262 331 del_aubio_pitchdetection(pitchdet); 263 332 del_fvec(onset); 333 if (median) { 334 del_fvec(note_buffer); 335 del_fvec(note_buffer2); 336 } 264 337 265 338 debug("End of program.\n"); -
examples/utils.h
re50b695 ra0fd4e4 25 25 extern int usejack; 26 26 extern int usedoubled; 27 extern int median; 27 28 extern const char * output_filename; 28 29 extern const char * input_filename;
Note: See TracChangeset
for help on using the changeset viewer.