ref: 063fa5a466c41b6b81d284ca98b7cb7275b2dd73
parent: 85ebab8aa7504e6e9ffc700657dcfc35dd058668
author: Paul Brossier <piem@piem.org>
date: Fri Jul 27 07:24:32 EDT 2012
src/io/source_sndfile.{c,h}: add get_samplerate, if == 1 use file samplerate
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -89,6 +89,8 @@
s->input_channels = sfinfo.channels;
s->input_format = sfinfo.format;
+ if (s->samplerate == 1) s->samplerate = s->input_samplerate;
+
/* compute input block size required before resampling */
s->ratio = s->samplerate/(float)s->input_samplerate;
s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5);
@@ -166,6 +168,10 @@
#endif /* HAVE_SAMPLERATE */
*read = (int)FLOOR(s->ratio * read_samples / input_channels + .5);
+}
+
+uint_t aubio_source_sndfile_get_samplerate(aubio_source_sndfile_t * s) {
+ return s->samplerate;
}
void del_aubio_source_sndfile(aubio_source_sndfile_t * s){
--- a/src/io/source_sndfile.h
+++ b/src/io/source_sndfile.h
@@ -24,6 +24,7 @@
typedef struct _aubio_source_sndfile_t aubio_source_sndfile_t;
aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplerate, uint_t block_size);
void aubio_source_sndfile_do(aubio_source_sndfile_t * s, fvec_t * read_to, uint_t * read);
+uint_t aubio_source_sndfile_get_samplerate(aubio_source_sndfile_t * s);
void del_aubio_source_sndfile(aubio_source_sndfile_t * s);
#endif /* _AUBIO_SOURCE_SNDFILE_H */