Papers
Topics
Authors
Recent
Search
2000 character limit reached

SWIPE: Sawtooth-Inspired Pitch Estimation

Updated 6 July 2026
  • SWIPE is a monophonic pitch estimator that uses a sawtooth-derived harmonic template to compare perceptually sampled spectra with candidate pitches.
  • Its algorithm employs log-spaced pitch grids, negative inter-harmonic weighting, and adaptive window sizes to enhance pitch accuracy and suppress octave errors.
  • SWIPE kernels serve as an effective neural frontend, reducing model parameters while boosting performance, noise robustness, and transposition equivariance.

Searching arXiv for the cited paper and closely related pitch-estimation work to ground the article with current identifiers. arXiv paper search: query "(Marttila et al., 15 Jul 2025) Improving Neural Pitch Estimation with SWIPE Kernels" arXiv paper search: query "PESTO: Pitch estimation with self-supervised transposition-equivariant objective" Sawtooth-Inspired Pitch Estimation (SWIPE) is a monophonic fundamental-frequency estimator that scores candidate pitches by comparing a perceptually sampled magnitude spectrum with a harmonic kernel derived from the spectral structure of a sawtooth wave. In contemporary pitch-estimation research, SWIPE has also been repurposed as a task-specific frontend for neural models: instead of learning periodicity from raw waveforms or generic time-frequency representations, the network consumes SWIPE score vectors that already encode a strong harmonic prior. A 2025 re-examination argues both that careful SWIPE implementations are substantially more accurate than commonly reported and that SWIPE kernels can improve neural pitch estimation in accuracy, noise robustness, and parameter efficiency (Marttila et al., 15 Jul 2025).

1. Historical basis and harmonic prior

SWIPE was introduced by Camacho and Harris as a pitch estimator for speech and music, with SWIPE′ as a variant that keeps only prime harmonics, except for the fundamental. Its basic intuition is spectral rather than temporal: an ideal sawtooth wave has Fourier amplitudes that decay as $1/k$, so a pitch candidate can be evaluated by measuring how well the observed spectrum matches a weighted harmonic template with that same decay. In the 2025 formulation, this prior is treated not only as a standalone DSP estimator but also as a reusable representation for neural architectures (Marttila et al., 15 Jul 2025).

The harmonic template has two characteristic components. First, it places positive lobes at integer multiples kf0k f_0 with weights wk1/kw_k \propto 1/k. Second, it inserts negative valleys halfway between harmonics in order to suppress subharmonic responses. SWIPE′ removes non-prime harmonics, except k=1k=1, specifically to reduce octave and subharmonic errors. This design makes the method explicitly sensitive to harmonic organization rather than to generic spectral energy.

A recurrent misconception in later neural-pitch literature has been that SWIPE is mainly a weak historical baseline. The 2025 reassessment disputes that view by showing that previously reported SWIPE numbers were strongly affected by implementation choices, including frequency sampling, search range, and normalization. This suggests that the algorithm’s reputation had been shaped at least partly by suboptimal baseline configurations rather than by an intrinsic limitation of the sawtooth prior.

2. Core algorithmic formulation

For each frame x[n]x[n], SWIPE constructs a set of candidate pitches fcf_c on a log-spaced grid. In the neural-frontend implementation, the range is fmin=27.5f_{\min}=27.5 Hz to fmax=8055f_{\max}=8055 Hz at a resolution of 3 bins per semitone, yielding 295 candidate bins. The spectrum is obtained from a windowed DFT, and the magnitude is compressed by a square root, both to reduce spectral slope and to approximate loudness (Marttila et al., 15 Jul 2025).

The SWIPE score is defined as a normalized inner product between a candidate-specific kernel ScS_c and the square-root magnitude spectrum. The manuscript prints this equation with a typesetting error in the closing braces, but its intended meaning is a normalized dot product proportional to

Z(fc)kSc[k]  X[k]1/2Sc2X1/22.Z(f_c)\propto \frac{\sum_k S_c[k]\;|X[k]|^{1/2}} {\|S_c\|_2\,\||X|^{1/2}\|_2}.

