Changes in / [db120ac:54a2ca2]
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source.h
rdb120ac r54a2ca2 26 26 Media source to read blocks of consecutive audio samples from file 27 27 28 To write to file, use ::aubio_sink_t.29 30 28 \example io/test-source.c 31 \example io/test-source_multi.c32 29 33 30 */ -
src/io/source_apple_audio.c
rdb120ac r54a2ca2 52 52 extern CFURLRef getURLFromPath(const char * path); 53 53 54 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path);55 56 54 aubio_source_apple_audio_t * new_aubio_source_apple_audio(char_t * path, uint_t samplerate, uint_t block_size) 57 55 { 58 56 aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t); 59 57 58 s->path = path; 60 59 s->block_size = block_size; 61 s->samplerate = samplerate; 62 63 if ( aubio_source_apple_audio_open ( s, path ) ) { 64 goto beach; 65 } 66 return s; 67 68 beach: 69 AUBIO_FREE(s); 70 return NULL; 71 } 72 73 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path) 74 { 60 75 61 OSStatus err = noErr; 76 62 UInt32 propSize; 77 s->path = path;78 63 79 64 // open the resource url … … 92 77 if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;} 93 78 94 if (s ->samplerate == 0) {95 s ->samplerate = fileFormat.mSampleRate;79 if (samplerate == 0) { 80 samplerate = fileFormat.mSampleRate; 96 81 //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate); 97 82 } 98 83 s->samplerate = samplerate; 99 84 s->source_samplerate = fileFormat.mSampleRate; 100 85 s->channels = fileFormat.mChannelsPerFrame; … … 139 124 140 125 // compute the size of the segments needed to read the input file 141 UInt32 samples = s->block_size * s->channels;142 Float64 rateRatio = s->samplerate / s->source_samplerate;126 UInt32 samples = s->block_size * clientFormat.mChannelsPerFrame; 127 Float64 rateRatio = clientFormat.mSampleRate / fileFormat.mSampleRate; 143 128 uint_t segmentSize= (uint_t)(samples * rateRatio + .5); 144 129 if (rateRatio < 1.) { 145 130 segmentSize = (uint_t)(samples / rateRatio + .5); 146 131 } else if (rateRatio > 1.) { 147 AUBIO_WRN("up-sampling %s from %0 dHz to %0dHz\n", s->path, s->source_samplerate, s->samplerate);132 AUBIO_WRN("up-sampling %s from %0.2fHz to %0.2fHz\n", s->path, fileFormat.mSampleRate, clientFormat.mSampleRate); 148 133 } else { 149 134 assert ( segmentSize == samples ); … … 152 137 153 138 // allocate the AudioBufferList 154 if (createAubioBufferList(&s->bufferList, s->channels, segmentSize)) { 155 AUBIO_ERR("source_apple_audio: failed creating bufferList\n"); 156 goto beach; 157 } 158 139 if (createAubioBufferList(&s->bufferList, s->channels, segmentSize)) err = -1; 140 141 return s; 142 159 143 beach: 160 return err; 144 AUBIO_FREE(s); 145 return NULL; 161 146 } 162 147 … … 220 205 } 221 206 222 uint_t aubio_source_apple_audio_close (aubio_source_apple_audio_t *s) 223 { 207 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ 224 208 OSStatus err = noErr; 225 if (!s || !s->audioFile) { return 1; }209 if (!s || !s->audioFile) { return; } 226 210 err = ExtAudioFileDispose(s->audioFile); 227 211 if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err); 228 212 s->audioFile = NULL; 229 return err;230 }231 232 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){233 aubio_source_apple_audio_close (s);234 213 freeAudioBufferList(&s->bufferList); 235 214 AUBIO_FREE(s);
Note: See TracChangeset
for help on using the changeset viewer.