• 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 an AUTimePitch unit.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioUnitScheduleParameters with an AUTimePitch unit.


  • Subject: Re: AudioUnitScheduleParameters with an AUTimePitch unit.
  • From: William Stewart <email@hidden>
  • Date: Fri, 10 Oct 2008 12:57:03 -0700

A parameter that can be ramped will be marked in a particular way:

kAudioUnitParameterFlag_CanRamp

will be set in a parameter's info struct.

You can see the settings for an AU by running auval on it:
>>>
# # # 24 Global Scope Parameters:
Parameter ID:0
Name: rate
Parameter Type: Rate
Values: Minimum = 0.250000, Default = 1.000000, Maximum = 4.000000
Flags: Display Logarithmic, High Resolution, Readable, Writable
  -parameter PASS

>>>

So, from this you can see that the time pitch's rate parameter is not ramp-able (arguably we should be returning an error here)

You can achieve the ramp by just using set parameter over a few buffer calls (the parameter itself will be de-zippered).

Bill

On Oct 10, 2008, at 7:23 AM, John Clayton wrote:

Hi All,

I'd like to ramp the playback rate of an AUTimePitch unit, I've read the docs and searched the examples + google, but still my rate change on the pitch unit doesn't seem to take effect when I call AudioUnitScheduleParameters.

I'm registering for render-notify like this:
	if(mPitchCallback || mPitchCallbackRefCon)
		XThrowIfError(AudioUnitAddRenderNotify(mPitchUnit,
					   mPitchCallback,
					   mPitchCallbackRefCon), "setting output render callback");

and in this callback, I have code like this:

- (double) rateValueForPercent:(double)pcnt {
	double rateValue = 	fabs(0.5 - pcnt);
	if(rateValue < 0.25)
		rateValue = 0.25;
	if(rateValue > 1.0)
		rateValue = 1.0;
	return rateValue;
}

notes: pcnt is the total percentage complete (always from 0 thru 1.0)

if(*ioActionFlags & kAudioUnitRenderAction_PreRender) {
// set the rate to fabs(0.5 - pcnt)
AudioUnit pitchUnit = [self pitchUnit];

AudioUnitParameterEvent inEvent;
memset(&inEvent, 0, sizeof(inEvent));

inEvent.scope = kAudioUnitScope_Output;
inEvent.element = 0;
inEvent.parameter = kTimePitchParam_Rate;
inEvent.eventType = kParameterEvent_Ramped;

// for this set of frames, what are the ramping values associated with the begin/end times?
double beginRateValue = [self rateValueForPercent:pcnt];
double endRateValue = [self rateValueForPercent:endPcnt];

inEvent.eventValues.ramp.startValue = beginRateValue;
inEvent.eventValues.ramp.endValue = endRateValue;
inEvent.eventValues.ramp.durationInFrames = inNumberFrames;
inEvent.eventValues.ramp.startBufferOffset = 0;

ComponentResult res = AudioUnitScheduleParameters(pitchUnit, &inEvent, 1);
if(res != 0)
printf("cant set up the scheduled param: %d\r\n", res);
}
}


No errors are printed to the console.

I hear audio being played back, but the pitch never changes - is the error obvious perhaps? Keen for any feedback / help, thanks.

Thanks--
John Clayton
Skype: johncclayton

_______________________________________________
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: AudioUnitScheduleParameters with an AUTimePitch unit.
      • From: John Clayton <email@hidden>
    • Re: AudioUnitScheduleParameters with an AUTimePitch unit.
      • From: John Clayton <email@hidden>
References: 
 >AudioUnitScheduleParameters with an AUTimePitch unit. (From: John Clayton <email@hidden>)

  • Prev by Date: Re: CAClock and MIDI Clock
  • Next by Date: Re: AudioUnitScheduleParameters with an AUTimePitch unit.
  • Previous by thread: AudioUnitScheduleParameters with an AUTimePitch unit.
  • Next by thread: Re: AudioUnitScheduleParameters with an AUTimePitch unit.
  • Index(es):
    • Date
    • Thread