Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 1.04 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Empty float ** for sound samples
  2. - (OSStatus) readFloatsConsecutive:(SInt64)numFrames intoArray:(float**)audio withOffset:(long)offset
  3.        
  4. if (audio) {
  5.     for (long c = 0; c < mExtAFNumChannels; c++) {
  6.         if (!audio[c]) continue;  // this executes for both channels
  7.                                   // but doesnt proceed into next for loop
  8.         for (long v = 0; v < numFrames; v++) {
  9.             if (v < loadedPackets) audio[c][v+offset] = (float)data[v*mExtAFNumChannels+c] / 32768.f;
  10.             else audio[c][v+offset] = 0.f;
  11.         }
  12.     }
  13. }
  14.        
  15. [reader readFloatsConsecutive:frameCount intoArray:arrayToFill];
  16.        
  17. // this array was passed into the function as tempArray  which is float **tempArray = NULL;
  18.  arrayToFill  = (float **) malloc ( (frameCount * channelCount) * sizeof( float ));
  19.        
  20. arrayToFill = (float *) malloc ( (frameCount * channelCount) * sizeof( float ));
  21.        
  22. arrayToFill = (float **)calloc(channelCount, sizeof(float*));
  23. for (int i = 0; i < channelCount; ++i)
  24.   arrayToFill[i] = (float*)calloc(frameCount, sizeof(float));