Re: Streaming Graph to file
Re: Streaming Graph to file
- Subject: Re: Streaming Graph to file
- From: Geoff Hufford <email@hidden>
- Date: Mon, 06 Mar 2006 13:05:43 -0600
I am trying the ExtAudioFile approach to export a sound file from my graph,
but I get hung up at one point.
I attach a kAudioUnitSubType_GenericOutput output unit to the end of the
graph (after the mixer) so I can set it to convert the data format for the
file writer.
Set the output unit format as follows:
CAStreamBasicDescription casbd;
casbd.mFormatID = 'lpcm';
casbd.mSampleRate = 48000;
casbd.mChannelsPerFrame = 2;
casbd.SetCanonical(2, true);
AudioUnitSetProperty (m_output, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 0, &casbd, size);
...
ExtAudioFileCreateNew - works
Get AudioStreamBasicDescription from the output unit and then set the file
writer input format.
result = ExtAudioFileSetProperty(outfile,
kExtAudioFileProperty_ClientDataFormat, dataSize, &inputStreamFormat);
==> This is where I hit a wall. The call returns 'fmt?' as the result. So I
guess I am not planning to send the writer a format it likes. I do not
understand the blurb in the header file:
The format must be linear PCM (kAudioFormatLinearPCM).
You must set this in order to encode or decode a non-PCM file data format.
You may set this on PCM files to specify the data format used in your
calls to read/write.
I also am unsure if using kAudioUnitSubType_GenericOutput is going to be a
successful way to convert the data flowing in the graph to a format that the
file writer wants. It would be simpler if the file writer will accept the
non-interleaved float format that I can pull out of the mixer in the graph,
but I got the impression that isnt possible. Please correct me if the output
unit conversion is an unnecessary step.
On 3/6/06 4:40 AM, "Karim Morsy" <email@hidden> wrote:
> just a hint in case you haven't already done so... use ExtAudioFileWriteAsync
> instead of ExtAudioFileWrite. It is much easier to use, as it performs the
> write for you on an internal thread very efficiently and you don't have to
> worry about managing buffers and threads.
> before starting your audio capture you should initialize the async
> write: ExtAudioFileWriteAsync(outfile, 0, NULL).
> whenever your graph is running and you want to start recording, just add a
> render notification call back function to the audio unit from which you want
> to save the audio data to file. and in the audio unit's post render
> notification perform the write:
Thanks, I will try it when I get the issue above resolved. Doesn't this
approach require that the graph is playing real-time through the output
unit? I like that I don¹t have to manage the process, but I need to have a
fast as possible export of the file that isnt clocked by the output device.
If a faster than real-time export is possible, Do I have to be concerned
about calling ExtAudioFileWriteAsync too many times before it is ready for
more data?
Geoff
_______________________________________________
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