如何使用音高值保存/导出音频文件?

时间:2017-02-02 11:12:49

标签: ios objective-c iphone audio

我录制了一个音频文件,在更改其音高值后,我想用新的音频文件保存它,我该怎么做?

当用户确定音高值正确时,我想保存音频。

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...?????
}

0 个答案:

没有答案