The pitch estimate is the maximizing candidate, kf0k f_00. Parabolic interpolation around the peak is optional; it is used in SPTK but not in the paper’s main comparisons.

Kernel construction is highly structured. Positive cosine lobes are centered at the harmonic locations kf0k f_01, with half-width kf0k f_02 and amplitudes kf0k f_03. Negative-valued lobes are centered at half-integer multiples such as kf0k f_04 and kf0k f_05 to reduce subharmonic responses. The paper states that this “corresponds precisely to the square root of the main lobes of a Hann-windowed sawtooth wave if the analysis window size is exactly kf0k f_06.” Because an ideal pitch-dependent window length is impractical, the implementation evaluates the two nearest power-of-two window sizes to kf0k f_07 and linearly interpolates their scores.

Frequency sampling is likewise specialized. Rather than scoring directly on FFT bins, the spectrum is resampled to 1024 frequencies linearly spaced on the Slaney-style mel scale over kf0k f_08. In the original SWIPE literature, ERB sampling was suggested for speech and mel for instruments; the 2025 study evaluates both and finds mel superior on the instrument-oriented benchmark it emphasizes. For voicing, the evaluations use no Viterbi decoding and no post-processing beyond framewise kf0k f_09. In SWIPE scoring, the threshold is set to 0, so all frames are considered voiced.

3. SWIPE kernels as a neural frontend

The central architectural idea is to compute a 295-dimensional SWIPE score vector wk1/kw_k \propto 1/k0 for each frame and to feed that vector, or a short temporal stack of such vectors, to a neural predictor. Because the score vector is already aligned with a pitch grid, it functions as a task-specific representation in which much of the harmonic inference has already been performed (Marttila et al., 15 Jul 2025).

In the supervised setting, the SWIPE-sup model uses 6 dimension-preserving 1D convolutions with zero-padding, layer normalization, and LeakyReLU with slope 0.3. After flattening, a Toeplitz layer replaces a conventional dense layer before the Softmax output. The paper reports that the Toeplitz constraint preserves transposition equivariance and improves generalization relative to an unconstrained dense layer. SWIPE-sup has 0.9M parameters, compared with 6.6M for the raw-waveform FCNF0++ baseline.

In the self-supervised setting, the frontend is substituted directly into the PESTO framework because PESTO already operates on a log-spaced pitch grid. The original PESTO uses CQT features; the SWIPE variants replace those CQT inputs with SWIPE score vectors while retaining the transposition-equivariant objective and timbre-invariance training strategy (Dousselin, 2023, Marttila et al., 15 Jul 2025). SWIPE-full uses the same multi-layer CNN encoder as PESTO and ends in a Toeplitz linear layer plus Softmax, for 28.2k parameters. SWIPE-tiny collapses the encoder almost entirely, using only the final Toeplitz mapping implemented as a single 1D convolutional filter of size 647 plus Softmax, for a total of 647 parameters.

The self-supervised formulation retains the printed PESTO losses: an equivariance mapping wk1/kw_k \propto 1/k1 with the constraint wk1/kw_k \propto 1/k2 under a pitch shift of wk1/kw_k \propto 1/k3 semitones, a shifted cross-entropy regularizer, and an invariance loss under pitch-preserving transforms. A notable implementation detail is that augmenting SWIPE score vectors directly degraded performance. The successful strategy was to augment the waveform in the time domain by adding random noise and an FIR filter with random amplitude response, then recompute SWIPE scores on the fly. The paper interprets the resulting parameter reductions as evidence that SWIPE’s harmonic prior reduces the amount of periodicity structure the network must learn.

4. Evaluation protocols and empirical findings

The empirical study uses MDB-stem-synth, PTDB-TUG, and MIR-1K. MDB-stem-synth contains 230 solo tracks and 418 minutes, with perfect wk1/kw_k \propto 1/k4 annotations obtained by re-synthesis and a hop size of 2.9 ms. PTDB-TUG contains 4720 speech recordings, 576 minutes, 20 English speakers, and a hop size of 10 ms. MIR-1K contains 1000 karaoke excerpts, 133 minutes, and a hop size of 20 ms. Evaluation focuses on cents error wk1/kw_k \propto 1/k5, Raw Pitch Accuracy (RPA) over voiced frames with wk1/kw_k \propto 1/k6 cents, voicing F-Score, and Overall Accuracy (OA), which combines voicing correctness with pitch correctness on voiced frames (Marttila et al., 15 Jul 2025).

