- Timestamp:
- Mar 22, 2013, 1:41:54 AM (12 years ago)
- 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:
- 4865e4b
- Parents:
- 2d3212a
- Location:
- src/io
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source.c
r2d3212a r7982203 82 82 } 83 83 84 uint_t aubio_source_seek (aubio_source_t * s, uint_t seek ) { 85 #ifdef __APPLE__ 86 return aubio_source_apple_audio_seek ((aubio_source_apple_audio_t *)s->source, seek); 87 #else /* __APPLE__ */ 88 #if HAVE_SNDFILE 89 return aubio_source_sndfile_seek ((aubio_source_sndfile_t *)s->source, seek); 90 #endif /* HAVE_SNDFILE */ 91 #endif /* __APPLE__ */ 92 } -
src/io/source.h
r2d3212a r7982203 80 80 /** 81 81 82 seek source object 83 84 \param s source object, created with ::new_aubio_source 85 \param pos position to seek to, in frames 86 87 \return 0 if sucessful, non-zero on failure 88 89 */ 90 uint_t aubio_source_seek (aubio_source_t * s, uint_t pos); 91 92 /** 93 82 94 close source and cleanup memory 83 95 -
src/io/source_apple_audio.c
r2d3212a r7982203 37 37 struct _aubio_source_apple_audio_t { 38 38 uint_t channels; 39 uint_t samplerate; 39 uint_t samplerate; //< requested samplerate 40 uint_t source_samplerate; //< actual source samplerate 40 41 uint_t block_size; 41 42 … … 81 82 } 82 83 s->samplerate = samplerate; 84 s->source_samplerate = fileFormat.mSampleRate; 83 85 84 86 AudioStreamBasicDescription clientFormat; … … 144 146 UInt32 c, v, loadedPackets = s->block_size; 145 147 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList); 146 if (err) { AUBIO_ERROR("error in ExtAudioFileRead , %d\n", (int)err); goto beach;}148 if (err) { AUBIO_ERROR("error in ExtAudioFileRead %s %d\n", s->path, (int)err); goto beach;} 147 149 148 150 short *data = (short*)s->bufferList.mBuffers[0].mData; … … 182 184 } 183 185 186 uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) { 187 Float64 ratio = (Float64)(s->source_samplerate) / (Float64)(s->samplerate); 188 OSStatus err = ExtAudioFileSeek(s->audioFile, pos); 189 if (err) AUBIO_ERROR("source_apple_audio: error in ExtAudioFileSeek (%d)\n", (int)err); 190 return err; 191 } 192 184 193 uint_t aubio_source_apple_audio_get_samplerate(aubio_source_apple_audio_t * s) { 185 194 return s->samplerate; -
src/io/source_apple_audio.h
r2d3212a r7982203 86 86 /** 87 87 88 seek source object 89 90 \param s source object, created with ::new_aubio_source 91 \param pos position to seek to, in frames 92 93 \return 0 if sucessful, non-zero on failure 94 95 */ 96 uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos); 97 98 /** 99 88 100 close source and cleanup memory 89 101 -
src/io/source_sndfile.c
r2d3212a r7982203 177 177 } 178 178 179 uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) { 180 uint_t resampled_pos = (uint_t)ROUND(pos * s->input_samplerate * 1. / s->samplerate); 181 return sf_seek (s->handle, resampled_pos, SEEK_SET); 182 } 183 179 184 void del_aubio_source_sndfile(aubio_source_sndfile_t * s){ 180 185 if (!s) return; -
src/io/source_sndfile.h
r2d3212a r7982203 85 85 /** 86 86 87 seek source object 88 89 \param s source object, created with ::new_aubio_source_sndfile 90 \param pos position to seek to, in frames 91 92 \return 0 if sucessful, non-zero on failure 93 94 */ 95 uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t *s, uint_t pos); 96 97 /** 98 87 99 close source and cleanup memory 88 100
Note: See TracChangeset
for help on using the changeset viewer.