Changeset c6e7ba1


Ignore:
Timestamp:
Apr 25, 2016, 4:42:43 PM (4 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
b4e1438
Parents:
b60f297
Message:

src/io/source_sndfile.h: add _get_duration

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_sndfile.c

    rb60f297 rc6e7ba1  
    5454  int input_channels;
    5555  int input_format;
     56  int duration;
    5657
    5758  // resampling stuff
     
    106107  s->input_channels   = sfinfo.channels;
    107108  s->input_format     = sfinfo.format;
     109  s->duration         = sfinfo.frames;
    108110
    109111  if (samplerate == 0) {
     
    273275}
    274276
     277uint_t aubio_source_sndfile_get_duration (const aubio_source_sndfile_t * s) {
     278  if (s && s->duration) {
     279    return s->duration;
     280  }
     281  return 0;
     282}
     283
    275284uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
    276285  uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio);
  • src/io/source_sndfile.h

    rb60f297 rc6e7ba1  
    121121/**
    122122
     123  get the duration of source object, in frames
     124
     125  \param s source object, created with ::new_aubio_source_sndfile
     126  \return number of frames in file
     127
     128*/
     129uint_t aubio_source_sndfile_get_duration (const aubio_source_sndfile_t *s);
     130
     131/**
     132
    123133  close source
    124134
  • tests/src/io/test-source_sndfile.c

    rb60f297 rc6e7ba1  
    3939  fvec_t *vec = new_fvec(hop_size);
    4040
     41  uint_t n_frames_expected = aubio_source_sndfile_get_duration(s);
     42
    4143  samplerate = aubio_source_sndfile_get_samplerate(s);
    4244
     
    4749  } while ( read == hop_size );
    4850
    49   PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
    50     n_frames / hop_size, source_path);
     51  PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n",
     52            n_frames, n_frames_expected, samplerate, n_frames / hop_size,
     53            source_path);
    5154
    5255  del_fvec (vec);
Note: See TracChangeset for help on using the changeset viewer.