Setting rate on AudioUnit subtype kAudioUnitSubType
 I'm trying to get/set the rate of an AudioUnit with subtype kAudioUnitSubType_NewTimePitch .  
 The audio unit is added to an AUGraph , through an AUNode , which has the following component description:  
acd->componentType = kAudioUnitType_Effect;
acd->componentSubType = kAudioUnitSubType_NewTimePitch;
acd->componentManufacturer = kAudioUnitManufacturer_Apple;
 According to AudioUnitParameters.h , get/set the rate should be as simple as get/set the rate parameter on the audio unit.  
// rate control.
// Global, rate, 1/32 -> 32.0, 1.0
kNewTimePitchParam_Rate                         = 0,
 However, while setting the value seems no problem (no error is returned) getting the value yields a OSStatus with value -10878 (kAudioUnitErr_InvalidParameter) .  
Here is how I set the value :
- (void)setTempo:(float)value {
    OSStatus err = noErr;
    err = AudioUnitSetParameter(tempoUnit, kNewTimePitchParam_Rate, kAudioUnitScope_Global, 0, (Float32)value, 0);
    if (err != noErr) {
        NSLog(@"Could not set tempo unit rate: %d", err);
    } // no error
}
and how I (try to) get it :
- (float)tempo {
    OSStatus err = noErr;
    Float32 value = 1.0;
    err = AudioUnitGetParameter(tempoUnit, kNewTimePitchParam_Rate, kAudioUnitScope_Global, 0, &value);
    if (err != noErr) {  // -10878
        NSLog(@"Could not get tempo unit rate: %d", err);
    }
    return value;
}
The input of the node is connected to a mixer node, and the output to the RemoteIO unit.
Any ideas ?
It turns out the type of the Audio Unit was wrong.
 I changed for kAudioUnitType_FormatConverter for the type and kept the same subtype.  
Both get/set the tempo now works as expected.
I'm still unclear about why I didn't get any error, neither on setting up the audio unit, nor when setting the value for the rate.
链接地址: http://www.djcxy.com/p/62316.html