+void FakeCapture::make_tone(int32_t *out, unsigned num_stereo_samples)
+{
+ int32_t *ptr = out;
+ float r = audio_real, i = audio_imag;
+ for (unsigned sample_num = 0; sample_num < num_stereo_samples; ++sample_num) {
+ int32_t s = lrintf(r);
+ *ptr++ = s;
+ *ptr++ = s;
+
+ // Rotate the phaser by one sample.
+ float new_r = r * audio_cos - i * audio_sin;
+ float new_i = r * audio_sin + i * audio_cos;
+ r = new_r;
+ i = new_i;
+ }
+
+ // Periodically renormalize to counteract precision issues.
+ double corr = audio_ref_level / hypot(r, i);
+ audio_real = r * corr;
+ audio_imag = i * corr;
+}
+