Repository navigation
Conversation
Add enhanced_spectrogram, a spectrogram with no window to choose: nine
Blackman-Harris windows from 8 to 512 ms are reassigned, the energy of
each frame is held over its frame step, each map is smoothed ('readable'
or 'sharp') and the maps are combined by geometric mean. The output is
on a logarithmic frequency grid in dB re the channel dBRef.
plot_spectrogram and SignalObj.plot_spectrogram take enhanced='readable'
or 'sharp' to draw it on a logarithmic frequency axis. The computation
lives in pytta/utils/spectrogram.py on arrays, so that _plot uses it
without a circular import.
The same method is in SQAT (GPL-3.0) as gui/SQAT_GUI_enhanced_stft.m;
its author releases it here under the MIT license. Tests compare both
smoothings with the SQAT output stored in
tests/golden/enhanced_spectrogram_sqat.mat, which
tests/golden/make_enhanced_spectrogram_sqat.m regenerates with MATLAB,
and pin the level of a steady tone, where a tone and a click land, the
floor of silence, independent channels and the plot.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 31, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
pytta.enhanced_spectrogram(signalObj, smoothing='readable', n_frames=2000, f_min=20, bins_per_octave=192)and the optionenhanced='readable' | 'sharp'topytta.plot_spectrogramandSignalObj.plot_spectrogram.The enhanced spectrogram is a spectrogram with no window to choose: nine Blackman-Harris windows from 8 to 512 ms are reassigned (Auger and Flandrin, 1995), the energy of each frame is held over the frame step of its window, each map is smoothed, and the maps are combined by geometric mean (Cheung and Lim, 1991, applied to reassigned maps). Two smoothings:
readable(4 ms by 1.45 % of the frequency, continuous lines) andsharp(1 ms by 1 Hz, thinnest lines). The output is on a logarithmic frequency grid, in dB re the channel'sdBRef; the cells of a column add up to the level of that instant.The same method is in the SQAT toolbox (GPL-3.0) as
gui/SQAT_GUI_enhanced_stft.m(https://github.com/ggrecow/SQAT). I am its author and release it here under the MIT license of PyTTa; the SQAT version keeps its license. The computation lives inpytta/utils/spectrogram.pyon NumPy arrays, so that_plotcan use it without a circular import;pytta.enhanced_spectrogramis theSignalObjinterface.Tests (
tests/test_enhanced_spectrogram.py, 7 tests):tandfwhole, maps on every 16th row and 10th column). Reference data:tests/golden/enhanced_spectrogram_sqat.mat(135 kB), generated bytests/golden/make_enhanced_spectrogram_sqat.mwith MATLAB and SQAT. Measured difference: 3e-10 dBf_min, smoothing and input typeCost: 10 s of audio at 48 kHz in about 2.3 s on an Apple laptop.
Checked with Python 3.12, numpy 1.26, scipy 1.17. The existing tests behave as on
development: the 7 failures there (3 intest_h5io.py, 4 intest_pyttasave.py) are the same with and without this change. Independent of #49 and #50.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com