Repository navigation
Conversation
The overlap argument of plot_spectrogram was used as the hop: 0.75 gave a 25 % overlap, and below 0.5 the frame count overran the signal and the plot failed with a broadcast error (0 failed with a division by zero). The time of each column was spread from 0 to the end of the signal instead of the centre of its window, and the level divided by the number of bins instead of the coherent gain of the window, so only a Hann window read close to the peak amplitude (Blackman read 1.5 dB low). _calc_spectrogram now calls scipy.signal.spectrogram: overlap is the overlapping fraction of consecutive windows, columns sit at the centre of their window, and a sine reads at its peak amplitude in dB for any window. The docstrings said the overlap was in %; it is a fraction. 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.
The plain spectrogram of
plot_spectrogramandSignalObj.plot_spectrogramwas computed by a loop in_plot._calc_spectrogramwith three problems.overlapwas used as the hop between windows. The default of 0.5 hides it, and 0.75 gave a 25 % overlap. Below 0.5 the frame count ran past the end of the signal and the plot failed with a broadcast error, andoverlap=0failed with a division by zero._calc_spectrogramnow callsscipy.signal.spectrogramwithdetrend=False, keeping the same window, dB reference and peak amplitude scale. The docstrings described the overlap as a percentage, and they now describe it as a fraction between 0 and 1.The tests in
tests/test_spectrogram.pycheck the number of columns and the time step for overlaps from 0 to 0.9, the first column at the centre of the first window with a click in the right column, and a sine of amplitude 0.5 at -6.02 dB with Hann, Blackman and rectangular windows. All three fail with the previous code.Checked with Python 3.12, numpy 1.26 and 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.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com