Best setting for record sound
What's the best settings for the recorder for recording voice? What should i replace with '?' in below code?
recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:?] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:?] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: ?] forKey:AVNumberOfChannelsKey];
[recordSetting setValue :[NSNumber nu开发者_Go百科mberWithInt:?] forKey:AVLinearPCMBitDepthKey];
[recordSetting setValue :[NSNumber numberWithBool:?] forKey:AVLinearPCMIsBigEndianKey];
[recordSetting setValue :[NSNumber numberWithBool:?] forKey:AVLinearPCMIsFloatKey];
this should be a fine starting point for speech, considering the hardware (since this is tagged 'iphone', i am assuming that is the source).
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:12000.0f] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt:1 /* mono */ ] forKey:AVNumberOfChannelsKey];
[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSetting setValue:[NSNumber numberWithBool:NX_BigEndian == NXHostByteOrder()] forKey:AVLinearPCMIsBigEndianKey];
[recordSetting setValue:[NSNumber numberWithBool:0] forKey:AVLinearPCMIsFloatKey];
if you want to reduce the size of the file, then you may prefer to record at a higher quality, then convert to a compressed format following record.
if you have long recordings to make, then you may want to record to a compressed format (i'd avoid it otherwise because the resource demands are higher).
as it is, these may not be the best for a specific application, but a good balance between size, speed, and quality.
精彩评论