2016-07-28 60 views
1

終止應用程序由於未捕獲的異常「com.apple.coreaudio.avfaudio」,理由是:「要求的條件是假的!節點=零」如何更改錄製音頻的音調讓我下面的錯誤

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]; 
+0

可能是完成處理程序的一些內容。看看這個堆棧溢出的答案 - http://stackoverflow.com/a/29630124/5716449 – Ro4ch

+0

即時消息全新的目標ci想要將錄製的聲音變成不同的聲音,如女童等你能幫我... –

+0

檢查這個問題出來了。 http://stackoverflow.com/questions/1100495/real-time-pitch-shifting-on-the-iphone這應該可以幫助你完成任務。 – Ro4ch

回答

0

在打電話前先嚐試啓動引擎:

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

如何保存這個音高改變了音頻? –