Repository navigation
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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 to
pytta.functionsthree analysis functions that the ITA-Toolbox has in its kernel (ita_pitch_detection,ita_wiener_hopf_factorizationandita_normxcorr2):pitch_detection(signal, fmin, fmax, blockSize=None, overlap=0, overtones=5, maxPitches=1, minDistance=10, minConfidence=0.1, fftDegree=16): the pitch of every block by the cepstrum biased harmonic product spectrum ofita_pitch_detection. The magnitude spectrum of the Hann windowed block is multiplied by itself decimated by 2 toovertones + 1(Noll 1969) and by the real cepstrum at the quefrency of each bin. Several pitches can be taken one after the other, each with a confidence from the share of energy around it. It returns the pitches, the confidences and the start time of each block.wiener_hopf(signal, invert=False): the factorization of each channel into a causal and an anticausal part whose spectra multiply to the spectrum of the signal, by splitting the complex cepstrum.normxcorr2(template, image): the normalized two-dimensional cross-correlation with the full output of MATLAB'snormxcorr2, computed with local sums (Lewis, "Fast normalized cross-correlation", 1995).Differences from the ITA-Toolbox, kept on purpose:
pitch_detectiondecimates the spectrum by taking every a-th bin, as the harmonic product spectrum is defined, where the ITA-Toolbox resamples it with a filter. It also weights by the real cepstrum, where the ITA-Toolbox uses the complex one. The pitch is the frequency of the peak bin; the ITA-Toolbox returns the bin before it.wiener_hopfleaves out the last step of the ITA-Toolbox, which replaces the phase of each factor by that of a windowed copy. That step is heuristic and breaks the product of the two factors, which here is exact.The ITA code was read for its semantics only and nothing was copied.
The tests in
tests/test_dsp_analysis.pyprint the measured values:normxcorr2has the full output shape, is 1 exactly where a patch of random data was taken as template, and equals the definition at another lag.Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of
development(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