int input_samplerate;
int input_channels;
int input_format;
+ int duration;
// resampling stuff
smpl_t ratio;
s->input_samplerate = sfinfo.samplerate;
s->input_channels = sfinfo.channels;
s->input_format = sfinfo.format;
+ s->duration = sfinfo.frames;
if (samplerate == 0) {
s->samplerate = s->input_samplerate;
return s->input_channels;
}
+uint_t aubio_source_sndfile_get_duration (const aubio_source_sndfile_t * s) {
+ if (s && s->duration) {
+ return s->duration;
+ }
+ return 0;
+}
+
uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio);
sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
/**
+ get the duration of source object, in frames
+
+ \param s source object, created with ::new_aubio_source_sndfile
+ \return number of frames in file
+
+*/
+uint_t aubio_source_sndfile_get_duration (const aubio_source_sndfile_t *s);
+
+/**
+
close source
\param s source object, created with ::new_aubio_source_sndfile
if (!s) { err = 1; goto beach; }
fvec_t *vec = new_fvec(hop_size);
+ uint_t n_frames_expected = aubio_source_sndfile_get_duration(s);
+
samplerate = aubio_source_sndfile_get_samplerate(s);
do {
n_frames += read;
} while ( read == hop_size );
- PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
- n_frames / hop_size, source_path);
+ PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n",
+ n_frames, n_frames_expected, samplerate, n_frames / hop_size,
+ source_path);
del_fvec (vec);
del_aubio_source_sndfile (s);