sonic_lite.c
static void changeSpeed(float speed) {
  short *samples;
  int numSamples = sonicStream.numInputSamples;
  int position = 0, period, newSamples;
  int maxRequired = 2 * SONIC_MAX_PERIOD;

  /* printf("Changing speed to %f\n", speed); */
  if (sonicStream.numInputSamples < maxRequired) {
    return;
  }
  do {
    if (sonicStream.remainingInputToCopy > 0) {
      newSamples = copyInputToOutput(position);
      position += newSamples;
    } else {
      samples = sonicStream.inputBuffer + position;
      period = findPitchPeriod(samples, 1);
      newSamples = skipPitchPeriod(samples, speed, period);
      position += period + newSamples;
    }
  } while (position + maxRequired <= numSamples);
  removeInputSamples(position);
}
/* Resample as many pitch periods as we have buffered on the input. */
Resample as many pitch periods as we have buffered on the input.
Resample as many pitch periods as we have buffered on the input .
static void changeSpeed(float speed) {
  short *samples;
  int numSamples = sonicStream.numInputSamples;
  int position = 0, period, newSamples;
  int maxRequired = 2 * SONIC_MAX_PERIOD;
  if (sonicStream.numInputSamples < maxRequired) {
    return;
  }
  do {
    if (sonicStream.remainingInputToCopy > 0) {
      newSamples = copyInputToOutput(position);
      position += newSamples;
    } else {
      samples = sonicStream.inputBuffer + position;
      period = findPitchPeriod(samples, 1);
      newSamples = skipPitchPeriod(samples, speed, period);
      position += period + newSamples;
    }
  } while (position + maxRequired <= numSamples);
  removeInputSamples(position);
}
static void changeSpeed ( float speed ) { short * samples ; int numSamples = sonicStream . numInputSamples ; int position = 0 , period , newSamples ; int maxRequired = 2 * SONIC_MAX_PERIOD ; if ( sonicStream . numInputSamples < maxRequired ) { return ; } do { if ( sonicStream . remainingInputToCopy > 0 ) { newSamples = copyInputToOutput ( position ) ; position += newSamples ; } else { samples = sonicStream . inputBuffer + position ; period = findPitchPeriod ( samples , 1 ) ; newSamples = skipPitchPeriod ( samples , speed , period ) ; position += period + newSamples ; } } while ( position + maxRequired <= numSamples ) ; removeInputSamples ( position ) ; }
Resample as many pitch periods as we have buffered on the input.
Resample as many pitch periods as we have buffered on the input .
/* printf("Changing speed to %f\n", speed); */