What is the data type of canonical audio data in iOS 5

The iOS 5.0 documentation states that the type of canonical audio data is 16 bits, signed int ( link ):

Type of sample canonical audio data for input and output.

typedef SInt16 AudioSampleType;

Discussion

Canonical type of audio sampling for input and output in iPhone OS linear PCM with 16-bit integer samples.

However, if I right-click โ€œgo to definitionโ€ on AudioSampleType , I see the following definition in CoreAudioTypes.h :

 #if !CA_PREFER_FIXED_POINT typedef Float32 AudioSampleType; typedef Float32 AudioUnitSampleType; #else typedef SInt16 AudioSampleType; typedef SInt32 AudioUnitSampleType; #define kAudioUnitSampleFractionBits 24 #endif 

and again, when the jump to def for CA_PREFER_FIXED_POINT I see:

 #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 

Checking my code at runtime, I see that CA_PREFER_FIXED_POINT is defined as 1, both on the simulator and on my iPod.

So my questions are:

  • What is the canonical type? Is it always SInt16 on the device?
  • In which case does the 3rd line above evaluate to true? I mean, which device uses iPhone OS and uses one of the listed processors?
  • Is there a precedent when I should override CA_PREFER_FIXED_POINT to 0 (when programming for iPhone)?
+6
source share
2 answers

Read the contents of the link and this line in the headers again:

 #define kAudioUnitSampleFractionBits 24 

The canonical type for audio input and output is equivalent to SInt16.

The canonical type for other audio processing, such as the new iOS 5 filter audio, is a fixed point with 8.44 characters.

If you are running your own DSP code for real-time audio processing in iOS mode, compare it with different types, like some of the latest ARM cores, sequences of 32-bit floats are often faster than using any of the canonical types listed above and are encoded in NEON asm code is even faster.

+7
source

At Core Audio Essentials, Apple explains about canonical audio data formats :

Formats of canonical audio data Depending on the platform, Core Audio has one or two "canonical" audio data formats in the sense that these formats can be:

  • Required as an intermediate format in conversions
  • The format for which the service is optimized in Core Audio.
  • The default format or the intended format, unless you specify ASBD otherwise

Canonical formats in Core Audio:

  • IOS Input and Output Linear PCM with 16-bit integer patterns
  • iOS audio devices and other sound processing. Unbound linear PCM with fixed point samples with 8.24 bits.
  • Mac Linear PCM in and out with 32-bit floating point patterns
  • Mac audio and other audio processing Disjoint linear PCM with 32-bit floating point patterns

But: If you look at CoreAudioTypes.h in iOS 8, you will find the following:

The "canonical" flags are out of date. CA_PREFER_FIXED_POINT discouraged since the floating point performance in iOS is such that a fixed point is no longer really preferred. All Apple AudioUnits supplied floating point support. Replacement should be done by carefully reviewing the specified or expected format, but often kAudioFormatFlagsCanonical can be replaced with kAudioFormatFlagsNativeFloatPacked and kAudioFormatFlagsAudioUnitCanonical with kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved .

+3
source

Source: https://habr.com/ru/post/907353/


All Articles