开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