Ignore:
Timestamp:
Mar 16, 2013, 3:43:37 PM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
de5d3f1
Parents:
4f872d7
Message:

src/io/source_apple_audio.c: simplify _do, downmixing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_apple_audio.c

    r4f872d7 r8c43bf7  
    146146  if (err) { AUBIO_ERROR("error in ExtAudioFileRead, %d\n", (int)err); goto beach;}
    147147
     148  short *data = (short*)s->bufferList.mBuffers[0].mData;
     149
    148150  smpl_t *buf = read_to->data;
    149151
    150   short *data = (short*)s->bufferList.mBuffers[0].mData;
     152  for (v = 0; v < loadedPackets; v++) {
     153    buf[v] = 0.;
     154    for (c = 0; c < s->channels; c++) {
     155      buf[v] += SHORT_TO_FLOAT(data[ v * s->channels + c]);
     156    }
     157    buf[v] /= (smpl_t)s->channels;
     158  }
     159  // short read, fill with zeros
     160  if (loadedPackets < s->block_size) {
     161    for (v = loadedPackets; v < s->block_size; v++) {
     162      buf[v] = 0.;
     163    }
     164  }
    151165
    152   if (buf) {
    153       for (c = 0; c < s->channels; c++) {
    154           for (v = 0; v < s->block_size; v++) {
    155               if (v < loadedPackets) {
    156                   buf[v * s->channels + c] =
    157                       SHORT_TO_FLOAT(data[ v * s->channels + c]);
    158               } else {
    159                   buf[v * s->channels + c] = 0.f;
    160               }
    161           }
    162       }
    163   }
    164   //if (loadedPackets < s->block_size) return EOF;
    165166  *read = (uint_t)loadedPackets;
    166167  return;
Note: See TracChangeset for help on using the changeset viewer.