Re: Audio Unit level metering oniPhone
Re: Audio Unit level metering oniPhone
- Subject: Re: Audio Unit level metering oniPhone
- From: William Stewart <email@hidden>
- Date: Mon, 20 Apr 2009 12:24:43 -0700
On Apr 19, 2009, at 10:19 AM, Andrew Nalband wrote:
I'm extremely new to programming so forgive me for the simple
concepts I am obviously missing here. I'm attempting to monitor the
input level of the iPhone's mic and use it to trigger a an OpenGL
visual effect and audio event when the mic level is hot.
I've been reading through this code which connects
RemoteIO-->MultliChannelMixer -->RemoteIO: http://pastie.org/445149
I believe I can monitor the level with:
kMultiChannelMixerParam_PreAveragePower on the Multichannel mixer.
I'm using this code to enable metering:
UInt32 meteringMode = 1; AudioUnitSetProperty(mixerUnit,
kAudioUnitProperty_MeteringMode, kAudioUnitScope_Input, 0,
&meteringMode, sizeof(meteringMode) );
I'm then attempting to use an NSTimer to regularly fire code that
monitors the input level:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.50
target:self
selector: @selector (updateAudioLevels)
userInfo: nil
repeats:YES]; self.vibrationTimer = timer;
This is the method I'm calling as the selector:
-(void) updateAudioLevels {
OSStatus err;
float amps[1];
err = AudioUnitGetParameter(mixerUnit,
kMultiChannelMixerParam_PreAveragePower, kAudioUnitScope_Input, 0,
&s[0]);
NSLog("%f", amps[0]);
}
I'm getting some errors here since this method doesn't know about
the mixerUnit.
You are pretty right here so far.
As long as the mixer unit is in the signal chain and is getting audio
You should *always* check the result code - your set property to
enable metering just assumes that that works.
You don't describe what errors you get back from the GetParameter call
I've been reading through Technical Note TN2104 and wondering if I
should be using the AudioUnitEvent api.
wrong path - it isn't going to help you here
Can I call an Objective-C method if
kMultiChannelMixerParam_PreAveragePower crosses a certain
threshold? Am I way off here? Is there a better way to do this?
If I'm clearly missing something - can anyone recommend some
documentation to read?
Not sure I understand the question.
The ultimate goal is low latency monitoring of the mic input level.
Bill
_______________________________________________
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