mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
Fix interpolation for rate/pitch adjustment
Based on https://github.com/waywardgeek/sonic/commit/7b441933. Issue: #2774 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=155349817
This commit is contained in:
parent
4b5c521a33
commit
631cce9171
1 changed files with 3 additions and 3 deletions
|
|
@ -374,8 +374,8 @@ import java.util.Arrays;
|
|||
}
|
||||
|
||||
private short interpolate(short[] in, int inPos, int oldSampleRate, int newSampleRate) {
|
||||
short left = in[inPos * numChannels];
|
||||
short right = in[inPos * numChannels + numChannels];
|
||||
short left = in[inPos];
|
||||
short right = in[inPos + numChannels];
|
||||
int position = newRatePosition * oldSampleRate;
|
||||
int leftPosition = oldRatePosition * newSampleRate;
|
||||
int rightPosition = (oldRatePosition + 1) * newSampleRate;
|
||||
|
|
@ -402,7 +402,7 @@ import java.util.Arrays;
|
|||
enlargeOutputBufferIfNeeded(1);
|
||||
for (int i = 0; i < numChannels; i++) {
|
||||
outputBuffer[numOutputSamples * numChannels + i] =
|
||||
interpolate(pitchBuffer, position + i, oldSampleRate, newSampleRate);
|
||||
interpolate(pitchBuffer, position * numChannels + i, oldSampleRate, newSampleRate);
|
||||
}
|
||||
newRatePosition++;
|
||||
numOutputSamples++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue