Changeset 5e9c68a
- Timestamp:
- Aug 9, 2005, 7:56:21 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:
- a29ad46
- Parents:
- 28d8c4a
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified examples/utils.c ¶
r28d8c4a r5e9c68a 40 40 41 41 42 aubio_ file_t * file = NULL;43 aubio_ file_t * fileout = NULL;42 aubio_sndfile_t * file = NULL; 43 aubio_sndfile_t * fileout = NULL; 44 44 45 45 aubio_pvoc_t * pv; … … 59 59 smpl_t pitch = 0.; 60 60 aubio_pitchdetection_t * pitchdet; 61 aubio_pitchdetection_type mode = aubio_ yin; // aubio_mcomb61 aubio_pitchdetection_type mode = aubio_pitch_yin; // aubio_pitch_mcomb 62 62 uint_t median = 6; 63 63 … … 205 205 206 206 207 aubio_ file_t * onsetfile;207 aubio_sndfile_t * onsetfile; 208 208 /* parse command line arguments */ 209 209 parse_args(argc, argv); … … 211 211 woodblock = new_fvec(buffer_size,1); 212 212 if (output_filename || usejack) { 213 (onsetfile = new_ file_ro(onset_filename)) ||214 (onsetfile = new_ file_ro("sounds/woodblock.aiff")) ||215 (onsetfile = new_ file_ro("../sounds/woodblock.aiff"));213 (onsetfile = new_aubio_sndfile_ro(onset_filename)) || 214 (onsetfile = new_aubio_sndfile_ro("sounds/woodblock.aiff")) || 215 (onsetfile = new_aubio_sndfile_ro("../sounds/woodblock.aiff")); 216 216 /* read the output sound once */ 217 file_read(onsetfile, overlap_size, woodblock);217 aubio_sndfile_read(onsetfile, overlap_size, woodblock); 218 218 } 219 219 … … 221 221 { 222 222 debug("Opening files ...\n"); 223 file = new_ file_ro (input_filename);224 if (verbose) file_info(file);225 channels = aubio_ file_channels(file);226 samplerate = aubio_ file_samplerate(file);223 file = new_aubio_sndfile_ro (input_filename); 224 if (verbose) aubio_sndfile_info(file); 225 channels = aubio_sndfile_channels(file); 226 samplerate = aubio_sndfile_samplerate(file); 227 227 if (output_filename != NULL) 228 fileout = new_ file_wo(file, output_filename);228 fileout = new_aubio_sndfile_wo(file, output_filename); 229 229 } 230 230 … … 235 235 if (usepitch) { 236 236 pitchdet = new_aubio_pitchdetection(buffer_size*4, 237 overlap_size, channels, samplerate, mode, aubio_ freq);237 overlap_size, channels, samplerate, mode, aubio_pitchm_freq); 238 238 239 239 if (median) { … … 306 306 frames = 0; 307 307 308 while (overlap_size == file_read(file, overlap_size, ibuf))308 while (overlap_size == aubio_sndfile_read(file, overlap_size, ibuf)) 309 309 { 310 310 isonset=0; … … 312 312 print(); 313 313 if (output_filename != NULL) { 314 file_write(fileout,overlap_size,obuf);314 aubio_sndfile_write(fileout,overlap_size,obuf); 315 315 } 316 316 frames++; … … 318 318 319 319 debug("Processed %d frames of %d samples.\n", frames, buffer_size); 320 del_ file(file);320 del_aubio_sndfile(file); 321 321 322 322 if (output_filename != NULL) 323 del_ file(fileout);323 del_aubio_sndfile(fileout); 324 324 325 325 } -
TabularUnified examples/utils.h ¶
r28d8c4a r5e9c68a 76 76 77 77 78 extern aubio_ file_t * file;79 extern aubio_ file_t * fileout;78 extern aubio_sndfile_t * file; 79 extern aubio_sndfile_t * fileout; 80 80 81 81 extern aubio_pvoc_t * pv; -
TabularUnified ext/sndfileio.c ¶
r28d8c4a r5e9c68a 30 30 #define MAX_SIZE 4096 31 31 32 struct _aubio_ file_t {32 struct _aubio_sndfile_t { 33 33 SNDFILE *handle; 34 34 int samplerate; … … 39 39 }; 40 40 41 aubio_ file_t * new_file_ro(const char* outputname) {42 aubio_ file_t * f = AUBIO_NEW(aubio_file_t);41 aubio_sndfile_t * new_aubio_sndfile_ro(const char* outputname) { 42 aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t); 43 43 SF_INFO sfinfo; 44 44 AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo)); … … 65 65 } 66 66 67 int file_open_wo(aubio_file_t * f, const char* inputname) {67 int aubio_sndfile_open_wo(aubio_sndfile_t * f, const char* inputname) { 68 68 SF_INFO sfinfo; 69 69 memset (&sfinfo, 0, sizeof (sfinfo)); … … 90 90 91 91 /* setup file struct from existing one */ 92 aubio_ file_t * new_file_wo(aubio_file_t * fmodel, const char *outputname) {93 aubio_ file_t * f = AUBIO_NEW(aubio_file_t);92 aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * fmodel, const char *outputname) { 93 aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t); 94 94 f->samplerate = fmodel->samplerate; 95 95 f->channels = fmodel->channels; 96 96 f->format = fmodel->format; 97 file_open_wo(f, outputname);97 aubio_sndfile_open_wo(f, outputname); 98 98 return f; 99 99 } … … 101 101 102 102 /* return 0 if properly closed, 1 otherwise */ 103 int del_ file(aubio_file_t * f) {103 int del_aubio_sndfile(aubio_sndfile_t * f) { 104 104 if (sf_close(f->handle)) { 105 105 AUBIO_ERR("Error closing file."); … … 122 122 /* read frames from file in data 123 123 * return the number of frames actually read */ 124 int file_read(aubio_file_t * f, int frames, fvec_t * read) {124 int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) { 125 125 sf_count_t read_frames; 126 126 int i,j, channels = f->channels; … … 131 131 /* allocate data for de/interleaving reallocated when needed. */ 132 132 if (nsamples >= f->size) { 133 AUBIO_ERR("Maximum file_read buffer size exceeded.");133 AUBIO_ERR("Maximum aubio_sndfile_read buffer size exceeded."); 134 134 return -1; 135 135 /* … … 158 158 * return the number of frames actually written 159 159 */ 160 int file_write(aubio_file_t * f, int frames, fvec_t * write) {160 int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t * write) { 161 161 sf_count_t written_frames = 0; 162 162 int i, j, channels = f->channels; … … 166 166 /* allocate data for de/interleaving reallocated when needed. */ 167 167 if (nsamples >= f->size) { 168 AUBIO_ERR("Maximum file_write buffer size exceeded.");168 AUBIO_ERR("Maximum aubio_sndfile_write buffer size exceeded."); 169 169 return -1; 170 170 /* … … 192 192 */ 193 193 194 uint_t aubio_ file_channels(aubio_file_t * f) {194 uint_t aubio_sndfile_channels(aubio_sndfile_t * f) { 195 195 return f->channels; 196 196 } 197 197 198 uint_t aubio_ file_samplerate(aubio_file_t * f) {198 uint_t aubio_sndfile_samplerate(aubio_sndfile_t * f) { 199 199 return f->samplerate; 200 200 } 201 201 202 void file_info(aubio_file_t * f) {202 void aubio_sndfile_info(aubio_sndfile_t * f) { 203 203 AUBIO_DBG("srate : %d\n", f->samplerate); 204 204 AUBIO_DBG("channels : %d\n", f->channels); -
TabularUnified ext/sndfileio.h ¶
r28d8c4a r5e9c68a 31 31 * sndfile object 32 32 */ 33 typedef struct _aubio_ file_t aubio_file_t;33 typedef struct _aubio_sndfile_t aubio_sndfile_t; 34 34 /** 35 35 * Open a sound file for reading 36 36 */ 37 aubio_ file_t * new_file_ro (const char * inputfile);37 aubio_sndfile_t * new_aubio_sndfile_ro (const char * inputfile); 38 38 /** 39 39 * Copy file model from previously opened sound file. 40 40 */ 41 aubio_ file_t * new_file_wo(aubio_file_t * existingfile, const char * outputname);41 aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * existingfile, const char * outputname); 42 42 /** 43 43 * Open a sound file for writing 44 44 */ 45 int file_open_wo (aubio_file_t * file, const char * outputname);45 int aubio_sndfile_open_wo (aubio_sndfile_t * file, const char * outputname); 46 46 /** 47 47 * Read frames data from file 48 48 */ 49 int file_read(aubio_file_t * file, int frames, fvec_t * read);49 int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read); 50 50 /** 51 51 * Write data of length frames to file 52 52 */ 53 int file_write(aubio_file_t * file, int frames, fvec_t * write);53 int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write); 54 54 /** 55 55 * Close file and delete file object 56 56 */ 57 int del_ file(aubio_file_t * file);57 int del_aubio_sndfile(aubio_sndfile_t * file); 58 58 /** 59 59 * Return some files facts 60 60 */ 61 void file_info(aubio_file_t * file);61 void aubio_sndfile_info(aubio_sndfile_t * file); 62 62 /** 63 63 * Return number of channel in file 64 64 */ 65 uint_t aubio_ file_channels(aubio_file_t * file);66 uint_t aubio_ file_samplerate(aubio_file_t * file);65 uint_t aubio_sndfile_channels(aubio_sndfile_t * file); 66 uint_t aubio_sndfile_samplerate(aubio_sndfile_t * file); 67 67 68 68 #ifdef __cplusplus -
TabularUnified python/aubio/aubioclass.py ¶
r28d8c4a r5e9c68a 30 30 def __init__(self,filename,model=None): 31 31 if (model!=None): 32 self.file = new_ file_wo(model.file,filename)32 self.file = new_aubio_sndfile_wo(model.file,filename) 33 33 else: 34 self.file = new_ file_ro(filename)35 def __del__(self): 36 del_ file(self.file)34 self.file = new_aubio_sndfile_ro(filename) 35 def __del__(self): 36 del_aubio_sndfile(self.file) 37 37 def info(self): 38 file_info(self.file)38 aubio_sndfile_info(self.file) 39 39 def samplerate(self): 40 return aubio_ file_samplerate(self.file)40 return aubio_sndfile_samplerate(self.file) 41 41 def channels(self): 42 return aubio_ file_channels(self.file)42 return aubio_sndfile_channels(self.file) 43 43 def read(self,nfram,vecread): 44 return file_read(self.file,nfram,vecread())44 return aubio_sndfile_read(self.file,nfram,vecread()) 45 45 def write(self,nfram,vecwrite): 46 return file_write(self.file,nfram,vecwrite())46 return aubio_sndfile_write(self.file,nfram,vecwrite()) 47 47 48 48 class pvoc: … … 205 205 return mylist 206 206 207 def getpitch(filein,mode=aubio_ mcomb,bufsize=1024,hopsize=512,omode=aubio_freq,207 def getpitch(filein,mode=aubio_pitch_mcomb,bufsize=1024,hopsize=512,omode=aubio_pitchm_freq, 208 208 samplerate=44100.,silence=-70): 209 209 frameread = 0 … … 228 228 229 229 class pitchdetection: 230 def __init__(self,mode=aubio_ mcomb,bufsize=2048,hopsize=1024,231 channels=1,samplerate=44100.,omode=aubio_ freq):230 def __init__(self,mode=aubio_pitch_mcomb,bufsize=2048,hopsize=1024, 231 channels=1,samplerate=44100.,omode=aubio_pitchm_freq): 232 232 self.pitchp = new_aubio_pitchdetection(bufsize,hopsize,channels, 233 233 samplerate,mode,omode) -
TabularUnified python/aubiopitch ¶
r28d8c4a r5e9c68a 14 14 nvalue = parser.rargs[0] 15 15 if nvalue == 'mcomb' : 16 setattr(parser.values, option.dest, aubio_ mcomb)16 setattr(parser.values, option.dest, aubio_pitch_mcomb) 17 17 elif nvalue == 'yin' : 18 setattr(parser.values, option.dest, aubio_ yin)18 setattr(parser.values, option.dest, aubio_pitch_yin) 19 19 elif nvalue == 'fcomb' : 20 setattr(parser.values, option.dest, aubio_ fcomb)20 setattr(parser.values, option.dest, aubio_pitch_fcomb) 21 21 elif nvalue == 'schmitt' : 22 setattr(parser.values, option.dest, aubio_ schmitt)22 setattr(parser.values, option.dest, aubio_pitch_schmitt) 23 23 24 24 … … 30 30 help="input sound file") 31 31 parser.add_option("-m","--mode", action="callback", 32 callback=check_mode, dest="mode", default=aubio_ mcomb,32 callback=check_mode, dest="mode", default=aubio_pitch_mcomb, 33 33 help="pitch detection mode [default=mcomb] \ 34 34 mcomb|yin|fcomb|schmitt") -
TabularUnified src/pitchdetection.c ¶
r28d8c4a r5e9c68a 62 62 p->bufsize = bufsize; 63 63 switch(p->type) { 64 case aubio_ yin:64 case aubio_pitch_yin: 65 65 p->buf = new_fvec(bufsize,channels); 66 66 p->yin = new_fvec(bufsize/2,channels); 67 67 p->callback = aubio_pitchdetection_yin; 68 68 break; 69 case aubio_ mcomb:69 case aubio_pitch_mcomb: 70 70 p->pv = new_aubio_pvoc(bufsize, hopsize, channels); 71 71 p->fftgrain = new_cvec(bufsize, channels); … … 73 73 p->callback = aubio_pitchdetection_mcomb; 74 74 break; 75 case aubio_ fcomb:75 case aubio_pitch_fcomb: 76 76 p->buf = new_fvec(bufsize,channels); 77 77 p->fcomb = new_aubio_pitchfcomb(bufsize,samplerate); 78 78 p->callback = aubio_pitchdetection_fcomb; 79 79 break; 80 case aubio_ schmitt:80 case aubio_pitch_schmitt: 81 81 p->buf = new_fvec(bufsize,channels); 82 82 p->schmitt = new_aubio_pitchschmitt(bufsize,samplerate); … … 91 91 void del_aubio_pitchdetection(aubio_pitchdetection_t * p) { 92 92 switch(p->type) { 93 case aubio_ yin:93 case aubio_pitch_yin: 94 94 del_fvec(p->yin); 95 95 del_fvec(p->buf); 96 96 break; 97 case aubio_ mcomb:97 case aubio_pitch_mcomb: 98 98 del_aubio_pvoc(p->pv); 99 99 del_cvec(p->fftgrain); 100 100 del_aubio_pitchmcomb(p->mcomb); 101 101 break; 102 case aubio_ schmitt:102 case aubio_pitch_schmitt: 103 103 del_fvec(p->buf); 104 104 del_aubio_pitchschmitt(p->schmitt); 105 105 break; 106 case aubio_ fcomb:106 case aubio_pitch_fcomb: 107 107 del_fvec(p->buf); 108 108 del_aubio_pitchfcomb(p->fcomb); -
TabularUnified src/pitchdetection.h ¶
r28d8c4a r5e9c68a 25 25 26 26 typedef enum { 27 aubio_yin,28 aubio_mcomb,29 aubio_ schmitt,30 aubio_ fcomb27 aubio_pitch_yin, 28 aubio_pitch_mcomb, 29 aubio_pitch_schmitt, 30 aubio_pitch_fcomb 31 31 } aubio_pitchdetection_type; 32 32 33 33 typedef enum { 34 aubio_freq,35 aubio_midi,36 aubio_cent,37 aubio_bin34 aubio_pitchm_freq, 35 aubio_pitchm_midi, 36 aubio_pitchm_cent, 37 aubio_pitchm_bin 38 38 } aubio_pitchdetection_mode; 39 39 -
TabularUnified swig/aubio.i ¶
r28d8c4a r5e9c68a 52 52 53 53 /* sndfile */ 54 extern aubio_ file_t * new_file_ro (const char * inputfile);55 extern aubio_ file_t * new_file_wo(aubio_file_t * existingfile, const char * outputname);56 extern void file_info(aubio_file_t * file);57 extern int file_write(aubio_file_t * file, int frames, fvec_t * write);58 extern int file_read(aubio_file_t * file, int frames, fvec_t * read);59 extern int del_ file(aubio_file_t * file);60 extern uint_t aubio_ file_channels(aubio_file_t * file);61 extern uint_t aubio_ file_samplerate(aubio_file_t * file);54 extern aubio_sndfile_t * new_aubio_sndfile_ro (const char * inputfile); 55 extern aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * existingfile, const char * outputname); 56 extern void aubio_sndfile_info(aubio_sndfile_t * file); 57 extern int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write); 58 extern int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read); 59 extern int del_aubio_sndfile(aubio_sndfile_t * file); 60 extern uint_t aubio_sndfile_channels(aubio_sndfile_t * file); 61 extern uint_t aubio_sndfile_samplerate(aubio_sndfile_t * file); 62 62 63 63 /* fft */ … … 159 159 /* pitch detection */ 160 160 typedef enum { 161 aubio_yin,162 aubio_mcomb,163 aubio_ schmitt,164 aubio_ fcomb161 aubio_pitch_yin, 162 aubio_pitch_mcomb, 163 aubio_pitch_schmitt, 164 aubio_pitch_fcomb 165 165 } aubio_pitchdetection_type; 166 166 167 167 typedef enum { 168 aubio_freq,169 aubio_midi,170 aubio_cent,171 aubio_bin168 aubio_pitchm_freq, 169 aubio_pitchm_midi, 170 aubio_pitchm_cent, 171 aubio_pitchm_bin 172 172 } aubio_pitchdetection_mode; 173 173
Note: See TracChangeset
for help on using the changeset viewer.