Re: AudioUnitAddRenderNotify and AudioUnitRender mDataByteSize
Re: AudioUnitAddRenderNotify and AudioUnitRender mDataByteSize
- Subject: Re: AudioUnitAddRenderNotify and AudioUnitRender mDataByteSize
- From: William Stewart <email@hidden>
- Date: Tue, 10 Oct 2006 18:45:55 -0700
On 10/10/2006, at 12:23 PM, Craig Bakalian wrote:
Hi Bill,
This is the code that is being called from the
AudioUnitAddRenderNotify. I am checking for mNumberOfBuffers and a
PostRender. I am getting two mBuffers when this is called. Two
buffers... I am calling double buffering, perhaps I am using poor
engineering language?
Yes - you are getting two buffers because Audio Units use a
deinterleaved format - so each channel in a connection will be in its
own buffer. So, this is a two channel output, so you see two buffers.
The first buffer is the left channel, the second the right channel
But, it does have two mBuffers. Any ideas? Am I testing the
inActionFlags incorrectly?
OSStatus synthRecordCallback(void *inRefCon,
AudioUnitRenderActionFlags *inActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *inData)
{
BGAudioSynthTrackView *con = (BGAudioSynthTrackView *)inRefCon;
if([con recordEnabled])
{
int i;
for(i=0;i<inData->mNumberBuffers;i++)
{
if(*inActionFlags == kAudioUnitRenderAction_PostRender)
You want to put this test up at the top (that is, first check that
you are in post render, and if you aren't don't do anything.
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
con->audioStoragePtr = [NSData dataWithBytes: inData->mBuffers
[i].mData
length: inData->mBuffers[i].mDataByteSize];
[con->audioStorage appendData: con->audioStoragePtr];
con->totalBytesInStorage += inData->mBuffers[i].mDataByteSize;
[pool release];
You cannot do this kind of obj c here. You are in the render thread
and you should not be allocating or deallocating objects on this
thread - it will cause glitches in the audio.
You need to just syphon off the inData buffer list's contents (the 2
channels) - you can use the ExtAudioFileWriteAsync call here for
instance if you are trying to create a file
}
else if(inActionFlags == (UInt32 *)
kAudioUnitRenderAction_OutputIsSilence)
{
memset(inData->mBuffers[i].mData, 0.0, inData->mBuffers
[i].mDataByteSize);
don't do this! the AU will take care of this.
Bill
}
}
}
return (0);
}
Craig Bakalian
www.ethinkingcap.com
On Oct 10, 2006, at 1:53 PM, William Stewart wrote:
There's no double buffering in the AU, so I'm not at all sure what
you are talking about.
You also have to check in the render notify *which* notification
you are being given - you are called both for pre and post render,
and post is the only time when the buffer list will contain valid
data - check the flags passed in with your notify call
Bill
On 10/10/2006, at 3:14 AM, Craig Bakalian wrote:
Hi Bill,
Okay, I do understand this. However, I am beginning to feel it
is the double buffering through the AudioUnitAddRenderNotiry that
is getting messed up. If I capture the data from a Music Device
audio unit in a Render Notify, and store the data into my apps
memory, and then I call AudioUnitRender on a single AudioUnit and
pull the stored data through **I think** that the double buffers
are getting **messed-up**. This is true regardless of me setting
the kAudioUnitProperty_StreamFormat I set up in the input or
output of the AudioUnit.
To keep this simple, are you saying that I should be able to
store double buffered data from AudioUnitRenderNotify, and then
pull the data through a reverb unit, or a delay unit with a call
to AudioUnitRender without the data get fuzzy? Also, what exacty
is the purpose of double buffering when we have mChannelsPerFrame?
Craig Bakalian
www.ethinkingcap.com
On Oct 9, 2006, at 3:32 PM, William Stewart wrote:
The RenderNotify calls are done and expressed in *output* scope
of an AU
The Input callbacks are expressed (and done) on the input scope/
element of an AU
So, you have to look at:
Render Notify - the format for the output scope (and element)
Input Callback - the format for the input scope and element
Bill
On 08/10/2006, at 3:59 AM, Craig Bakalian wrote:
Hi,
I have just discovered that there are two buffers with a
mDataByteSize of 2048 in a callback set up with
AudioUnitAddRenderNotify. However, when setting up a
AudioUnitRender and its callback the mDataByteSize is 128 with
two buffers. So, if I use AudioUnitAddRenderNotify to capture
data and store it in memory, and then pull on that data with an
AudioUnitRender, weird stuff happens, unreliable stuff.
What is up with this?
Craig Bakalian
www.ethinkingcap.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com
This email sent to email@hidden
--
mailto:email@hidden
tel: +1 408 974 4056
___________________________________________________________________
_______
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry
Pratchett
___________________________________________________________________
_______
--
mailto:email@hidden
tel: +1 408 974 4056
_____________________________________________________________________
_____
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry
Pratchett
_____________________________________________________________________
_____
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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