Re: Different sample types between Simulator and device
Re: Different sample types between Simulator and device
- Subject: Re: Different sample types between Simulator and device
- From: Doug Wyatt <email@hidden>
- Date: Fri, 13 Sep 2013 16:47:48 -0700
I can't emphasize enough: when you are dealing with AURemoteIO (or any AudioUnit for that matter), you should always be specific about the format you wish to use. In the case of AURemoteIO, you should always be using:
AudioStreamBasicDescription myformat;
... fill out myformat to the myRenderFormat you want to provide for output ...
OSStatus err = AudioUnitSetProperty(myRemoteIO, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &myRenderFormat, sizeof(myRenderFormat));
This specifies the format of the buffers you supply to the output unit. The implementation will convert to the format it is using. You can query the format of element 0's output scope to find out what *that* format is.
If you do not set a client format, you are at the mercy of the implementation's defaults, which will differ across routes, the device vs. simulator, and OS releases.
On Sep 4, 2013, at 23:44 , Nathan Vonnahme <email@hidden> wrote:
> 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:
>>
>> On Wed, Sep 4, 2013 at 6:36 AM, Nathan Vonnahme <email@hidden> wrote:
>>
>> But after trying to figure out 8.24 fixed-point because everything says that is canonical within AudioGraphs,
>>
>> Can you point to *anything* which says this?
>>
>
> 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?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden