Changeset a0fd4e4
- 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
- Files:
-
- 1 deleted
- 6 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; -
python/aubio/gnuplot.py
re50b695 ra0fd4e4 109 109 data.append(myvec.get(curpos,i)) 110 110 curpos+=1 111 # FIXME again for the last frame112 curpos = 0113 while (curpos < readsize):114 data.append(myvec.get(curpos,i))115 curpos+=1116 111 time = arange(len(data))*framestep 117 112 return time,data 118 113 119 def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None , task=audio_to_array):114 def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None): 120 115 g = Gnuplot.Gnuplot(debug=1, persist=1) 121 116 d = [] … … 125 120 g.gnuplot('set multiplot;') 126 121 while (len(filenames)): 127 b,a = task(filenames.pop(0)) 128 d.append(Gnuplot.Data(b,a)) 122 d.append(plot_audio_make(filenames.pop(0))) 129 123 if not noaxis and todraw==1: 130 124 g.xlabel('Time (s)') … … 141 135 g.hardcopy(fileout, enhanced=1, color=0) 142 136 137 def make_audio_plot(time,data,maxpoints=10000): 138 """ create gnuplot plot from an audio file """ 139 import numarray 140 length = len(time) 141 downsample = length/maxpoints 142 if downsample == 0: downsample = 1 143 x = numarray.array(time).resize(length)[0:-1:downsample] 144 y = numarray.array(data).resize(length)[0:-1:downsample] 145 return Gnuplot.Data(x,y,with='lines') -
src/mathutils.c
re50b695 ra0fd4e4 401 401 return loudness; 402 402 } 403 404 void aubio_autocorr(fvec_t * input, fvec_t * output){ 405 uint_t i = 0, j = 0, length = input->length; 406 smpl_t * data = input->data[0]; 407 smpl_t * acf = output->data[0]; 408 smpl_t tmp =0.; 409 for(i=0;i<length;i++){ 410 for(j=i;j<length;j++){ 411 tmp += data[j-i]*data[j]; 412 } 413 acf[i] = tmp/(length-i); 414 tmp = 0.0; 415 } 416 } 417 -
src/mathutils.h
re50b695 ra0fd4e4 236 236 uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold); 237 237 smpl_t aubio_level_detection(fvec_t * ibuf, smpl_t threshold); 238 /** 239 * calculate normalised autocorrelation function 240 */ 241 void aubio_autocorr(fvec_t * input, fvec_t * output); 238 242 239 243 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.