How to use this calculator
Find a candidate waveform repetition period by comparing the record with delayed copies.
- Enter Uniform samples (signal units), Sampling frequency (Hz), Smallest tested lag, Largest tested lag. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Average magnitude difference pitch period explained
AMDF compares a sample sequence with delayed copies. The selected lag gives a candidate period, and sampling frequency divided by that lag gives a candidate repetition frequency.
Inputs, symbols, and units
x— Uniform samples (signal units)- Chronological real samples; use a comma-separated list in the same signal units. Use comma-separated values in the stated order.
fs— Sampling frequency (Hz)- Uniform samples per second; must be positive.
lo— Smallest tested lag- Minimum candidate full period in samples. Enter a whole number.
hi— Largest tested lag- Maximum candidate full period, smaller than record length. Enter a whole number.
Formula and method
D(k)=mean over n=0…N−k−1 of |x[n+k]−x[n]|; choose smallest D in the stated interval; f=fs/k. Ties choose the smallest lag.
The lag search range encodes plausible full periods. Unlike zero crossings, this method can use a waveform with a DC offset; repeated subpatterns and harmonics still create ambiguity.
A worked scenario
Uniform samples (signal units) = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]; Sampling frequency (Hz) = 8000; Smallest tested lag = 2; Largest tested lag = 5.
- Candidate repetition frequency: 2000 Hz
- Selected integer period: 4 samples
- Mean absolute difference: 0 signal units
- Difference at lag 2: 1 signal units
- Difference at lag 3: 1 signal units
- Difference at lag 4: 0 signal units
- Difference at lag 5: 1 signal units
A twelve-sample four-point oscillation is searched over lags two through five at 8 kHz, identifying a four-sample period.
Assumptions and edge cases
No voicing classification, interpolation or pitch-tracking continuity. A minimum need not be the fundamental, especially for repeated harmonics or too-short records.
Reading the outputs
The full lag-difference curve supports inspection of competing minima; candidate frequency uses integer-sample timing.
Frequently asked questions
Does a DC offset change the difference curve?
A constant offset cancels between delayed samples.
Why can the wrong octave be selected?
A waveform can have similar subperiods or multiple-period matches.
Is this appropriate for every sound?
No. Noise and mixtures may have no meaningful single repetition period.
How do I use the Average magnitude difference pitch period calculator?
Enter Uniform samples (signal units), Sampling frequency (Hz), Smallest tested lag, Largest tested lag. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Average magnitude difference pitch period?
Uniform samples (signal units) = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]; Sampling frequency (Hz) = 8000; Smallest tested lag = 2; Largest tested lag = 5. Candidate repetition frequency: 2000 Hz Selected integer period: 4 samples Mean absolute difference: 0 signal units Difference at lag 2: 1 signal units Difference at lag 3: 1 signal units Difference at lag 4: 0 signal units Difference at lag 5: 1 signal units A twelve-sample four-point oscillation is searched over lags two through five at 8 kHz, identifying a four-sample period.
Read our calculation methodology.