Well, I was really hoping for more response from my big remaining question,
does anyone know how the callback should decide whether to cast mData to float* (my devices) or sInt16* (simulator)? I guess for now I will hardcode it using #if TARGET_IPHONE_SIMULATOR. There's nothing I see in the AUGraphAddRenderNotify params to indicate the format of mData...
But in response to:
On Sep 4, 2013, at 5:10 AM, Paul Davis < email@hidden> wrote:
What I meant in my very late night ramblings was that I thought I had specified SInt16 by setting the ASBD on both scopes of the RIO unit, but now I am wondering if I got that wrong or if there is just something different about AUGraphAddRenderNotify, about which I can find very little documentation.
But once I figured out I had 32-bit samples I first assumed they were 8.24 because, for example,
the canonical formats are those that the system is best suited to use and that Core Audio automatically converts to for its own internal use. On Mac OS X, kAudioFormatFlagsCanonical and kAudioFormatFlagsAudioUnitCanonical both use floating point samples, but floating point is a significant expense on the low-power chips of early ARM devices. So on iOS, kAudioFormatFlagsCanonical uses signed integer samples, and kAudioFormatFlagsAudioUnitCanonical uses 8.24 fixed point.
—Adamson, Chris; Avila, Kevin (2012-04-03). Learning Core Audio: A Hands-On Guide to Audio Programming for Mac and iOS (Kindle Locations 5802-5806). Pearson Education (US). Kindle Edition.
Or more definitively, CoreAudioTypes.h says,
/*! @typedef AudioSampleType @abstract The canonical audio sample type used by the various CoreAudio APIs */ #if !CA_PREFER_FIXED_POINT typedef Float32 AudioSampleType; typedef Float32 AudioUnitSampleType; #else typedef SInt16 AudioSampleType; typedef SInt32 AudioUnitSampleType; #define kAudioUnitSampleFractionBits 24 #endif
and above, it's clear that CA_PREFER_FIXED_POINT is defined for all iOS devices and the Simulator
#if !defined(CA_PREFER_FIXED_POINT) #if TARGET_OS_IPHONE #if (TARGET_CPU_X86 || TARGET_CPU_X86_64 || TARGET_CPU_PPC || TARGET_CPU_PPC64) && !TARGET_IPHONE_SIMULATOR #define CA_PREFER_FIXED_POINT 0 #else #define CA_PREFER_FIXED_POINT 1 #endif #else #define CA_PREFER_FIXED_POINT 0 #endif #endif
So I was surprised to find regular old 32-bit float values in my buffer data on an iOS device. The examples I've seen are all SInt16 or 8.24, though now I know to search for it I see an example and another (both by Nik Reiman) using Float32s in an AU effect. But how come it is SInt16s in the Simulator?
|