Skip to content

Spectrogram: add a Mel frequency axis (Unit setting) - #3368

Open
yjzxkxdn wants to merge 1 commit into
praat:masterfrom
yjzxkxdn:pr/spectrogram-frequency-scale
Open

yjzxkxdn wants to merge 1 commit into
praat:masterfrom
yjzxkxdn:pr/spectrogram-frequency-scale

Conversation

@yjzxkxdn

Copy link
Copy Markdown
Contributor

Praat already uses the Mel scale in MelSpectrogram and MFCC; this also makes it
available as a display axis for the ordinary Spectrogram.

  • New kSpectrogram_unit (Hertz (linear), Mel) in Spectrogram_enums.h.
  • Spectrogram_paint/paintInside take a unit. For Mel the rows are resampled at
    drawing time (the object itself still stores Hz bins), and the drawn range is
    converted with NUMhertzToMel.
  • New instance pref spectrogram_unit (default Hertz), available as "Unit" in
    Spectrogram settings..., like View range and Dynamic range.
  • The frequency cursor, range labels and the formant overlay use the same
    conversion, so they stay aligned.
  • Spectrogram: Paint... keeps its argument list and still draws in Hertz, so
    existing scripts are unaffected.

Verification: MSYS2/GCC build; spectrogram tests in test/fon pass
(Sound_to_Spectrogram, Spectrum_draw, resample*_8, resamplingDepth); an old
10-argument Paint: script runs unchanged.

Images: same sound with Unit = Hertz (first) and Unit = Mel (second).

@yjzxkxdn

Copy link
Copy Markdown
Contributor Author
2e471c2d4f2699e5ac6af025c7d3adcc ![Uploading 8332e15027730775ecc6a4846db9116f.png…]()

@yjzxkxdn

Copy link
Copy Markdown
Contributor Author
8332e15027730775ecc6a4846db9116f

The frequency axis of a spectrogram can now be drawn linearly in Hz or linearly in Mel, selectable with the new Unit setting in Spectrogram settings. Mel rows are obtained by linear interpolation of the dB values in Hz. The frequency cursor, the range marks and the Paint command follow the chosen unit.
@yjzxkxdn
yjzxkxdn force-pushed the pr/spectrogram-frequency-scale branch from 2bc8c0e to 08a189f Compare November 16, 2026 14:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant