Hello all,
I'm trying to make a simple iphone app that has two buttons: Start and Stop. When you hit start it starts listening to the phone's microphone volume and makes label show how loud you're talking into the mic. When you hit stop, it stops listening.
I found a great class called SCListener, but I'm not sure how to get it implemented. Right now i've got a button hooked up to the following code
-(IBAction)getVolume
{
SCListener *listener = [SCListener sharedListener];
[listener listen];
Float32 peakPower = [listener peakPower];
NSString *theString = [NSString stringWithFormat:@"Level is: %1.2f", peakPower];
[volumeLabel setText:theString];
}
This works perfectly well, but only gets the volume once. I've tried to do something like:
[listener addObserver:self
forKeyPath:@"peakPower"
options:NSKeyValueObservingOptionOld
context:NULL];
But since peakPower is a method not a variable I can't put an observer on it. How would I go about using a class like SCListener to set up an app that allows the user to press a button and have the label constantly update?
Thanks, JP