Autotune Effects in CSOUND

This is a collection of various Autotune patches. "autotune" is an effect that pitch-shifts a monophonous input to the nearest halftone.

The code is not ready yet, more in a beta stage, and may contain bugs. I'd be glad about any feedback.

Autotune is either useful to correct intonation problems (eg. for Karaoke or Instrumental tracks that might be out-of-tune by instrumental principle - a violinist playing solo eg. might get out-of-tune by a few cents during a longer piece due to lack of reference) or, with extreme settings ("strength" close to 1, decays low) as an effect that gives the
sample a mechanical ("computer voice") feeling.

The Song "Believe" by "Cher", which, despite being poison to your ears, was very popular in Germany, used an Autotune effect for distinctive chorus vocals.

In the end, the effect is very simple:

  1. measure the input frequency f_i
  2. round it to the nearest halftone f_target
  3. pitch shift by the ratio (f_target/f_i)

Refinements to this basic effect are:

  • ignore or dampen broken measurements
  • make f_target "glide"
  • retain some natural variation in pitch

The devil is, like always, in the details. Neither measuring input frequency nor pitch shifting are particularly basic.

I found two satisfying ways to measure the Frequency of a sample. One uses pvsanal/pvspitch, which works fine even with very small FFT windows (which are necissary - the pitch correction has to work on a scale of under maybe 0.05 seconds - which rules out window sizes beyond 2048). However, it has the drawback that pitch can only be determined sensibly once a full FFT window has been received. Inbetween complete FFT windows, the measured pitch can not change. So a quick glide might not be corrected for.

The other one uses pitchamdf, which uses a different method without such
drawbacks. Additionally, it is computationally expensive.

However, I think that both methods might be equally useful, so I
included both.

I also found two satisfying ways to pitch shift a sample. One is inspired by Hans Mikelsons pitch shifter (Instrument 22 in http://www.csounds.com/mikelson/multifx.orc), however improves on it by using two windowed "grains" and switching between them. The method is not free of artifacts, especially there's a periodic clicking noise. This might be because i don't fully understand the problem.

The other one is simply using harmon, which works great, speaking in terms of reaction speed and signal delay, but sadly introduces some distortion. The artifacts are, however, different to the one produced by using delay lines.

AttachmentSize
autotune.csd7.74 KB
wolken-falsch.mp365.71 KB
wolken-pitch.mp371.02 KB