I am developing an app for android using the native pitch shifting cpp code available here:
www.dspdimension.com/admin/pitch-shifting-using-the-ft/
the app will read wav files, change its pitch and then write back the file on the sd card. The reading wav file and write back methods are working fine, but when I apply pitch shift and then write, i get back static only i.e. the original audio is lost and just static is heard..
seems that there is se problem while passing the data from java to the cpp code
Can anyone help me with this?
the cpp code is at that link, and I have made a function in cpp to use that code:
JNIEXPORT jfloatArray JNICALL Java_com_pitch_PitchActivity_pitchShift (JNIEnv * pEnv, jobject pThis, jfloat pitchShift, jlong numSampsToProcess, jlong fftFrameSize, jlong osamp, jfloat sampleRate, jfloatArray inputdata) {
jfloat* ind,ata = pEnv->GetFloatArrayElements(inputdata,0);
float outdata[numSampsToProcess];
jfloatArray res;
res = pEnv->NewFloatArray(numSampsToProcess);
memset(outdata, 0, numSampsToProcess*sizeof(float));
smbPitchShift(pitchShift, numSampsToProcess, fftFrameSize, osamp, sampleRate, indata, outdata);
pEnv->SetFloatArrayRegion(res, 0, numSampsToProcess, outdata);
return res;
}
this code calls the smbPitchShift method of the cpp code.
from the java code i am passing the following values:
float[] parr = new float[data.length];
parr = pitchShift(0.6f, (long)data.length, (long)2048, (long) 4, (float) sampleRate, data);
here data is a float array, containing the data extracted from the wav file and it is in the range of [-1.0,1.0)