Changeset cfa46b9


Ignore:
Timestamp:
Apr 25, 2016, 6:05:02 PM (9 years ago)
Author:
Paul Brossier <piem@piem.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:
07867cd
Parents:
6e765ed
Message:

python/ext/py-source.c: added duration

Location:
python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-source.c

    r6e765ed rcfa46b9  
    99  uint_t channels;
    1010  uint_t hop_size;
     11  uint_t duration;
    1112  fvec_t *read_to;
    1213  fmat_t *mread_to;
     
    147148    self->channels = aubio_source_get_channels ( self->o );
    148149  }
     150  self->duration = aubio_source_get_duration ( self->o );
    149151
    150152  self->read_to = new_fvec(self->hop_size);
     
    227229  {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY,
    228230    "number of consecutive frames that will be read at each do or do_multi call"},
     231  {"duration", T_INT, offsetof (Py_source, duration), READONLY,
     232    "total number of frames in the source (estimated)"},
    229233  { NULL } // sentinel
    230234};
  • python/tests/test_source.py

    r6e765ed rcfa46b9  
    100100            assert a == b + c
    101101
     102    def test_duration(self):
     103        for p in list_of_sounds:
     104            total_frames = 0
     105            f = source(p)
     106            duration = f.duration
     107            while True:
     108                vec, read = f()
     109                total_frames += read
     110                if read < f.hop_size: break
     111            self.assertEqual(duration, total_frames)
     112
    102113class aubio_source_readmulti_test_case(aubio_source_read_test_case):
    103114
Note: See TracChangeset for help on using the changeset viewer.