Audio Unit level metering oniPhone
Audio Unit level metering oniPhone
- Subject: Audio Unit level metering oniPhone
- From: Andrew Nalband <email@hidden>
- Date: Sun, 19 Apr 2009 13:19:52 -0400
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.
I've been reading through Technical Note TN2104 and wondering if I
should be using the AudioUnitEvent api.
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?
The ultimate goal is low latency monitoring of the mic input level.
-Andrew
_______________________________________________
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