Add kAudioUnitSubType_Varispeed to AUGraph in iOS5

2

I am trying to add a kAudioUnitSubType to an AUGraph in iOS 5 but when I add it and call AUGraphInitialize an error code -10868 is returned (kAudioUnitErr_FormatNotSupported).

Here is my AudioComponentDescription:

AudioComponentDescription varispeedDescription;
varispeedDescription.componentType = kAudioUnitType_FormatConverter;
varispeedDescription.componentSubType = kAudioUnitSubType_Varispeed;
varispeedDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
varispeedDescription.componentFlags = 0;
varispeedDescription.componentFlagsMask = 0;

If I print the state of the graph right before I initialise the graph I get the following:

AudioUnitGraph 0x918000:
    Member Nodes:
    node 1: 'auou' 'rioc' 'appl', instance 0x16dba0 O  
    node 2: 'aumx' 'mcmx' 'appl', instance 0x1926f0 O  
    node 3: 'aufc' 'vari' 'appl', instance 0x193b00 O  
    Connections:
    node   2 bus   0 => node   3 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000C2C)   8.24-bit little-endian signed integer, deinterleaved]
    node   3 bus   0 => node   1 bus   0  [ 2 ch,      0 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    Input Callbacks:
    {0x39a5, 0x172e24} => node   2 bus   0  [2 ch, 44100 Hz]
    {0x39a5, 0x172e24} => node   2 bus   1  [2 ch, 44100 Hz]
  CurrentState:
    mLastUpdateError=0, eventsToProcess=F, isRunning=F

As you can see the connection from the Varispeed unit to the Remote IO unit shows a very strange format. What is even more odd is that if I run this on the simulator as opposed to on my development device the format that shows is 16-bit little endian integer, deinterleaved. If I try to set the stream format on the input or output scopes of the Varispeed unit I get the same error code -10868.

The asbd that I am setting as the stream format on each Multichannel mixer bus on the input scope is as follows:

stereoFormat.mSampleRate = sampleRate;
stereoFormat.mFormatID = kAudioFormatLinearPCM;
stereoFormat.mFormatFlags = kAudioFormatFlagsCanonical;
stereoFormat.mFramesPerPacket = 1;
stereoFormat.mChannelsPerFrame = 2;
stereoFormat.mBitsPerChannel = 16;
stereoFormat.mBytesPerPacket = 4;
stereoFormat.mBytesPerFrame = 4;

The reason I am not using the canonical format for audio units is because I am reading samples from an AVAssetReader which I cannot configure to output 8.24 Signed Integer samples.

If I take out the Varispeed unit from the graph and connect the Multichannel Mixer unit to the input of the Remote IO unit the graph initialises and plays fine. Any idea what I'm doing wrong?

iphone
ios
audio
core-audio
asked on Stack Overflow Oct 26, 2011 by Dino • edited Oct 26, 2011 by Dino

1 Answer

2

your io unit is asking for 32bit float and recieving 8.24 from the varispeed unit, hence the format error.

you can set the stream format on the output of varispeed to match the input format of the io unit like this:

AudioStreamBasicDescription asbd;
UInt32 asbdSize = sizeof (asbd);
memset (&asbd, 0, sizeof (asbd));

AudioUnitGetProperty(ioaudiounit , kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &asbd, &asbdSize);

AudioUnitSetProperty(varipseedaudiounit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &asbd, sizeof(asbd));
answered on Stack Overflow Dec 23, 2011 by Ed Filowat

User contributions licensed under CC BY-SA 3.0