For SWIPE alone, the paper reports that commonly cited self-supervised-literature baselines—86.6% RPA on MIR-1K and 90.7% on MDB-stem-synth—substantially understate the achievable accuracy. SPTK SWIPE is highly sensitive to the search range: with wk1/kw_k \propto 1/k7 kHz it reaches 96.5% on MIR-1K and 94.1% on MDB, but with wk1/kw_k \propto 1/k8 kHz it drops to 68.2% and 61.4%. The paper’s own implementation, using a large search range of 27.5–8055 Hz and 1024 perceptually sampled frequencies, reaches 95.7% on MIR-1K and 94.0% on MDB with ERB sampling, and 96.2% and 96.1% with mel sampling. The mel result is the best standalone SWIPE configuration reported in the study.

In supervised experiments trained on MDB-stem-synth plus PTDB-TUG, the reported in-domain test results are: PYIN at 89.4% RPA; SWIPE (DSP) at 93.2% RPA; FCNF0++ at 98.3% RPA, 98.2% F, and 98.7% OA; CQT-sup at 98.1% RPA, 98.7% F, and 99.2% OA; and SWIPE-sup at 97.9% RPA, 98.1% F, and 98.6% OA. On MIR-1K, the same models achieve 95.4%, 96.2%, 91.0% with 87.8% F and 86.0% OA, 92.2% with 91.2% F and 87.1% OA, and 93.5% with 90.0% F and 87.8% OA, respectively. The study emphasizes three comparisons: SWIPE-sup uses far fewer parameters than FCNF0++, its maximum analysis window is much shorter than CQT-sup’s 327 ms versus 1871 ms, and it generalizes best to MIR-1K among the supervised neural models.

The self-supervised results are framed against PESTO (Dousselin, 2023). DSP baselines yield 95.4% on MIR-1K and 91.6% on MDB for PYIN, and 96.2% and 96.1% for SWIPE. The PESTO baseline, with 28.9k parameters, reaches 96.1% on MIR-1K and 94.6% on MDB when trained on MIR-1K, and 93.5% and 95.5% when trained on MDB. CQT-tiny, with 647 parameters, reaches 95.6% and 78.8% when trained on MIR-1K, and 91.7% and 95.5% when trained on MDB. SWIPE-full, with 28.2k parameters, reaches 97.0% and 89.7% when trained on MIR-1K, and 96.1% and 96.4% when trained on MDB. SWIPE-tiny, with 647 parameters, reaches 96.6% and 90.1% when trained on MIR-1K, and 96.4% and 96.5% when trained on MDB. The most striking cross-dataset comparison is that SWIPE-tiny, despite having only 647 parameters, attains 96.4% on MIR-1K when trained on MDB, whereas CQT-tiny degrades to 91.7% under the same train-test configuration.

Noise-robustness experiments add white noise to MIR-1K and report RPA at clean, 5 dB, 0 dB, wk1/kw_k \propto 1/k9 dB, and k=1k=10 dB. The trajectories are: PYIN 95.4 / 95.3 / 95.1 / 93.7 / 85.8; SWIPE (DSP) 96.2 / 93.9 / 91.2 / 85.6 / 75.2; PESTO 94.6 / 93.3 / 92.9 / 90.1 / 81.7; FCNF0++ 91.0 / 90.3 / 89.0 / 83.5 / 81.0; CQT-sup 92.2 / 91.5 / 89.3 / 87.3 / 82.3; SWIPE-sup 93.5 / 91.6 / 90.0 / 87.1 / 72.2; and SWIPE-tiny 96.6 / 96.0 / 95.3 / 93.4 / 88.5. The paper attributes SWIPE-tiny’s particularly strong low-SNR behavior to the interaction of the harmonic prior with the Toeplitz refinement.

5. Implementation, parameterization, and latency

