How can i compare two audio files on the basis of certain parameter say maximum decibel?
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!
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.
精彩评论