Как сохранить звук, записанный с измененной высотой звука?

Я работаю над записью голоса, затем меняю высоту звука и сохраняю. Я вызываю этот метод после записи голоса и нажимаю кнопку, чтобы изменить высоту звука, затем также создается новый файл, но не удается прослушать звук, звук генерируется без голоса, что может быть ошибкой?

-(void)saveEffectedAudioToFolder

{
NSError *error;
if (_audioEngine) {


    AVAudioUnitTimePitch *pitchEffect = [AVAudioUnitTimePitch new];



    pitchEffect.pitch = pitch;


    AVAudioFormat  * commonFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:44100 channels:2 interleaved:NO];

    //
    AVAudioFile *outputFile = [[AVAudioFile alloc] initForWriting:[NSURL URLWithString:_filePathDstaud] settings:commonFormat.settings error:&error];

    if (error) {
        NSLog(@"Error is 1 %@",[error localizedDescription]);


    }


    [pitchEffect installTapOnBus: 0 bufferSize: 8192 format: commonFormat block: ^(AVAudioPCMBuffer *buffer, AVAudioTime *when)
     //here is that error 
     {

         if (outputFile.length < _audioFile.length)
         {
             //Let us know when to stop saving the file, otherwise saving infinitely
             NSError *error;

             NSAssert([outputFile writeFromBuffer:buffer error:&error], @"error writing buffer data to file, %@", [error localizedDescription]);

         }else{
             _audioEngine = nil;
             [pitchEffect removeTapOnBus:0];//if we dont remove it, will keep on tapping infinitely
             NSLog(@"Did you like it? Please, vote up for my question");
         }

     }


     ];
}
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

NSString *filePath = [documentsPath stringByAppendingPathComponent:name];

[fileManager removeItemAtPath:filePath error:&error];

}


person Mitesh Varu    schedule 22.08.2016    source источник
comment
это частота голоса, она меняется в зависимости от человека женского пола ребенка ....и т.д.   -  person Mitesh Varu    schedule 22.08.2016