Re: Getting BufferLists
Re: Getting BufferLists
- Subject: Re: Getting BufferLists
- From: Robert Grant <email@hidden>
- Date: Tue, 3 Feb 2004 19:04:03 -0500
Craig,
(I sent this to you a couple of weeks back - but maybe you didn't get
it? - anyway it's here for the group to pick apart):
What I've done for capturing live audio is as follows:
Attach a RenderNotification callback to the penultimate AU in your
graph (the one before the output unit) and look for PostRender
notifications. (You'll get both PreRender and PostRender notifications
coming into the same callback.) The reason you want the penultimate AU
is that the buffers passed by the PostRender callbacks on the Output AU
will be in the format of the AudioDevice and thus differ from device to
device making your buffer saving code more complex. (I'm probably
misrepresenting this - but it's what I found worked).
You need to create a circular queue for saving the buffers as they're
rendered because the file writer thread needs to run separately from
the Render thread.
Create a file writer and converter (see my example code on the Swiki)
and return the buffers from the circular queue as they become available
(i.e. the write head has moved on) in the converter callback.
You'll need to set up some mechanism to signal that recording has ended
- a BOOL would do.
Hope that helps,
Robert.
On Feb 3, 2004, at 6:18 PM, Craig Bakalian wrote:
Hi,
I am back at trying to save BufferList from a microphone input. I got
the microphone working okay, yet I do not know where to put the
AudioUnitRenderCallback...
Here's what I got so far->
-(void)buildGraph
{
ComponentResult result;
NewAUGraph(&mainGraph);
AUGraphOpen(mainGraph);
UInt32 size;
size = sizeof(AudioDeviceID);
AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&size, &deviceID);
ComponentDescription mic;
mic.componentType = kAudioUnitType_Output;
mic.componentSubType = kAudioUnitSubType_HALOutput;
mic.componentManufacturer = kAudioUnitManufacturer_Apple;
mic.componentFlags = 0;
mic.componentFlagsMask = 0;
AUGraphNewNode(mainGraph, &mic, 0, NULL, &micNode);
AUGraphGetNodeInfo(mainGraph, micNode, NULL, NULL,NULL, &micUnit);
UInt32 enableIO = 1;
result = AudioUnitSetProperty(micUnit,
kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO,
sizeof(UInt32));
result = AudioUnitSetProperty(micUnit,
kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0,
&enableIO, sizeof(UInt32));
result = AudioUnitSetProperty(micUnit,
kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0,
&deviceID, sizeof(UInt32));
UInt32 hasIO=0;
UInt32 dataSize = sizeof(UInt32);
result = AudioUnitGetProperty(micUnit, kAudioOutputUnitProperty_HasIO,
kAudioUnitScope_Input, 1, &hasIO, &dataSize );
NSLog(@"%d", hasIO);
ComponentDescription reverb;
reverb.componentFlags = 0;
reverb.componentFlagsMask = 0;
reverb.componentType = kAudioUnitType_Effect;
reverb.componentSubType = kAudioUnitSubType_MatrixReverb;
reverb.componentManufacturer = kAudioUnitManufacturer_Apple;
AUGraphNewNode(mainGraph, &reverb, 0, NULL, &reverbNode);
OSStatus err;
err = AUGraphConnectNodeInput(mainGraph, micNode, 1, reverbNode, 0);
err = AUGraphConnectNodeInput(mainGraph, reverbNode, 0, micNode,
0);
err = AUGraphInitialize(mainGraph);
err = AUGraphStart(mainGraph);
}
I want to get the BufferLists out of the micNode. Yet, could I put a
RenderCallback on the reverbNode and from there get the BufferList
coming into it from the micNode? If so, any code would be appreciated.
Ya know, I think I know how to do this if the component is a
AUNTComponent, yet I don't have a clue about AUComponents.
Craig Bakalian
www.eThinkingCap.com
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.