Re: AudioBufferList configuration when rendering from AUHAL
Re: AudioBufferList configuration when rendering from AUHAL
- Subject: Re: AudioBufferList configuration when rendering from AUHAL
- From: Pierre Pasquet <email@hidden>
- Date: Thu, 01 Mar 2018 13:45:37 +0000
Hello Brian and Doug,
Thanks for your answers.
Brian, I’ve tried your solution.
I have set up my application as follow :
- a Record Stream Basic Description that is basically the stream format of the
AUHAL output element. (Should it be the input element?)
- a Write Stream Basic Description that is a stream format for AAC, defined as
follow :
CAStreamBasicDescription fileStream;
memset(&fileStream, 0, sizeof(fileStream));
fileStream.mChannelsPerFrame = 2;
fileStream.mFormatID = kAudioFormatMPEG4AAC;
fileStream.mFormatFlags = 0;
fileStream.mSampleRate = 0;
fileStream.mBitsPerChannel = 0;
Then, I create a ExtAudioFile with ExtAudioFileCreateWithURL whose format is
basically the format INTO which it should write (AAC)
ExtAudioFileCreateWithURL(
(CFURLRef) outputFileURL,
kAudioFileCAFType,
&mWriteSBD,
NULL,
kAudioFileFlags_EraseFile,
&mOutputFileRef
)
And I set the ClientDataFormat property to be the format of the Audio it will
receive (AUHAL output element format)
Everything else is correctly set up and the AUHAL render correctly. I use
ExtAudioFileWriteAsync within the callback to write the AudioBufferList in the
audio file.
Yet, when I try to play the file In my computer, it doesn’t produce any sound.
What is strange is that it’s size is growing, so I guess the AudioBufferList is
correctly written into the file. But, under the “More Info” of the file
inspector, It says duration is 00:00 seconds. Hence the confusion.
Do you have any clue? I have updated my repository if you want to have a closer
look https://github.com/PiR-P/Dopplr/tree/compressed-format
<https://github.com/PiR-P/Dopplr/tree/compressed-format>
Thanks for your help !
> On 1 Mar 2018, at 05:23, Brian Willoughby <email@hidden> wrote:
>
> Pierre,
>
> Rather than try to put AUHAL into AAC format, I would just use ExtAudioFile.
> Set it up so that the ExtAudioFile takes PCM as input, and AAC as the file
> format. It will handle the conversion for you. You can specify .caf or any
> other format that legally holds AAC. I believe that ExtAudioFile handles the
> threading issues.
>
> AUHAL is designed to talk to the hardware, so it’s not really going to
> support all file formats. In contrast, ExtAudioFile is designed to handle
> most file formats (and you can even add your own via plugins).
>
> Of course, Doug’s suggestion may be even easier.
>
> Brian
>
>
> On Feb 28, 2018, at 8:29 PM, Doug Wyatt <email@hidden
> <mailto:email@hidden>> wrote:
>> AUHAL does not support non-PCM formats. There are other higher-level API’s
>> to accomplish what it sounds like you’re trying to do, e.g. AVAudioRecorder
>> and AVAudioEngine with an AVAudioFile.
>>
>> Doug
>>
>> On Feb 28, 2018, at 15:48, Pierre Pasquet <email@hidden
>> <mailto:email@hidden>> wrote:
>>> Hi All,
>>>
>>> I have posted a question on stack overflow
>>> (https://stackoverflow.com/questions/49038140/audiobufferlist-for-auhal-unit-whose-output-stream-format-is-compressed
>>>
>>> <https://stackoverflow.com/questions/49038140/audiobufferlist-for-auhal-unit-whose-output-stream-format-is-compressed>)
>>> but since CoreAudio isn’t that popular I thought it would be worth it to
>>> ask it here as well.
>>>
>>> To make it short (even if it’s not that easy in this case), I’d like to
>>> record audio from an input device using au AUHAL, encode it into AAC format
>>> and write to a file (.caf at the moment). So the input scope of the AUHAL
>>> reads data in LPCM and output scope should render AAC (everything in bus 1).
>>>
>>> However, I have an error when rendering (AudioUnitRender returns -50). I
>>> really don’t know what I’m doing wrong. My audio stream is in stereo so I
>>> allocate two AudioBuffer but it doesn’t seem to work.
>>>
>>> Anyway, everything is explained in more detail in the stack overflow
>>> question. Would be great if you could have a look at it and answer me
>>> either here or on the post to give a better visibility.
>>>
>>> Thanks !
>>> Best,
>>> Pierre
>
_______________________________________________
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