我录制了一个音频文件,在更改其音高值后,我想用新的音频文件保存它,我该怎么做?
当用户确定音高值正确时,我想保存音频。
AVAudioUnitTimePitch *_auTimePitch;
AVAudioFormat *audioFormat;
int rec_time;
- (void)onSliderValChanged:(UISlider*)slider forEvent:(UIEvent*)event {
_auTimePitch.pitch=(int)sliderVal;
}
- (void)setupAudio{
_playerNode = [[AVAudioPlayerNode alloc] init];
_engine = [[AVAudioEngine alloc] init];
_auTimePitch.pitch=pitchValue;
NSString *soundFilePath =self.recorderFilePath;
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
if (audioFile==nil) {
audioFile=[[AVAudioFile alloc] initForReading:soundFileURL error:nil];
audioFormat=audioFile.processingFormat;
}
AVAudioTime *startTime=[AVAudioTime timeWithHostTime:rec_time];
[_engine attachNode: _playerNode];
[_engine attachNode: _auTimePitch];
NSLog(@"%d",rec_time);
[_engine connect:_playerNode to:_auTimePitch format:audioFormat];
[_engine connect:_auTimePitch to:_engine.outputNode format:audioFormat];
[_playerNode scheduleFile:audioFile atTime:nil completionHandler:nil];
[_engine startAndReturnError:nil];
[_playerNode playAtTime:startTime];
}
-(void)tapSave {
//on save...?????
}