Use Non-Frames Version Previous Page Next Page
Instrument Control: Sensing and Control

pitchamdf

  kcps,   pitchamdf asig, imincps, imaxcps[, icps[, imedi[, idowns[, iexcps]]]]
  krms

Description

Follows the pitch of a signal based on the AMDF method (Average Magnitude Difference Function). Outputs pitch and amplitude tracking signals. The method is quite fast and should run in realtime. This technique usually works best for monophonic signals.

Initialization

imincps - estimated minimum frequency (expressed in Hz) present in the signal

imaxcps - estimated maximum frequency present in the signal

icps - estimated initial frequency of the signal. If 0, icps = (imincps+imaxcps) / 2. The default is 0.

imedi - size of median filter applied to the output kcps. The size of the filter will be imedi*2+1. If 0, no median filtering will be applied. The default is 1.

idowns - downsampling factor for asig. Must be an integer. A factor of idowns > 1 results in faster performance, but may result in worse pitch detection. Useful range is 1 - 4. The default is 1.

iexcps - how frequently pitch analysis is executed, expressed in Hz. If 0, iexcps is set to imincps. This is usually reasonable, but experimentation with other values may lead to better results. Default is 0.

Performance

kcps - pitch tracking output

krms - amplitude tracking output

pitchamdf usually works best for monophonic signals, and is quite reliable if appropriate initial values are chosen. Setting imincps and imaxcps as narrow as possible to the range of the signal's pitch, results in better detedtion and performance.

Because this process can only detect pitch after an initial delay, setting icps close to the signal's real initial pitch prevents spurious data at the beginning.

The median filter prevents kcps from jumping. Experiment to determine the optimum value for imedi for a given signal.

Other initial values can usually be left at the default settings. Lowpass filtering of asig before passing it to pitchamdf, can improve preformance, especially with complex waveforms.

Example

  ginput  ftgen     1, 0, 0, -1, "input.wav", 0, 4, 0  ; input signal
  giwave  ftgen     2, 0, 1024, 10, 1, 1, 1, 1         ; synth wave

          instr 1
  asig    loscil    1, 1, ginput, 1                    ; get input signal with original freq
  asig    tone      asig, 1000                         ; lowpass-filter
  kcps, krms pitchamdf asig, 150, 500, 200             ; extract pitch and envelope
  asig1   oscil     krms, kcps, iwave                  ; "resynthesize" with some waveform
          out       asig1
          endin

Author

Peter Neubäcker
Munich, Germany
August, 1999
New in Csound version 3.59



Use Non-Frames Version Previous Page Next Page
Instrument Control: Sensing and Control