- Timestamp:
- Dec 20, 2018, 7:44:51 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- 49ac58e0
- Parents:
- 4edba9d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_apple_audio.c
r4edba9d r4c72a9c 25 25 #include "fvec.h" 26 26 #include "fmat.h" 27 #include "ioutils.h" 27 28 #include "io/source_apple_audio.h" 28 29 … … 210 211 uint_t c, v; 211 212 UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s); 213 uint_t length = aubio_source_validate_input_length("source_apple_audio", 214 s->path, s->block_size, read_to->length); 212 215 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 213 216 214 for (v = 0; v < loadedPackets; v++) { 217 length = MIN(loadedPackets, length); 218 219 for (v = 0; v < length; v++) { 215 220 read_to->data[v] = 0.; 216 221 for (c = 0; c < s->channels; c++) { … … 220 225 } 221 226 // short read, fill with zeros 222 if (loadedPackets < s->block_size) { 223 for (v = loadedPackets; v < s->block_size; v++) { 224 read_to->data[v] = 0.; 225 } 226 } 227 228 *read = (uint_t)loadedPackets; 229 return; 227 aubio_source_pad_output(read_to, length); 228 229 *read = (uint_t)length; 230 230 } 231 231 232 232 void aubio_source_apple_audio_do_multi(aubio_source_apple_audio_t *s, fmat_t * read_to, uint_t * read) { 233 233 uint_t c, v; 234 uint_t length = aubio_source_validate_input_length("source_apple_audio", 235 s->path, s->block_size, read_to->length); 236 uint_t channels = aubio_source_validate_input_channels("source_apple_audio", 237 s->path, s->channels, read_to->height); 234 238 UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s); 235 239 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 236 240 237 for (v = 0; v < loadedPackets; v++) { 238 for (c = 0; c < read_to->height; c++) { 241 length = MIN(loadedPackets, length); 242 243 for (v = 0; v < length; v++) { 244 for (c = 0; c < channels; c++) { 239 245 read_to->data[c][v] = data[ v * s->channels + c]; 240 246 } 241 247 } 242 // if read_data has more channels than the file 243 if (read_to->height > s->channels) { 244 // copy last channel to all additional channels 245 for (v = 0; v < loadedPackets; v++) { 246 for (c = s->channels; c < read_to->height; c++) { 247 read_to->data[c][v] = data[ v * s->channels + (s->channels - 1)]; 248 } 249 } 250 } 251 // short read, fill with zeros 252 if (loadedPackets < s->block_size) { 253 for (v = loadedPackets; v < s->block_size; v++) { 254 for (c = 0; c < read_to->height; c++) { 255 read_to->data[c][v] = 0.; 256 } 257 } 258 } 259 260 *read = (uint_t)loadedPackets; 261 return; 248 249 aubio_source_pad_multi_output(read_to, s->channels, (uint_t)length); 250 251 *read = (uint_t)length; 262 252 } 263 253
Note: See TracChangeset
for help on using the changeset viewer.