From 063fa5a466c41b6b81d284ca98b7cb7275b2dd73 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 27 Jul 2012 11:24:32 -0600 Subject: [PATCH] src/io/source_sndfile.{c,h}: add get_samplerate, if == 1 use file samplerate --- src/io/source_sndfile.c | 6 ++++++ src/io/source_sndfile.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/io/source_sndfile.c b/src/io/source_sndfile.c index 7fbe2f22..93e37d6c 100644 --- a/src/io/source_sndfile.c +++ b/src/io/source_sndfile.c @@ -89,6 +89,8 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera 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); @@ -168,6 +170,10 @@ void aubio_source_sndfile_do(aubio_source_sndfile_t * s, fvec_t * read_data, uin *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){ if (!s) return; if (sf_close(s->handle)) { diff --git a/src/io/source_sndfile.h b/src/io/source_sndfile.h index eac27719..cfa38b7e 100644 --- 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 */ -- 2.26.2