I went ahead and ran your gist and all I had to do was
use kAudioUnitSubType_DefaultOutput rather
than kAudioUnitSubType_GenericOutput and I got a working lowpass with a
render callback, you were very close! I did not set any ASBDs anywhere.
And for the offline render, following christian's advice is the way to go.
You don't need a graph or io unit, just AudioUnitInitialize your lowpass
unit. I also checked out EZAudio.m from Haris and it has easy to read code
for how to get some common ASBDs, and how to initialize the AudioBufferlist
that you will need for doing the offline render. It's definitely worth a
study, especially if your having trouble finding examples online.
Here I do the AudioBufferList setup and then thirty renders of 1024 frames
of stereo float data:
AudioBufferList *bufferlist = malloc(sizeof(AudioBufferList) +
sizeof(AudioBuffer)); //stereo bufferlist
float *left = malloc(sizeof(float) * 1024);
float *right = malloc(sizeof(float) * 1024);
bufferlist->mBuffers[0].mData = left;
bufferlist->mBuffers[1].mData = right;
AudioTimeStamp inTimeStamp;
memset(&inTimeStamp, 0, sizeof(AudioTimeStamp));
inTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
inTimeStamp.mSampleTime = 0;
AudioUnitRenderActionFlags flag = 0;
for (int i = 0; i < 30; i++) {
bufferlist->mBuffers[0].mDataByteSize = sizeof(float) * 1024;
bufferlist->mBuffers[1].mDataByteSize = sizeof(float) * 1024;
bufferlist->mNumberBuffers = 2;
AudioUnitRender(lowPass, &flag, &inTimeStamp, 0, 1024, bufferlist);
//do something with audio here
inTimeStamp.mSampleTime += 1024;
}
On Sat, Mar 21, 2015 at 8:56 AM, Patrick J. Collins <
[email protected]> wrote:
> > But here is a stere float one anyway:
> >
> > mSampleRate 44100.000000
> > mFormatFlags kAudioFormatFlagIsFloat |
> kAudioFormatFlagIsNonInterleaved | kAudioFormatFlagIsPacked
> > mFormatID kAudioFormatLinearPCM
> > mFramesPerPacket 1
> > mBytesPerFrame 4
> > mChannelsPerFrame 2
> > mBitsPerChannel 32
> > mBytesPerPacket 4
>
> Yeah these asbds do not work on the graph, for whatever no matter what I
> do. If I put them on the output node, I get -50, and if i put them on
> the lowpass node, I get -10868...
>
> I am using audio units in another class where I do
> AudioComponentInstanceNew and AudioUnitInitialize... And I can set the
> asbd no problem, and it plays my buffer perfectly.
>
> However, as soon as the graph is involved, nothing works.
>
> Patrick J. Collins
> http://collinatorstudios.com
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com
This email sent to [email protected]