Skip to content

signal.PitchDetectionHarm.Function.harmonicSum

Christian d'Heureuse edited this page Jun 7, 2026 · 2 revisions

dsp-collection / signal/PitchDetectionHarm / harmonicSum

Function: harmonicSum()

function harmonicSum(
   samples, 
   sampleRate, 
   position, 
   f0, 
   parms?): number;

Defined in: signal/PitchDetectionHarm.ts:125

Pitch salience function using a weighted sum of the harmonic amplitudes.

Calculates a measure for a pitch at a given fundamental frequency by calculating a weighted sum of the amplitudes of its harmonics.

Note that this is a CPU intensive pitch detection algorithm.

Parameters

samples

Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>

The input signal.

sampleRate

number

The sample rate of the input signal. This parameter is only relevant for the parameters f0 and parms.fCutoff. To use normalized frequencies instead, a sample rate of 1 can be specified.

position

number

Position in the input signal where the pitch is to be estimated. Center position of the window. In seconds.

f0

number

The fundamental frequency (in Hz) to be evaluated.

parms?

HarmonicSumParms = ...

Optional secondary parameters, which have default values.

Returns

number

A measure for a pitch perception at the specified fundamental frequency. Or NaN if the pitch cannot be computed.

Clone this wiki locally