Re: Fwd: still super duper frustrated about the au graph..
Re: Fwd: still super duper frustrated about the au graph..
- Subject: Re: Fwd: still super duper frustrated about the au graph..
- From: "Patrick J. Collins" <email@hidden>
- Date: Sat, 21 Mar 2015 15:31:03 -0700 (PDT)
Ok-- so I tried the approach suggested and my callback is not firing... I
suspect I am doing something wrong with the kAudioUnitProperty_MakeConnection,
as I am a bit confused about sourceOutputNumber and the
destinationOutputNumber... I couldn't find any examples online of how to do
this.
-(void)makeAudioUnitConnections {
AudioComponentDescription outputcd = {0};
outputcd.componentType = kAudioUnitType_Output;
outputcd.componentSubType = kAudioUnitSubType_GenericOutput;
outputcd.componentManufacturer = kAudioUnitManufacturer_Apple;
AudioComponent comp = AudioComponentFindNext(NULL, &outputcd);
if (comp == NULL) NSLog(@"can't get output unit");
AudioComponentInstanceNew(comp, &player.outputUnit);
AudioComponentDescription lowpasscd = {0};
lowpasscd.componentType = kAudioUnitType_Effect;
lowpasscd.componentSubType = kAudioUnitSubType_LowPassFilter;
lowpasscd.componentManufacturer = kAudioUnitManufacturer_Apple;
comp = AudioComponentFindNext(NULL, &lowpasscd);
if (comp == NULL) NSLog(@"can't get lowpass unit");
AudioComponentInstanceNew(comp, &player.lowPassAU);
AURenderCallbackStruct input;
input.inputProc = EffectMachineCallbackRenderProc;
input.inputProcRefCon = &player;
CheckError(AudioUnitSetProperty(player.lowPassAU,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input,
0,
&input,
sizeof(input)),
"AudioUnitSetProperty for callback failed");
CheckError(AudioUnitSetParameter(player.lowPassAU,
kLowPassParam_CutoffFrequency,
kAudioUnitScope_Global,
0,
800,
0), "AudioUnitSetParameter for lowpass failed");
AudioUnitElement bus0 = 0;
AudioUnitElement bus1 = 1;
AudioUnitConnection outToLowPass;
outToLowPass.sourceAudioUnit = player.lowPassAU;
outToLowPass.sourceOutputNumber = bus1;
outToLowPass.destInputNumber = bus0;
AudioUnitSetProperty (
player.outputUnit,
kAudioUnitProperty_MakeConnection,
kAudioUnitScope_Input,
bus0,
&outToLowPass,
sizeof(outToLowPass)
);
CheckError(AudioUnitInitialize(player.outputUnit),
"Couldn't initialize output unit");
CheckError(AudioUnitInitialize(player.lowPassAU),
"Couldn't initialize lowpass unit");
AudioBufferList *bufferlist = malloc(sizeof(AudioBufferList));
UInt32 blockSize = 1024;
float *buffer = malloc(sizeof(float) * blockSize);
bufferlist->mBuffers[0].mData = buffer;
AudioTimeStamp inTimeStamp;
memset(&inTimeStamp, 0, sizeof(AudioTimeStamp));
inTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
inTimeStamp.mSampleTime = 0;
AudioUnitRenderActionFlags flag = 0;
NSUInteger length = ceil(self.buffer.size / (float)blockSize);
for (int i = 0; i < length; i++) {
bufferlist->mBuffers[0].mDataByteSize = sizeof(float) * blockSize;
bufferlist->mNumberBuffers = 1;
AudioUnitRender(player.outputUnit, &flag, &inTimeStamp, 0, blockSize, bufferlist);
inTimeStamp.mSampleTime += blockSize;
}
free(bufferlist);
}
Patrick J. Collins
http://collinatorstudios.com
_______________________________________________
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