objective c - how to change the pitch of recorded audio getting me following error -
terminating app due uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition false: node != 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. default value 1.0. range of values -2400 2400 autimepitch.rate = 2.0; //the default value 1.0. range of supported values 1/32 32.0. //get error in 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];
try starting engine first before calling play:
[self.engine startandreturnerror:nil]; [playernode play];
Comments
Post a Comment