if (TARGET_IPHONE_SIMULATOR && SYSTEM_VERSION_LESS_THAN(@"7.0") ) {
// In Simulator before iOS 7 I get 1 buffer with 2 identical channels containing AudioSampleType (SInt16) samples
AudioSampleType* samples = (AudioSampleType*)(ioData->mBuffers[0].mData);
float* floatSamples = taas->analyzeBuffer;
// Convert native AudioSampleType(SInt16/short) to floats so we can use more vector math functions
// Discard every other sample (right channel). But we still have the same number of Frames.
vDSP_vflt16(samples, 2, floatSamples, 1, inNumberFrames);
// Scale from 0 to 1 by dividing by the max int value
float scaleMax = (INT16_MAX + 1 );
vDSP_vsdiv(floatSamples, 1, &scaleMax, floatSamples, 1, inNumberFrames);
taas->bytesFedToRingBuf = inNumberFrames * sizeof(float) ;
assert(inNumberFrames * sizeof(float) == ioData->mBuffers[0].mDataByteSize);
TPCircularBufferProduceBytes(ringBuffer, floatSamples, taas->bytesFedToRingBuf);
}
else {
// Apparently on a real iOS device we magically already have 32-bit floats here. Boom!
// I have 2 buffers with 1 channel each, but I'll just use the left (mBuffer[0])
float* samples = (float*)(ioData->mBuffers[0].mData);
taas->bytesFedToRingBuf = inNumberFrames * sizeof(float) ;
assert(inNumberFrames * sizeof(float) == ioData->mBuffers[0].mDataByteSize);
TPCircularBufferProduceBytes(ringBuffer, samples, taas->bytesFedToRingBuf);
}