Glad to hear you got it figured out.
FYI, the format flags are a bit field, which allows them to combine behaviors. Sounds like maybe you're not familiar with these? For example, on iOS, kAudioUnitFlagsCanonical is defined (in CoreAudioTypes.h) like this:
kAudioFormatFlagsCanonical = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked
Each of these is a value with one bit turned on:
kAudioFormatFlagIsSignedInteger = (1 << 2), // 0x4 kAudioFormatFlagIsPacked = (1 << 3), // 0x8
(kAudioFormatFlagsNativeEndian is hidden behind an #ifdef that causes it to either be kAudioFormatFlagIsBigEndian, which is 0x02, or 0 for little-endian)
When you logically OR these values together, as the definition of kAudioFormatFlagsCanonical does, the presence of the whichever bit is set gets preserved.
kAudioFormatFlagIsSignedInteger 0000 0100 kAudioFormatFlagIsPacked 0000 1000 0000 1100 (0x0c, decimal 12)
So, by OR'ing the flags together, you can combine behaviors. For example, if we also wanted this format to be non-interleaved, we'd OR in that flag:
kAudioFormatFlagIsSignedInteger 0000 0100 kAudioFormatFlagIsPacked 0000 1000 kAudioFormatFlagIsNonInterleaved 0010 0000 OR --------- 0010 1100 (0x2c, decimal 44)
If you want to test for the interleaved flag, you can't just use equality; you need to apply the logical AND.
someOutputFormatIJustGot (0x2c) 0010 1100 kAudioFormatFlagIsNonInterleaved 0010 0000 AND --------- 0010 0000 (0X20, decimal 32)
In code this would be something like:
if (myFormat & kAudioFormatFlagIsNonInterleaved) {...}
After performing the AND, you can just check to see if the result is 0, since the only bit that can survive the AND operation is the one you're interested in.
Not sure if this was the issue that made your output unit and the render call incompatible, but hope it helps nonetheless.
--Chris
On Mar 4, 2013, at 8:10 AM, David Blake < email@hidden> wrote:
Success!!!! The key was setting the output scope for the generic output unit it seems! All seems to render fine now.
FYI the mFormatFlag was 12, which I assume isn't 0x20, so interleaved?
The ASBD printout shown below.
Many thanks!! David
Initializing the audio processing graph Sample Rate: 44100 Format ID: lpcm Format Flags: C Bytes per Packet: 2
Frames per Packet: 1 Bytes per Frame: 2 Channels per Frame: 1 Bits per Channel: 16
|