Skip to content

Commit 52b590d

Browse files
tonychanchenoldcodefarmer
authored andcommitted
优化soundtouch pitch参数
Change-Id: I179020a921ef7a45f3f3ab892ce0e627aca2f202 (cherry picked from commit 6aac7cb)
1 parent fbb9538 commit 52b590d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Source/SDK/LinkVideo/FLV/TIoTAVCaptionFLV.mm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
323335
static 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

Comments
 (0)