Skip to content

Commit

Permalink
Fix interpolation for rate/pitch adjustment
Browse files Browse the repository at this point in the history
Based on waywardgeek/sonic@7b441933.

Issue: #2774

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155349817
  • Loading branch information
andrewlewis authored and ojw28 committed May 11, 2017
1 parent 2d2fcf1 commit 963b7cb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ private void adjustPitch(int originalNumOutputSamples) {
}

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;
Expand All @@ -402,7 +402,7 @@ private void adjustRate(float rate, int originalNumOutputSamples) {
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++;
Expand Down

0 comments on commit 963b7cb

Please sign in to comment.