#endif /* __APPLE__ */
}
+uint_t aubio_source_seek (aubio_source_t * s, uint_t seek ) {
+#ifdef __APPLE__
+ return aubio_source_apple_audio_seek ((aubio_source_apple_audio_t *)s->source, seek);
+#else /* __APPLE__ */
+#if HAVE_SNDFILE
+ return aubio_source_sndfile_seek ((aubio_source_sndfile_t *)s->source, seek);
+#endif /* HAVE_SNDFILE */
+#endif /* __APPLE__ */
+}
*/
uint_t aubio_source_get_samplerate(aubio_source_t * s);
+/**
+
+ seek source object
+
+ \param s source object, created with ::new_aubio_source
+ \param pos position to seek to, in frames
+
+ \return 0 if sucessful, non-zero on failure
+
+*/
+uint_t aubio_source_seek (aubio_source_t * s, uint_t pos);
+
/**
close source and cleanup memory
struct _aubio_source_apple_audio_t {
uint_t channels;
- uint_t samplerate;
+ uint_t samplerate; //< requested samplerate
+ uint_t source_samplerate; //< actual source samplerate
uint_t block_size;
char_t *path;
//AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate);
}
s->samplerate = samplerate;
+ s->source_samplerate = fileFormat.mSampleRate;
AudioStreamBasicDescription clientFormat;
propSize = sizeof(clientFormat);
void aubio_source_apple_audio_do(aubio_source_apple_audio_t *s, fvec_t * read_to, uint_t * read) {
UInt32 c, v, loadedPackets = s->block_size;
OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList);
- if (err) { AUBIO_ERROR("error in ExtAudioFileRead, %d\n", (int)err); goto beach;}
+ if (err) { AUBIO_ERROR("error in ExtAudioFileRead %s %d\n", s->path, (int)err); goto beach;}
short *data = (short*)s->bufferList.mBuffers[0].mData;
return;
}
+uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) {
+ Float64 ratio = (Float64)(s->source_samplerate) / (Float64)(s->samplerate);
+ OSStatus err = ExtAudioFileSeek(s->audioFile, pos);
+ if (err) AUBIO_ERROR("source_apple_audio: error in ExtAudioFileSeek (%d)\n", (int)err);
+ return err;
+}
+
uint_t aubio_source_apple_audio_get_samplerate(aubio_source_apple_audio_t * s) {
return s->samplerate;
}
*/
uint_t aubio_source_apple_audio_get_samplerate(aubio_source_apple_audio_t * s);
+/**
+
+ seek source object
+
+ \param s source object, created with ::new_aubio_source
+ \param pos position to seek to, in frames
+
+ \return 0 if sucessful, non-zero on failure
+
+*/
+uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos);
+
/**
close source and cleanup memory
return s->samplerate;
}
+uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
+ uint_t resampled_pos = (uint_t)ROUND(pos * s->input_samplerate * 1. / s->samplerate);
+ return sf_seek (s->handle, resampled_pos, SEEK_SET);
+}
+
void del_aubio_source_sndfile(aubio_source_sndfile_t * s){
if (!s) return;
if (sf_close(s->handle)) {
*/
uint_t aubio_source_sndfile_get_samplerate(aubio_source_sndfile_t * s);
+/**
+
+ seek source object
+
+ \param s source object, created with ::new_aubio_source_sndfile
+ \param pos position to seek to, in frames
+
+ \return 0 if sucessful, non-zero on failure
+
+*/
+uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t *s, uint_t pos);
+
/**
close source and cleanup memory