问题
I am playing with Apple's sample project "LoadPresetDemo". I have added the reverb audio unit AudioUnit kAudioUnitSubType_Reverb2
to the graph, which is the only iOS reverb available. In the CoreAudio header file "AudioUnitParameters.h", it states that Reverb2 should respond to these parameters:
enum {
// Global, CrossFade, 0->100, 100
kReverb2Param_DryWetMix = 0,
// Global, Decibels, -20->20, 0
kReverb2Param_Gain = 1,
// Global, Secs, 0.0001->1.0, 0.008
kReverb2Param_MinDelayTime = 2,
// Global, Secs, 0.0001->1.0, 0.050
kReverb2Param_MaxDelayTime = 3,
// Global, Secs, 0.001->20.0, 1.0
kReverb2Param_DecayTimeAt0Hz = 4,
// Global, Secs, 0.001->20.0, 0.5
kReverb2Param_DecayTimeAtNyquist = 5,
// Global, Integer, 1->1000
kReverb2Param_RandomizeReflections = 6,
};
After the AUGraph has been initialized and started, everything compiles, I hear sound.
Next, I alter the kReverb2Param_DryWetMix parameter (changing to full wet mix):
AudioUnitSetParameter(_reverbUnit, kAudioUnitScope_Global, 0, kReverb2Param_DryWetMix, 100.0f, 0);
All good, I hear sound with full wet mixed reverb.
Now hear is where I run into issues. When trying to alter any parameter other than kReverb2Param_DryWetMix
I get error code -10877
. It seems as if these other parameters listed in the header file do not actually exist.
For example, calling
AudioUnitSetParameter(_reverbUnit, kAudioUnitScope_Global, 0, kReverb2Param_DecayTimeAtNyquist, 20.0f, 0)
Throws the -10877
error.
Is this a bug? Have I omitted any audio frameworks? Have I not imported specific audio headers?
The current audio frameworks included are AVFoundation and AudioToolbox. The current audio imports are
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>
I have scoured google with no solution. I know I have problems when the Google route fails. Any help would be greatly appreciated.
Note: I tested with simulator and iPhone 4S device, same problem.
UPDATE: I have tried
AudioUnitGetParameter(_reverbUnit, kReverb2Param_DecayTimeAtNyquist, kAudioUnitScope_Global, 0, &value)
and it returns a value of 0.500000
, which means the property does exist. So what am I doing wrong in setting the value?
回答1:
Doh! I realize that I was confusing AudioUnitSetParameter
with AudioUnitSetProperty
, including their parameters. Man, subtle but evil.
来源:https://stackoverflow.com/questions/11362709/core-audio-ios-5-1-reverb2-properties-do-not-exist-error-code-10877