The implementation recipe is explicit. For each candidate k=1k=11, the ideal window size is k=1k=12, approximated by the nearest power-of-two lengths k=1k=13 and k=1k=14; FFT magnitudes are computed for both, and their scores are linearly interpolated. The magnitude spectrum is then resampled to 1024 Slaney-mel frequencies in k=1k=15, square-rooted, and compared with a SWIPE′ kernel defined over the same frequencies. That kernel uses prime harmonics only, except for k=1k=16, includes all harmonics up to Nyquist, assigns weights k=1k=17, and applies cosine lobes of width k=1k=18 together with negative lobes at inter-harmonic midpoints. The output is a 295-dimensional score vector, from which the framewise estimate is obtained by k=1k=19 (Marttila et al., 15 Jul 2025).

The recommended parameters in the study are tightly specified: 3 bins per semitone, x[n]x[n]0 Hz, x[n]x[n]1 Hz, 1024 mel-sampled frequencies, SWIPE′ harmonic selection, and lobe bandwidth x[n]x[n]2. For neural training, the supervised regime uses 500k steps, batch size 256, Adam, and learning rate x[n]x[n]3. The self-supervised regime uses 50 epochs, batch size 256, Adam, and learning rate x[n]x[n]4. In the SWIPE-based self-supervised models, augmentation is applied to the waveform rather than to the SWIPE scores.

Latency is adjustable at inference time because SWIPE scoring depends on window size rather than on a fixed learned receptive field. At a sample rate of 44.1 kHz, a maximum window of 16384 samples, about 372 ms, yields 96.4% RPA for SWIPE-tiny and 97.2% for SWIPE-sup. At 8192 samples, about 186 ms, the figures are 96.4% and 97.1%. At 4096 samples, about 93 ms, they are 96.2% and 96.7%. At 2048 samples, about 46 ms, performance falls sharply to 85.0% and 86.9%. This tradeoff indicates that the method can be retuned for latency-sensitive settings without retraining, although only up to the point at which window shortening begins to destroy the spectral evidence needed for harmonic discrimination.

Computationally, the method scales with the number of window sizes and pitch candidates. The paper characterizes the per-frame feature as memory-light: the neural frontend is only a 295-dimensional vector, and even the smallest downstream model, SWIPE-tiny, has only 647 parameters.

6. Limitations, misconceptions, and research position

The study identifies several failure modes. Very low SNR and heavy broadband noise degrade DSP-only SWIPE more rapidly than SWIPE-tiny, implying that a small learned refinement can compensate for some noise sensitivity. Highly inharmonic or noise-like signals and percussive onsets are poor matches for harmonic kernels. Extreme pitch ranges can exacerbate octave errors through spectral leakage and limited harmonic counts, even though SWIPE′ reduces such errors. Rapid modulation and vibrato create the usual time-frequency tradeoff: shorter windows reduce latency but can reduce accuracy, while multi-resolution scoring only partially mitigates the problem. The formulation also targets monophonic frames; mixed or polyphonic sources can produce overlapping harmonics that confuse the kernel (Marttila et al., 15 Jul 2025).

Within the broader literature on learned pitch estimation, including self-supervised systems such as SPICE (Ikoma et al., 2020), noisy-mixture self-supervised pitch detection (Horkel et al., 2020), and PESTO (Dousselin, 2023), the SWIPE-kernel results reposition hand-crafted harmonic features as a viable complement to learned models rather than as a superseded alternative. A common misconception had been that generic frontends such as raw waveform, STFT, mel, or CQT were necessarily the more flexible and therefore the better foundation for modern pitch networks. The reported results do not support that generalization: SWIPE kernels can match or exceed self-supervised neural baselines, and they can enable orders-of-magnitude parameter reductions without performance degradation in the reported settings.

The most consequential implication is methodological rather than purely empirical. This suggests that strong domain priors can still improve modern neural systems when they are inserted at the representation level rather than treated as end-to-end competitors. In the specific case of monophonic pitch estimation, the SWIPE prior appears to reduce irrelevancies in the spectrum, stabilize inference across timbres, and preserve transposition structure in a way that makes even extremely small neural refiners effective.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Sawtooth-Inspired Pitch Estimation (SWIPE).