• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Fwd: still super duper frustrated about the au graph..
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: still super duper frustrated about the au graph..


  • Subject: Re: Fwd: still super duper frustrated about the au graph..
  • From: "Dave O'Neill" <email@hidden>
  • Date: Sat, 21 Mar 2015 15:47:00 -0700

I don't think that you can call AudioUnitRender on the ioUnit, but I don't know that for sure.  If you are going to do an offline render just leave it out and call AudioUnitRender on the next unit up the chain.  sourceOutputNumber will be 0 unless the source unit is the ioUnit then it will be 1 for the microphone. inDestInputNumber will be 0 unless your destination unit can take multiple channels like a mixer.

On Sat, Mar 21, 2015 at 3:31 PM, Patrick J. Collins <email@hidden> wrote:
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

 _______________________________________________
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

  • Follow-Ups:
    • Re: Fwd: still super duper frustrated about the au graph..
      • From: "Patrick J. Collins" <email@hidden>
References: 
 >Re: Fwd: still super duper frustrated about the au graph.. (From: "Patrick J. Collins" <email@hidden>)

  • Prev by Date: Re: Fwd: still super duper frustrated about the au graph..
  • Next by Date: Re: Fwd: still super duper frustrated about the au graph..
  • Previous by thread: Re: Fwd: still super duper frustrated about the au graph..
  • Next by thread: Re: Fwd: still super duper frustrated about the au graph..
  • Index(es):
    • Date
    • Thread