sonic_lite.c
void sonicFlushStream(void) {
  int maxRequired = 2 * SONIC_MAX_PERIOD;
  int remainingSamples = sonicStream.numInputSamples;
  float speed = sonicStream.speed;
  int expectedOutputSamples = sonicStream.numOutputSamples + (int)((remainingSamples / speed) + 0.5f);

  memset(sonicStream.inputBuffer + remainingSamples, 0,
      sizeof(short) * (SONIC_INPUT_BUFFER_SIZE - remainingSamples));
  sonicStream.numInputSamples += 2 * maxRequired;
  sonicWriteShortToStream(NULL, 0);
  /* Throw away any extra samples we generated due to the silence we added */
  if (sonicStream.numOutputSamples > expectedOutputSamples) {
    sonicStream.numOutputSamples = expectedOutputSamples;
  }
  /* Empty input buffer */
  sonicStream.numInputSamples = 0;
  sonicStream.remainingInputToCopy = 0;
}
/* Force the sonic stream to generate output using whatever data it currently
   has.  No extra delay will be added to the output, but flushing in the middle
   of words could introduce distortion. */
Force the sonic stream to generate output using whatever data it currently
has.  No extra delay will be added to the output, but flushing in the middle
of words could introduce distortion.
Force the sonic stream to generate output using whatever data it currently has . No extra delay will be added to the output but flushing in the middle of words could introduce distortion .
void sonicFlushStream(void) {
  int maxRequired = 2 * SONIC_MAX_PERIOD;
  int remainingSamples = sonicStream.numInputSamples;
  float speed = sonicStream.speed;
  int expectedOutputSamples = sonicStream.numOutputSamples + (int)((remainingSamples / speed) + 0.5f);
  memset(sonicStream.inputBuffer + remainingSamples, 0,
      sizeof(short) * (SONIC_INPUT_BUFFER_SIZE - remainingSamples));
  sonicStream.numInputSamples += 2 * maxRequired;
  sonicWriteShortToStream(NULL, 0);
  if (sonicStream.numOutputSamples > expectedOutputSamples) {
    sonicStream.numOutputSamples = expectedOutputSamples;
  }
  sonicStream.numInputSamples = 0;
  sonicStream.remainingInputToCopy = 0;
}
void sonicFlushStream ( void ) { int maxRequired = 2 * SONIC_MAX_PERIOD ; int remainingSamples = sonicStream . numInputSamples ; float speed = sonicStream . speed ; int expectedOutputSamples = sonicStream . numOutputSamples + ( int ) ( ( remainingSamples / speed ) + 0.5f ) ; memset ( sonicStream . inputBuffer + remainingSamples , 0 , sizeof ( short ) * ( SONIC_INPUT_BUFFER_SIZE - remainingSamples ) ) ; sonicStream . numInputSamples += 2 * maxRequired ; sonicWriteShortToStream ( NULL , 0 ) ; if ( sonicStream . numOutputSamples > expectedOutputSamples ) { sonicStream . numOutputSamples = expectedOutputSamples ; } sonicStream . numInputSamples = 0 ; sonicStream . remainingInputToCopy = 0 ; }
Force the sonic stream to generate output using whatever data it currently
has.
Force the sonic stream to generate output using whatever data it currently has .
/* Throw away any extra samples we generated due to the silence we added */ /* Empty input buffer */