Changes in src/io/source_apple_audio.c [4865e4b:8c43bf7]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_apple_audio.c
r4865e4b r8c43bf7 23 23 #include "aubio_priv.h" 24 24 #include "fvec.h" 25 #include "fmat.h"26 25 #include "io/source_apple_audio.h" 27 26 … … 38 37 struct _aubio_source_apple_audio_t { 39 38 uint_t channels; 40 uint_t samplerate; //< requested samplerate 41 uint_t source_samplerate; //< actual source samplerate 39 uint_t samplerate; 42 40 uint_t block_size; 43 41 … … 58 56 s->path = path; 59 57 s->block_size = block_size; 58 s->channels = 1; 60 59 61 60 OSStatus err = noErr; … … 82 81 } 83 82 s->samplerate = samplerate; 84 s->source_samplerate = fileFormat.mSampleRate;85 s->channels = fileFormat.mChannelsPerFrame;86 83 87 84 AudioStreamBasicDescription clientFormat; … … 101 98 err = ExtAudioFileSetProperty(s->audioFile, kExtAudioFileProperty_ClientDataFormat, 102 99 propSize, &clientFormat); 103 if (err) { 104 AUBIO_ERROR("error in ExtAudioFileSetProperty, %d\n", (int)err); 105 #if 1100 if (err) { AUBIO_ERROR("error in ExtAudioFileSetProperty, %d\n", (int)err); goto beach;} 101 102 #if 0 106 103 // print client and format descriptions 107 104 AUBIO_DBG("Opened %s\n", s->path); … … 120 117 AUBIO_DBG("file/client Format.mReserved : %6d / %d\n", (int)fileFormat.mReserved , (int)clientFormat.mReserved); 121 118 #endif 122 goto beach;123 }124 119 125 120 // compute the size of the segments needed to read the input file … … 132 127 AUBIO_WRN("up-sampling %s from %0.2fHz to %0.2fHz\n", s->path, fileFormat.mSampleRate, clientFormat.mSampleRate); 133 128 } else { 134 assert ( 129 assert (segmentSize == samples ); 135 130 //AUBIO_DBG("not resampling, segmentSize %d, block_size %d\n", segmentSize, s->block_size); 136 131 } … … 149 144 UInt32 c, v, loadedPackets = s->block_size; 150 145 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList); 151 if (err) { AUBIO_ERROR("error in ExtAudioFileRead %s %d\n", s->path, (int)err); goto beach;}146 if (err) { AUBIO_ERROR("error in ExtAudioFileRead, %d\n", (int)err); goto beach;} 152 147 153 148 short *data = (short*)s->bufferList.mBuffers[0].mData; … … 176 171 } 177 172 178 void aubio_source_apple_audio_do_multi(aubio_source_apple_audio_t *s, fmat_t * read_to, uint_t * read) {179 UInt32 c, v, loadedPackets = s->block_size;180 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList);181 if (err) { AUBIO_ERROR("source_apple_audio: error in ExtAudioFileRead, %d\n", (int)err); goto beach;}182 183 short *data = (short*)s->bufferList.mBuffers[0].mData;184 185 smpl_t **buf = read_to->data;186 187 for (v = 0; v < loadedPackets; v++) {188 for (c = 0; c < s->channels; c++) {189 buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + c]);190 }191 }192 // short read, fill with zeros193 if (loadedPackets < s->block_size) {194 for (v = loadedPackets; v < s->block_size; v++) {195 for (c = 0; c < s->channels; c++) {196 buf[c][v] = 0.;197 }198 }199 }200 *read = (uint_t)loadedPackets;201 return;202 beach:203 *read = 0;204 return;205 }206 207 173 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ 208 174 OSStatus err = noErr; … … 216 182 } 217 183 218 uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) {219 SInt64 resampled_pos = (SInt64)ROUND( pos * s->source_samplerate * 1. / s->samplerate );220 OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos);221 if (err) AUBIO_ERROR("source_apple_audio: error in ExtAudioFileSeek (%d)\n", (int)err);222 return err;223 }224 225 184 uint_t aubio_source_apple_audio_get_samplerate(aubio_source_apple_audio_t * s) { 226 185 return s->samplerate; 227 186 } 228 187 229 uint_t aubio_source_apple_audio_get_channels(aubio_source_apple_audio_t * s) {230 return s->channels;231 }232 233 188 #endif /* __APPLE__ */
Note: See TracChangeset
for help on using the changeset viewer.