0

我在使用 Superpower 时间拉伸功能进行实时音高转换时遇到问题。

我已将此解决方案用于我的目的。问题是我正在对输入缓冲区应用更改,该缓冲区是一个短数组,并在处理缓冲区后返回噪声。

这是相关的代码-

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;
    }

这是 SuperpoweredAndroidAudioIO 的音频处理功能。我已经timeStretch在初始化函数中定义了。我被困在这一点上,需要一些帮助......

谢谢。

4

1 回答 1

0

outputBuffers->makeSlice 应该询问“numberOfSamples”,而不是整个“sampleLength”。此外,当您在该迭代中将这些样本放入“audioInputOutput”时,请确保“audioInputOutput”也被步进,否则您将覆盖相同的区域(开始)。

于 2018-04-10T08:26:53.207 回答