Re: Configuring RemoteIO Audio unit to play and record iLBC on the iPhone
Re: Configuring RemoteIO Audio unit to play and record iLBC on the iPhone
- Subject: Re: Configuring RemoteIO Audio unit to play and record iLBC on the iPhone
- From: Chris Adamson <email@hidden>
- Date: Tue, 14 Jun 2011 09:53:40 -0400
The audio unit APIs are usually about linear PCM… I don't think units or AUGraphs accept or produce iLBC, but I could be wrong.
I haven't used iLBC, but I'm assuming it's variable bitrate? Anything VBR is going to need APIs that work with arrays of packet descriptions, which rules out iLBC. Then again, your ASBD specifies frame- and bit-rate, so I guess it's CBR? Maybe you could use an AUConverter unit on input to an AUGraph to turn iLBC into audio unit canonical inside the graph, but I think you have deeper problems than that.
Which AudioUnitSetProperty() call is failing? You have two: one to set the format you get from capture (bus 1 output) and another to set the format you're sending to play-out (bus 0 input).
THEN AGAIN, if all you want to do is record/play iLBC, you might be better off with an Audio Queue. This has the nice side effect of providing you some buffering and isolating you from the threading concerns of AUs, and if you're actually working with the network, those things are going to help you a lot.
As for using LPCM, the error message suggests your ASBD is bogus (it looks like you've copied over the bytes and frames per packet from your iLBC ASBD, like mBytesPerPacket=50, and you haven't set mBitsPerChannel or mBytesPerFrame). 16-bit mono PCM would be 2 bytes-per-packet, and since PCM is one frame-per-packet, mFramesPerPacket should be 1 and mBytesPerPacket should be 2. That's probably why you're getting !dat there.
--Chris
On Jun 13, 2011, at 7:27 PM, Fabrice Ferino wrote:
> The documentation ("CoreAudioOverview.pdf of 2008-11-03, page 45 Table 2-3
> and 2-5 and "Audio Unit Hosting Guide for iOS", section "Using the I/O
> Units") states that it should be possible to play and record sound in the
> iLBC format but we get errors when we try to setup an I/O AudioUnit
> (RemoteIO or VoiceProcessingIO) with that format. Is this expected or are
> we doing something wrong? We are using the same code successfully for the
> (simpler) G.711 formats. Here are the details:
>
> memset( &m_streamDesc, 0, sizeof(m_streamDesc));
> m_streamDesc.mSampleRate = 8000.0;
> m_streamDesc.mFormatID = kAudioFormatiLBC;
> m_streamDesc.mFormatFlags = 0;
> m_streamDesc.mChannelsPerFrame = 1;
> m_streamDesc.mFramesPerPacket = 240;
> m_streamDesc.mBytesPerPacket = 50;
> size = sizeof(m_streamDesc);
> err = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo,
> 0, NULL, &size, &m_streamDesc);
>
>
> if (0 != (err = AudioUnitSetProperty(m_audioUnit,
> kAudioUnitProperty_StreamFormat,
> kAudioUnitScope_Output, 1,
> &m_streamDesc,
> sizeof(m_streamDesc))))
> {
> goto exit; // succeeds with VoiceProcessingIO, fails with RemoteIO
> }
>
>
> if (0 != (err = AudioUnitSetProperty(m_audioUnit,
> kAudioUnitProperty_StreamFormat,
> kAudioUnitScope_Input, 0,
> &m_streamDesc,
> sizeof(m_streamDesc))))
> {
> goto exit; // fails with either VoiceProcessingIO or RemoteIO
> }
>
>
> The err returned by AudioUnitSetProperty is
> kAudioUnitErr_FormatNotSupported.
>
> If we try to set the Stream Format for the Output element of the Input
> scope of the VoiceProcessingIO AudioUnit to a "plain vanilla" LPCM format
> ( since the error happens only on that scope), then we get another error
> when calling AudioUnitInitialize with a message in the Debugger console:
>
> 2011-06-13 15:50:54.063 iLBCTest[94:6103] 15:50:54.059 <0x488b000>
> AURemoteIO::Initialize failed: '!dat' (enable 3, outf< 2 ch, 8000 Hz,
> 'lpcm' (0x0000000C) 16-bit little-endian signed integer> inf< 1 ch, 8000
> Hz, 'ilbc' (0x00000000) 0 bits/channel, 50 bytes/packet, 240
> frames/packet, 0 bytes/frame>)
>
> Is there something wrong in the code above? Or is it the expected
> behavior?
>
>
>
> _______________________________________________
> 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
_______________________________________________
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