Changeset 5e9c68a


Ignore:
Timestamp:
Aug 9, 2005, 7:56:21 PM (19 years ago)
Author:
Paul Brossier <piem@altern.org>
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
Message:

rename file_ to aubio_sndfile, protect aubio_pitdetection_{mode,type} enumerators

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    r28d8c4a r5e9c68a  
    4040
    4141
    42 aubio_file_t * file = NULL;
    43 aubio_file_t * fileout = NULL;
     42aubio_sndfile_t * file = NULL;
     43aubio_sndfile_t * fileout = NULL;
    4444
    4545aubio_pvoc_t * pv;
     
    5959smpl_t pitch               = 0.;
    6060aubio_pitchdetection_t * pitchdet;
    61 aubio_pitchdetection_type mode = aubio_yin; // aubio_mcomb
     61aubio_pitchdetection_type mode = aubio_pitch_yin; // aubio_pitch_mcomb
    6262uint_t median         = 6;
    6363
     
    205205
    206206
    207   aubio_file_t * onsetfile;
     207  aubio_sndfile_t * onsetfile;
    208208  /* parse command line arguments */
    209209  parse_args(argc, argv);
     
    211211  woodblock = new_fvec(buffer_size,1);
    212212  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"));
    216216          /* read the output sound once */
    217           file_read(onsetfile, overlap_size, woodblock);
     217          aubio_sndfile_read(onsetfile, overlap_size, woodblock);
    218218  }
    219219
     
    221221  {
    222222    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);
    227227    if (output_filename != NULL)
    228       fileout = new_file_wo(file, output_filename);
     228      fileout = new_aubio_sndfile_wo(file, output_filename);
    229229  }
    230230
     
    235235  if (usepitch) {
    236236    pitchdet = new_aubio_pitchdetection(buffer_size*4,
    237                     overlap_size, channels, samplerate, mode, aubio_freq);
     237                    overlap_size, channels, samplerate, mode, aubio_pitchm_freq);
    238238 
    239239  if (median) {
     
    306306    frames = 0;
    307307
    308     while (overlap_size == file_read(file, overlap_size, ibuf))
     308    while (overlap_size == aubio_sndfile_read(file, overlap_size, ibuf))
    309309    {
    310310      isonset=0;
     
    312312      print();
    313313      if (output_filename != NULL) {
    314         file_write(fileout,overlap_size,obuf);
     314        aubio_sndfile_write(fileout,overlap_size,obuf);
    315315      }
    316316      frames++;
     
    318318
    319319    debug("Processed %d frames of %d samples.\n", frames, buffer_size);
    320     del_file(file);
     320    del_aubio_sndfile(file);
    321321
    322322    if (output_filename != NULL)
    323       del_file(fileout);
     323      del_aubio_sndfile(fileout);
    324324
    325325  }
  • examples/utils.h

    r28d8c4a r5e9c68a  
    7676
    7777
    78 extern aubio_file_t * file;
    79 extern aubio_file_t * fileout;
     78extern aubio_sndfile_t * file;
     79extern aubio_sndfile_t * fileout;
    8080
    8181extern aubio_pvoc_t * pv;
  • ext/sndfileio.c

    r28d8c4a r5e9c68a  
    3030#define MAX_SIZE 4096
    3131
    32 struct _aubio_file_t {
     32struct _aubio_sndfile_t {
    3333        SNDFILE *handle;
    3434        int samplerate;
     
    3939};
    4040
    41 aubio_file_t * new_file_ro(const char* outputname) {
    42         aubio_file_t * f = AUBIO_NEW(aubio_file_t);
     41aubio_sndfile_t * new_aubio_sndfile_ro(const char* outputname) {
     42        aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t);
    4343        SF_INFO sfinfo;
    4444        AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
     
    6565}
    6666
    67 int file_open_wo(aubio_file_t * f, const char* inputname) {
     67int aubio_sndfile_open_wo(aubio_sndfile_t * f, const char* inputname) {
    6868        SF_INFO sfinfo;
    6969        memset (&sfinfo, 0, sizeof (sfinfo));
     
    9090
    9191/* 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);
     92aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * fmodel, const char *outputname) {
     93        aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t);
    9494        f->samplerate    = fmodel->samplerate;
    9595        f->channels      = fmodel->channels;
    9696        f->format        = fmodel->format;
    97         file_open_wo(f, outputname);
     97        aubio_sndfile_open_wo(f, outputname);
    9898        return f;
    9999}
     
    101101
    102102/* return 0 if properly closed, 1 otherwise */
    103 int del_file(aubio_file_t * f) {
     103int del_aubio_sndfile(aubio_sndfile_t * f) {
    104104        if (sf_close(f->handle)) {
    105105                AUBIO_ERR("Error closing file.");
     
    122122/* read frames from file in data
    123123 *  return the number of frames actually read */
    124 int file_read(aubio_file_t * f, int frames, fvec_t * read) {
     124int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) {
    125125        sf_count_t read_frames;
    126126        int i,j, channels = f->channels;
     
    131131        /* allocate data for de/interleaving reallocated when needed. */
    132132        if (nsamples >= f->size) {
    133                 AUBIO_ERR("Maximum file_read buffer size exceeded.");
     133                AUBIO_ERR("Maximum aubio_sndfile_read buffer size exceeded.");
    134134                return -1;
    135135                /*
     
    158158 *   return the number of frames actually written
    159159 */
    160 int file_write(aubio_file_t * f, int frames, fvec_t * write) {
     160int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t * write) {
    161161        sf_count_t written_frames = 0;
    162162        int i, j,       channels = f->channels;
     
    166166        /* allocate data for de/interleaving reallocated when needed. */
    167167        if (nsamples >= f->size) {
    168                 AUBIO_ERR("Maximum file_write buffer size exceeded.");
     168                AUBIO_ERR("Maximum aubio_sndfile_write buffer size exceeded.");
    169169                return -1;
    170170                /*
     
    192192 */
    193193
    194 uint_t aubio_file_channels(aubio_file_t * f) {
     194uint_t aubio_sndfile_channels(aubio_sndfile_t * f) {
    195195        return f->channels;
    196196}
    197197
    198 uint_t aubio_file_samplerate(aubio_file_t * f) {
     198uint_t aubio_sndfile_samplerate(aubio_sndfile_t * f) {
    199199        return f->samplerate;
    200200}
    201201
    202 void file_info(aubio_file_t * f) {
     202void aubio_sndfile_info(aubio_sndfile_t * f) {
    203203        AUBIO_DBG("srate    : %d\n", f->samplerate);
    204204        AUBIO_DBG("channels : %d\n", f->channels);
  • ext/sndfileio.h

    r28d8c4a r5e9c68a  
    3131 * sndfile object
    3232 */
    33 typedef struct _aubio_file_t aubio_file_t;
     33typedef struct _aubio_sndfile_t aubio_sndfile_t;
    3434/**
    3535 * Open a sound file for reading
    3636 */
    37 aubio_file_t * new_file_ro (const char * inputfile);
     37aubio_sndfile_t * new_aubio_sndfile_ro (const char * inputfile);
    3838/**
    3939 * Copy file model from previously opened sound file.
    4040 */
    41 aubio_file_t * new_file_wo(aubio_file_t * existingfile, const char * outputname);
     41aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * existingfile, const char * outputname);
    4242/**
    4343 * Open a sound file for writing
    4444 */
    45 int file_open_wo (aubio_file_t * file, const char * outputname);
     45int aubio_sndfile_open_wo (aubio_sndfile_t * file, const char * outputname);
    4646/**
    4747 * Read frames data from file
    4848 */
    49 int file_read(aubio_file_t * file, int frames, fvec_t * read);
     49int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read);
    5050/**
    5151 * Write data of length frames to file
    5252 */
    53 int file_write(aubio_file_t * file, int frames, fvec_t * write);
     53int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write);
    5454/**
    5555 * Close file and delete file object
    5656 */
    57 int del_file(aubio_file_t * file);
     57int del_aubio_sndfile(aubio_sndfile_t * file);
    5858/**
    5959 * Return some files facts
    6060 */
    61 void file_info(aubio_file_t * file);
     61void aubio_sndfile_info(aubio_sndfile_t * file);
    6262/**
    6363 * Return number of channel in file
    6464 */
    65 uint_t aubio_file_channels(aubio_file_t * file);
    66 uint_t aubio_file_samplerate(aubio_file_t * file);
     65uint_t aubio_sndfile_channels(aubio_sndfile_t * file);
     66uint_t aubio_sndfile_samplerate(aubio_sndfile_t * file);
    6767
    6868#ifdef __cplusplus
  • python/aubio/aubioclass.py

    r28d8c4a r5e9c68a  
    3030    def __init__(self,filename,model=None):
    3131        if (model!=None):
    32             self.file = new_file_wo(model.file,filename)
     32            self.file = new_aubio_sndfile_wo(model.file,filename)
    3333        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)
    3737    def info(self):
    38         file_info(self.file)
     38        aubio_sndfile_info(self.file)
    3939    def samplerate(self):
    40         return aubio_file_samplerate(self.file)
     40        return aubio_sndfile_samplerate(self.file)
    4141    def channels(self):
    42         return aubio_file_channels(self.file)
     42        return aubio_sndfile_channels(self.file)
    4343    def read(self,nfram,vecread):
    44         return file_read(self.file,nfram,vecread())
     44        return aubio_sndfile_read(self.file,nfram,vecread())
    4545    def write(self,nfram,vecwrite):
    46         return file_write(self.file,nfram,vecwrite())
     46        return aubio_sndfile_write(self.file,nfram,vecwrite())
    4747
    4848class pvoc:
     
    205205    return mylist
    206206
    207 def getpitch(filein,mode=aubio_mcomb,bufsize=1024,hopsize=512,omode=aubio_freq,
     207def getpitch(filein,mode=aubio_pitch_mcomb,bufsize=1024,hopsize=512,omode=aubio_pitchm_freq,
    208208        samplerate=44100.,silence=-70):
    209209    frameread = 0
     
    228228
    229229class 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):
    232232        self.pitchp = new_aubio_pitchdetection(bufsize,hopsize,channels,
    233233                samplerate,mode,omode)
  • python/aubiopitch

    r28d8c4a r5e9c68a  
    1414        nvalue = parser.rargs[0]
    1515        if   nvalue == 'mcomb' :
    16                  setattr(parser.values, option.dest, aubio_mcomb)
     16                 setattr(parser.values, option.dest, aubio_pitch_mcomb)
    1717        elif nvalue == 'yin'           :
    18                  setattr(parser.values, option.dest, aubio_yin)
     18                 setattr(parser.values, option.dest, aubio_pitch_yin)
    1919        elif nvalue == 'fcomb'         :
    20                  setattr(parser.values, option.dest, aubio_fcomb)
     20                 setattr(parser.values, option.dest, aubio_pitch_fcomb)
    2121        elif nvalue == 'schmitt'      :
    22                  setattr(parser.values, option.dest, aubio_schmitt)
     22                 setattr(parser.values, option.dest, aubio_pitch_schmitt)
    2323
    2424
     
    3030                          help="input sound file")
    3131        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,
    3333                          help="pitch detection mode [default=mcomb] \
    3434                          mcomb|yin|fcomb|schmitt")
  • src/pitchdetection.c

    r28d8c4a r5e9c68a  
    6262        p->bufsize = bufsize;
    6363        switch(p->type) {
    64                 case aubio_yin:
     64                case aubio_pitch_yin:
    6565                        p->buf      = new_fvec(bufsize,channels);
    6666                        p->yin      = new_fvec(bufsize/2,channels);
    6767                        p->callback = aubio_pitchdetection_yin;
    6868                        break;
    69                 case aubio_mcomb:
     69                case aubio_pitch_mcomb:
    7070                        p->pv       = new_aubio_pvoc(bufsize, hopsize, channels);
    7171                        p->fftgrain = new_cvec(bufsize, channels);
     
    7373                        p->callback = aubio_pitchdetection_mcomb;
    7474                        break;
    75                 case aubio_fcomb:
     75                case aubio_pitch_fcomb:
    7676                        p->buf      = new_fvec(bufsize,channels);
    7777                        p->fcomb    = new_aubio_pitchfcomb(bufsize,samplerate);
    7878                        p->callback = aubio_pitchdetection_fcomb;
    7979                        break;
    80                 case aubio_schmitt:
     80                case aubio_pitch_schmitt:
    8181                        p->buf      = new_fvec(bufsize,channels);
    8282                        p->schmitt  = new_aubio_pitchschmitt(bufsize,samplerate);
     
    9191void del_aubio_pitchdetection(aubio_pitchdetection_t * p) {
    9292        switch(p->type) {
    93                 case aubio_yin:
     93                case aubio_pitch_yin:
    9494                        del_fvec(p->yin);
    9595                        del_fvec(p->buf);
    9696                        break;
    97                 case aubio_mcomb:
     97                case aubio_pitch_mcomb:
    9898                        del_aubio_pvoc(p->pv);
    9999                        del_cvec(p->fftgrain);
    100100                        del_aubio_pitchmcomb(p->mcomb);
    101101                        break;
    102                 case aubio_schmitt:
     102                case aubio_pitch_schmitt:
    103103                        del_fvec(p->buf);
    104104                        del_aubio_pitchschmitt(p->schmitt);
    105105                        break;
    106                 case aubio_fcomb:
     106                case aubio_pitch_fcomb:
    107107                        del_fvec(p->buf);
    108108                        del_aubio_pitchfcomb(p->fcomb);
  • src/pitchdetection.h

    r28d8c4a r5e9c68a  
    2525
    2626typedef enum {
    27         aubio_yin,
    28         aubio_mcomb,
    29         aubio_schmitt,
    30         aubio_fcomb
     27        aubio_pitch_yin,
     28        aubio_pitch_mcomb,
     29        aubio_pitch_schmitt,
     30        aubio_pitch_fcomb
    3131} aubio_pitchdetection_type;
    3232
    3333typedef enum {
    34         aubio_freq,
    35         aubio_midi,
    36         aubio_cent,
    37         aubio_bin
     34        aubio_pitchm_freq,
     35        aubio_pitchm_midi,
     36        aubio_pitchm_cent,
     37        aubio_pitchm_bin
    3838} aubio_pitchdetection_mode;
    3939
  • swig/aubio.i

    r28d8c4a r5e9c68a  
    5252
    5353/* 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);
     54extern aubio_sndfile_t * new_aubio_sndfile_ro (const char * inputfile);
     55extern aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * existingfile, const char * outputname);
     56extern void aubio_sndfile_info(aubio_sndfile_t * file);
     57extern int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write);
     58extern int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read);
     59extern int del_aubio_sndfile(aubio_sndfile_t * file);
     60extern uint_t aubio_sndfile_channels(aubio_sndfile_t * file);
     61extern uint_t aubio_sndfile_samplerate(aubio_sndfile_t * file);
    6262
    6363/* fft */
     
    159159/* pitch detection */
    160160typedef enum {
    161         aubio_yin,
    162         aubio_mcomb,
    163         aubio_schmitt,
    164         aubio_fcomb
     161        aubio_pitch_yin,
     162        aubio_pitch_mcomb,
     163        aubio_pitch_schmitt,
     164        aubio_pitch_fcomb
    165165} aubio_pitchdetection_type;
    166166
    167167typedef enum {
    168         aubio_freq,
    169         aubio_midi,
    170         aubio_cent,
    171         aubio_bin
     168        aubio_pitchm_freq,
     169        aubio_pitchm_midi,
     170        aubio_pitchm_cent,
     171        aubio_pitchm_bin
    172172} aubio_pitchdetection_mode;
    173173
Note: See TracChangeset for help on using the changeset viewer.