Saturday, August 29, 2009

iPhone: Voice Mill

Yesterday I've played a bit with AVAudioRecorder, and this is a very small and funny example.
The main Idea is to create something like a wind mill that works with voice instead of wind.

The code below shows you how to record something. Then with the updateMeters() and peakPowerForChannel() you can extract the audio "noise".


NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:44100.0], AVSampleRateKey,
[NSNumber numberWithInt:kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt:1], AVNumberOfChannelsKey,
[NSNumber numberWithInt:AVAudioQualityLow], AVEncoderAudioQualityKey,
nil];

NSError *error;
recorder = [[AVAudioRecorder alloc] initWithURL:url 
settings:settings error:&error];
if (recorder) {
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
[recorder record];
...
}


The SWF Video is available here Voice Mill Video.
The Source Code is available here Cocoa Voice Mill Source Code.

No comments:

Post a Comment