• 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: AudioUnitScheduleParameters with kStereoMixerParam_Volume
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioUnitScheduleParameters with kStereoMixerParam_Volume


  • Subject: Re: AudioUnitScheduleParameters with kStereoMixerParam_Volume
  • From: Matt Grippaldi <email@hidden>
  • Date: Fri, 22 Jul 2016 18:22:24 -0400

I’m not an expert, but I think this method is not as “automagic" as you and I both assumed.  I believe what you are really scheduling is sample accurate ramping of a parameter change that should be done in a render notification callback.  You are responsible for keeping track of the incremental parameter values across frames.

So you need to add a render notification callback:
AudioUnitAddRenderNotify(mixerUnit, MixerRenderProc, &mixerUnit/* Or whatever you need */);

And the parameter event like this (for example):

AudioUnitParameterEvent parameterEvent = {
    .scope = parameter.mScope,
    .element = parameter.mElement,
    .parameter = parameter.mParameterID,
    .eventType = kParameterEvent_Ramped,
    .eventValues.ramp.startBufferOffset = 0,
    .eventValues.ramp.durationInFrames = 0,
    .eventValues.ramp.startValue = 0.0,
    .eventValues.ramp.endValue = 0.01
};

And this callback that would continually ramp from from a volume of 0.0 to 1.0:

OSStatus MixerRenderProc(void* inRefCon,
                         AudioUnitRenderActionFlags* ioActionFlags,
                         const AudioTimeStamp* inTimeStamp,
                         UInt32 inBusNumber,
                         UInt32 inNumberFrames,
                         AudioBufferList* ioData)
{
    AudioUnit* mixerUnit = (AudioUnit*)inRefCon;
    
    if ((*ioActionFlags & kAudioUnitRenderAction_PreRender) == kAudioUnitRenderAction_PreRender)
    {
        parameterEvent.eventValues.ramp.startBufferOffset = 0;
        parameterEvent.eventValues.ramp.durationInFrames = inNumberFrames; 
        CheckError(AudioUnitScheduleParameters(*mixerUnit, &parameterEvent, 1),
                   "ramped volume parameter could not be scheduled");
        if (parameterEvent.eventValues.ramp.endValue >= 1.0)
        {
            parameterEvent.eventValues.ramp.startValue = 0.0;
            parameterEvent.eventValues.ramp.endValue = 0.01;
        }
        else
        {
            parameterEvent.eventValues.ramp.startValue += 0.01;
            parameterEvent.eventValues.ramp.endValue += 0.01;
        }
   }
    return noErr;
}
   
If this is not how this is intended to work I hope someone else answers, because I would also like to better understand.
- Matt Grippaldi

 _______________________________________________
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

References: 
 >AudioUnitScheduleParameters with kStereoMixerParam_Volume (From: Benjamin Federer <email@hidden>)

  • Prev by Date: Re: AudioUnitScheduleParameters with kStereoMixerParam_Volume
  • Next by Date: AUv3 for Mac Code Signing
  • Previous by thread: AudioUnitScheduleParameters with kStereoMixerParam_Volume
  • Next by thread: AudioUnitScheduleParameters with kStereoMixerParam_Volume
  • Index(es):
    • Date
    • Thread