文件名称:简单TOM猫学说话
文件大小:497KB
文件格式:ZIP
更新时间:2016-06-13 05:02:59
TOM
简单实现TOM猫学说话 - (void)record { if ([self canRecord]) { NSError *error; NSMutableDictionary *_recordSetting = [[NSMutableDictionary alloc] init]; [_recordSetting setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; [_recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [_recordSetting setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; [_recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityMax] forKey:AVEncoderAudioQualityKey]; //_recorderTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithString:@"recording.caf"]]]; //[_recorderTmpFile retain]; if (_recorder == NULL) { _recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:audioPath] settings:_recordSetting error:&error]; }else { [_recorder release]; _recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:audioPath] settings:_recordSetting error:&error]; } [_recorder setMeteringEnabled:YES]; [_recorder setDelegate:self]; [_recorder prepareToRecord]; // [_recorder record]; // NSLog(@"录制中~~~~~~~~~~~~~!!!!"); [_recordSetting release]; }else { NSLog(@"不能录制!!!!"); } } - (void)updateMeters:(NSTimer *)sender { //NSLog(@"~~~~~~~~~~~~~~~~~监听中!!!~~~~~"); //NSLog(@"AVG = %f;peak = %f", [[SCListener sharedListener] averagePower], [[SCListener sharedListener] peakPower]); if ([[SCListener sharedListener] averagePower] > 0.1) { if (!ISRECORDED) { if (!isRecording) { NSLog(@"1开始录制"); isRecording = YES; ISRECORDED = YES; //记录是否录音过声音 _playTimes = 0; //[self record]; [_recorder prepareToRecord]; [_recorder record]; } }else { if (!isPlaying) { if (!isRecording) { NSLog(@"2开始录制"); isRecording = YES; _playTimes = 0; [_recorder prepareToRecord]; [_recorder record]; //[self record]; } } } } if ([[SCListener sharedListener] averagePower] < 0.1) { _lowTimes++; if (_lowTimes >= 5) { //5 次 0.5s======= _lowTimes = 0; isRecording = NO; if (!isRecording & !isPlaying) { if (ISRECORDED) { if (_playTimes < 1) { _playTimes++; NSLog(@"停止录制内容"); [self stopRecord]; isPlaying = YES; } } } } } }
【文件预览】:
usworldpro
----.DS_Store(6KB)
----Classes()
--------EAFWrite.mm(13KB)
--------SCListener.h(626B)
--------EAFRead.h(1KB)
--------SCListener.m(4KB)
--------EAFWrite.h(1KB)
--------usworldproViewController.h(993B)
--------usworldproAppDelegate.m(3KB)
--------usworldproViewController.mm(11KB)
--------libDIRAC_iOS4-fat.a(1.13MB)
--------soundtouch()
--------usworldproAppDelegate.h(489B)
--------Dirac.h(7KB)
--------EAFRead.mm(11KB)
----usworldpro.xcodeproj()
--------shijianlong.mode1v3(39KB)
--------project.xcworkspace()
--------shijianlong.pbxuser(4KB)
--------xcuserdata()
--------guo2000tt.pbxuser(8KB)
--------project.pbxproj(16KB)
--------guo2000tt.mode1v3(39KB)
----main.m(362B)
----usworldpro_Prefix.pch(189B)
----MainWindow.xib(20KB)
----usworldpro-Info.plist(897B)
----build()
--------.DS_Store(6KB)
----usworldproViewController.xib(7KB)