public void ShiftPitch(float[] inputBuff, float inputPitch, float targetPitch, float[] outputBuff, int nFrames) { UpdateSettings(); detectedPitch = inputPitch; float shiftFactor = 1.0f; if (this.settings.SnapMode) { if (inputPitch > 0) { shiftFactor = snapFactor(inputPitch); shiftFactor += addVibrato(nFrames); } } else { float midiPitch = targetPitch; shiftFactor = 1.0f; if (inputPitch > 0 && midiPitch > 0) { shiftFactor = midiPitch / inputPitch; } } if (shiftFactor > 2.0) { shiftFactor = 2.0f; } if (shiftFactor < 0.5) { shiftFactor = 0.5f; } // fftFrameSize was nFrames but can't guarantee it is a power of 2 // 2048 works, let's try 1024 int fftFrameSize = 2048; int osamp = 8; // 32 is best quality SmbPitchShift.smbPitchShift(shiftFactor, nFrames, fftFrameSize, osamp, this.sampleRate, inputBuff, outputBuff); //vibrato //addVibrato(outputBuff, nFrames); shiftedPitch = inputPitch * shiftFactor; updateShifts(detectedPitch, shiftedPitch, this.currPitch); }