@@ -320,6 +320,18 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
320320}
321321
322322#pragma mark - PCM XEcho record_callback
323+ void *ijk_soundtouch_handle = NULL ;
324+ - (void )setPitch : (int )pitch {
325+ _pitch = ((pitch >= -12 ) && (pitch <= 12 ))?pitch:-6 ;
326+ NSLog (@" 设置变调参数:%d <===>修正为:%d " ,pitch, _pitch);
327+ int tmpChannel = _channel;
328+
329+ if (ijk_soundtouch_handle != NULL ) {
330+ ijk_soundtouch_destroy (ijk_soundtouch_handle);
331+ }
332+ ijk_soundtouch_handle = ijk_soundtouch_create (1.0 , _pitch, tmpChannel, 16000 );
333+ }
334+
323335static void record_callback (uint8_t *buffer, int size, void *u)
324336{
325337// printf("pcm_size_callback: %d\n", size);
@@ -329,8 +341,6 @@ static void record_callback(uint8_t *buffer, int size, void *u)
329341 TIoTAVCaptionFLV *vc = (__bridge TIoTAVCaptionFLV *)(u);
330342 if (vc.pitch != 0 ) {
331343 static int tmpChannel = vc.pcmRecord .pcmStreamDescription .mChannelsPerFrame ;
332- static int pitch = ((vc.pitch >= -12 ) && (vc.pitch <= 12 ))?vc.pitch :-6 ;
333- static void *ijk_soundtouch_handle = ijk_soundtouch_create (1.0 , pitch, tmpChannel, 16000 );
334344 ret_len = ijk_soundtouch_translate (ijk_soundtouch_handle, (short *)buffer, size/2 , 2 , tmpChannel);
335345 if (ret_len<1 ) {
336346 return ;
0 commit comments