Question

I am trying to compare two .caf files on the basis of some parameter, say maximum decibels or duration of files. I have recorded these two files using the AVAudioRecorder class using the following settings:

NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
    [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
    [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];

Thanks for the help!

Was it helpful?

Solution

To get duration of files you following code:

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError* error;
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:filePath error&error];

NSInteger duration = fileAttributes.fileAttributes / sampleRare / numberOfChannels / bytesPerSample;

To get maximum decibels you'll have to analyze content of file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top