【问题标题】:how to change the pitch of recorded audio getting me following error如何更改录制音频的音高让我跟随错误
【发布时间】:2016-12-02 17:02:40
【问题描述】:

由于未捕获的异常“com.apple.coreaudio.avfaudio”而终止应用程序,原因:“所需条件为假:节点!= nil”

AVAudioFile *file=[[AVAudioFile alloc] initForReading:_recordedvoice error:nil];
AVAudioFormat *format=file.processingFormat;
AVAudioFrameCount capacity= (AVAudioFrameCount)file.length;
AVAudioPCMBuffer *buffer=[[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:capacity];
[file readIntoBuffer:buffer error:nil];
[playerNode scheduleBuffer:buffer completionHandler:nil];

engine = [[AVAudioEngine alloc] init];
    playerNode = [[AVAudioPlayerNode alloc] init];

[engine attachNode: playerNode];

AVAudioMixerNode *mixer = engine.mainMixerNode;
AVAudioUnitTimePitch *auTimePitch;
auTimePitch.pitch=1200.0;// In cents. The default value is 1.0. The range of values is -2400 to 2400
auTimePitch.rate = 2.0; //The default value is 1.0. The range of supported values is 1/32 to 32.0.

//get the error in the following line

[engine attachNode: auTimePitch];
[engine connect:playerNode to:auTimePitch format:[mixer outputFormatForBus:0]];
[engine connect:playerNode to:mixer format:[mixer outputFormatForBus:0]];

[playerNode play];

【问题讨论】:

标签: objective-c avaudiorecorder pitch-shifting avaudiofile


【解决方案1】:

在调用 play 之前先尝试启动引擎:

[self.engine startAndReturnError:nil];
[playerNode play];

【讨论】:

  • 如何保存这个音高改变的音频?
猜你喜欢
  • 2015-08-15
  • 1970-01-01
  • 1970-01-01
  • 2013-09-30
  • 1970-01-01
  • 2012-06-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多