src/media/audio/lib/analysis/analysis_unittest.cc
// Local version of GenerateCosineAudio that uses doubles, the same type used by our FFT methods.
Local version of GenerateCosineAudio that uses doubles, the same type used by our FFT methods.
Local version of GenerateCosineAudio that uses doubles the same type used by our FFT methods .
void OverwriteCosine(double* buffer, uint32_t buf_size, double freq, double magn = 1.0,
                     double phase = 0.0) {
  FX_DCHECK(freq > 0.0 || (freq == 0.0 && phase == 0.0));
  FX_DCHECK(freq * 2.0 <= buf_size) << "Buffer too short--requested frequency will be aliased";
  const double mult = 2.0 * M_PI / buf_size * freq;
  for (uint32_t idx = 0; idx < buf_size; ++idx) {
    buffer[idx] = magn * std::cos(mult * idx + phase);
  }
}
void OverwriteCosine ( double * buffer , uint32_t buf_size , double freq , double magn = 1.0 , double phase = 0.0 ) { FX_DCHECK ( freq > 0.0 || ( freq == 0.0 && phase == 0.0 ) ) ; FX_DCHECK ( freq * 2.0 <= buf_size ) << " " ; const double mult = 2.0 * M_PI / buf_size * freq ; for ( uint32_t idx = 0 ; idx < buf_size ; ++ idx ) { buffer [ idx ] = magn * std :: cos ( mult * idx + phase ) ; } }
Local version of GenerateCosineAudio that uses doubles, the same type used by our FFT methods.
Local version of GenerateCosineAudio that uses doubles the same type used by our FFT methods .
// If frequency is 0 (constant val), phase offset causes reduced amplitude // Freqs above buf_size/2 (Nyquist limit) will alias into lower frequencies. // freq is defined as: cosine recurs exactly 'freq' times within buf_size.