I am having problem in using the Superpowered time stretching function for real time pitch shift.
I have used this solution for my purpose. The problem is I am applying the change on the input buffer which is a short array and getting back noise after processing the buffer.
Here's the relevant code--
static bool audioProcessing(void * __unused clientdata, short int *audioInputOutput, int numberOfSamples, int __unused samplerate) {
SuperpoweredAudiopointerList *outputBuffers = new SuperpoweredAudiopointerList(8, 16);
// Create an input buffer for the time stretcher.
SuperpoweredAudiobufferlistElement inputBuffer;
inputBuffer.samplePosition = 0;
inputBuffer.startSample = 0;
inputBuffer.samplesUsed = 0;
inputBuffer.endSample = numberOfSamples; // <-- Important!
inputBuffer.buffers[0] = SuperpoweredAudiobufferPool::getBuffer(
(unsigned int) (numberOfSamples * 8 + 64));
inputBuffer.buffers[1] = inputBuffer.buffers[2] = inputBuffer.buffers[3] = NULL;
// Convert the decoded PCM samples from 16-bit integer to 32-bit floating point.
SuperpoweredShortIntToFloat(audioInputOutput, (float *)inputBuffer.buffers[0],
(unsigned int) numberOfSamples);
// Time stretching.
timeStretch->process(&inputBuffer, outputBuffers);
// Do we have some output?
if (outputBuffers->makeSlice(0, outputBuffers->sampleLength)) {
while (true) { // Iterate on every output slice.
// Get pointer to the output samples.
int _numSamples = 0;
float *timeStretchedAudio = (float *)outputBuffers->nextSliceItem(&_numSamples);
if (!timeStretchedAudio) break;
SuperpoweredFloatToShortInt(timeStretchedAudio, audioInputOutput,
(unsigned int) numberOfSamples);
};
// Clear the output buffer list.
outputBuffers->clear();
}
return true;
}
This is the audio processing function of the SuperpoweredAndroidAudioIO. I have defined the timeStretch
in the initializing function.I am stuck at this point and need some help...
Thanks.