title: Real time pitch shift using Superpowered Android
body: <p>I am having problem in using the Superpowered time stretching function for real time pitch shift.</p>
  
  <p>I have used <a href="https://stackoverflow.com/questions/46889430/superpowered-real-time-pitch-shift-with-timestretcher-not-working">this solution</a> 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.</p>
  
  <p>Here's the relevant code--</p>
  
  <pre><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; // &lt;-- 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-&gt;process(&amp;inputBuffer, outputBuffers);
  
          // Do we have some output?
          if (outputBuffers-&gt;makeSlice(0, outputBuffers-&gt;sampleLength)) {
  
              while (true) { // Iterate on every output slice.
                  // Get pointer to the output samples.
  
                  int _numSamples = 0;
                  float *timeStretchedAudio = (float *)outputBuffers-&gt;nextSliceItem(&amp;_numSamples);
                  if (!timeStretchedAudio) break;
  
                  SuperpoweredFloatToShortInt(timeStretchedAudio, audioInputOutput,
                                              (unsigned int) numberOfSamples);
  
              };
  
              // Clear the output buffer list.
              outputBuffers-&gt;clear();
          }
  
          return true;
      }
  </code></pre>
  
  <p>This is the audio processing function of the SuperpoweredAndroidAudioIO. I have defined the <code>timeStretch</code> in the initializing function.I am stuck at this point and need some help...</p>
  
  <p>Thanks.</p>