How to use kAudioUnitSubType_LowShelfFilter of kAu

2019-03-15 23:26发布

问题:

i'm back with one more question related to BASS. I already had posted this question How Can we control bass of music in iPhone, but not get as much attention of your people as it should get. But now I have done some more search and had read the Core AUDIO. I got one sample code which i want to share with you people here is the link to download it iPhoneMixerEqGraphTest. Have a look on it in this code what i had seen is the developer had use preset Equalizer given by iPod in Apple. Lets see some code snippet too:----

// iPodEQ unit
CAComponentDescription eq_desc(kAudioUnitType_Effect, kAudioUnitSubType_AUiPodEQ, kAudioUnitManufacturer_Apple);

What kAudioUnitSubType_AUiPodEQ does is it get preset values from iPod's equalizer and return us in Xcode in an array which we can use in PickerView/TableView and can set any category like bass, rock, Dance etc. It is helpless for me as it only returns names of equalizer types like bass, rock, Dance etc. as i want to implement bass only and want to implement it on UISLider.

To implement Bass on slider i need values so that i can set minimum and maximum value so that on moving slider bass can be changed.

After getting all this i start reading Core Audio's Audio Unit framework's classes and got this after that i start searching for bass control and got this

So now i need to implement this kAudioUnitSubType_LowShelfFilter. But now i don't know how to implement this enum in my code so that i can control the bass as written documentation. Even Apple had not write that how can we use it. kAudioUnitSubType_AUiPodEQ this category was returning us an array but kAudioUnitSubType_LowShelfFilter category is not returning any array. While using kAudioUnitSubType_AUiPodEQ this category we can use types of equalizer from an array but how can we use this category kAudioUnitSubType_LowShelfFilter. Can anybody help me regarding this in any manner? It would be highly appreciable.

Thanks.

回答1:

Update

Although it's declared in the iOS headers, the Low Shelf AU is not actually available on iOS.


The parameters of the Low Shelf are different from the iPod EQ.

Parameters are declared and documented in `AudioUnit/AudioUnitParameters.h':

// Parameters for the AULowShelfFilter unit
enum {
  // Global, Hz, 10->200, 80
  kAULowShelfParam_CutoffFrequency = 0,

  // Global, dB, -40->40, 0
  kAULowShelfParam_Gain = 1
};

So after your low shelf AU is created, configure its parameters using AudioUnitSetParameter.

Some initial parameter values you can try would be 120 Hz (kAULowShelfParam_CutoffFrequency) and +6 dB (kAULowShelfParam_Gain) -- assuming your system reproduces bass well, your low frequency content should be twice as loud.


Can u tell me how can i use this kAULowShelfParam_CutoffFrequency to change the frequency.

If everything is configured right, this should be all that is needed:

assert(lowShelfAU);
const float frequencyInHz = 120.0f;
OSStatus result = AudioUnitSetParameter(lowShelfAU,
                                        kAULowShelfParam_CutoffFrequency,
                                        kAudioUnitScope_Global,
                                        0,
                                        frequencyInHz,
                                        0);
if (noErr != result) {
  assert(0 && "error!");
  return ...;
}