Repository navigation
Conversation
For signalType 'power', _ifft multiplied the whole half spectrum into the AC slice [1:, :], one row short, so building a SignalObj from a spectrum (domain='freq') raised a broadcast error. Index [1:, :] on both sides; the round trip time -> freq -> time closes at the float32 floor. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Smooth the magnitude spectrum over 1 / nthOct octave and keep the phase. The magnitude is interpolated onto a 1 cent logarithmic grid spanning the 20 octaves below Nyquist, box averaged over 1200 / nthOct cents (made odd, shrinking at the ends of the grid) and interpolated back onto the bins with a not-a-knot cubic spline. The DC bin is copied. Follows the LogFreqOctave1 smoothing of ita_smooth in the ITA-Toolbox (RWTH Aachen). Tests pin each rule on spectra built bin by bin and compare 1, 1/3 and 1/12 octave with the ITA-Toolbox output stored in tests/golden/smooth_frequency_ita.mat, which tests/golden/make_smooth_frequency_ita.m regenerates with MATLAB. 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.smooth_frequency(signalObj, nthOct=3): fractional octave smoothing of the magnitude spectrum, phase kept, returning a newSignalObj.The magnitude of
freqSignalis interpolated linearly onto a logarithmic grid of 1 cent spanning the 20 octaves below Nyquist, box averaged over1200 / nthOctcents (made odd, shrinking symmetrically at the ends of the grid) and interpolated back onto the bins with a not-a-knot cubic spline. The DC bin is copied unchanged. This is theLogFreqOctave1smoothing ofita_smoothin the ITA-Toolbox (RWTH Aachen), written from its documented behaviour; no ITA code is copied.The first commit fixes a bug that this feature needs: building a
SignalObjfrom a spectrum (domain='freq') failed forsignalType='power'because_ifftmultiplied the whole half spectrum into the AC slice (shape mismatch). The fix indexes[1:, :]on both sides; the round trip time -> freq -> time now closes at the float32 floor for both signal types.Tests (
tests/test_smooth_frequency.py, 6 tests):area / widthover the predicted band, flat to float32 and zero beyond it, at 1, 1/3 and 1/12 octaventhOctand input typetests/golden/smooth_frequency_ita.mat, generated bytests/golden/make_smooth_frequency_ita.mwith MATLAB and the ITA-Toolbox. Measured difference: 2.7e-7 of the spectrum peak, the float32 floor ofSignalObj.Note for reviewers: PyTTa and the ITA-Toolbox scale the DC and Nyquist bins differently from the AC bins. The reference signal has those two bins at zero so that the comparison pins the smoothing itself; the function smooths
freqSignalas stored.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 PR #49.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com