gpt4 book ai didi

iphone - 如何在 iphone 录音时设置电平表?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:43:28 25 4
gpt4 key购买 nike

为了录制声音,我使用以下代码:

- (IBAction) recordClicked:(id)sender {
NSLog(@"play Record");
if (audioPlayerRecord) {
if (audioPlayerRecord.isPlaying) [audioPlayerRecord stop];
else {
[audioPlayerRecord play];
[self updateCurrentTimeForPlayer:audioPlayerRecord];
}
return;
}

//Initialize playback audio session
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *recDir = [paths objectAtIndex:0];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/recordTest.caf", recDir]];

NSError *error;
audioPlayerRecord = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[audioPlayerRecord play];
duration.text = [NSString stringWithFormat:@"%d:%02d", (int)audioPlayerRecord.duration / 60, (int)audioPlayerRecord.duration % 60, nil];
progressBar.maximumValue = audioPlayerRecord.duration;
[self updateViewForPlayerState:audioPlayerRecord];
NSLog(@"Recoder file >");
}

录音进行时,我想显示以下类型的电平表

Level meter

那么有没有其他简化的方法来解决这个问题呢?

最佳答案

检查AQRecorder.mm ...

查找:void AQRecorder::StartRecord(CFStringRef inRecordFile)

在这里你必须评论/删除de line

url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL);

url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)recordFile, kCFURLPOSIXPathStyle, false);

关于iphone - 如何在 iphone 录音时设置电平表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14193522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com