Skip to content

Analysis fft.fs and sample_rate mismatch#340

Open
Gautzilla wants to merge 4 commits intoProject-OSmOSE:mainfrom
Gautzilla:analysis-warning-fs-mismatch
Open

Analysis fft.fs and sample_rate mismatch#340
Gautzilla wants to merge 4 commits intoProject-OSmOSE:mainfrom
Gautzilla:analysis-warning-fs-mismatch

Conversation

@Gautzilla
Copy link
Contributor

🐠 What's new?

This PR adds some error raising when trying to run Analysis where the sample_rate and fft.fs mismatch:

In the constructor

Analysis(AnalysisType.AUDIO, sample_rate=48_000, fft=ShortTimeFFT(hamming(1024),512,fs=32_000))

>>> ValueError: The sample rate of the analysis (48000 Hz) does not match the sampling frequency of the fft (32000 Hz)

In the FFT property

analysis=Analysis(AnalysisType.AUDIO, sample_rate=48_000, fft=ShortTimeFFT(hamming(1024),512,fs=48_000))
analysis.fft=ShortTimeFFT(hamming(1024),512,fs=32_000)

>>> ValueError: The sample rate of the analysis (48000 Hz) does not match the sampling frequency of the fft (32000 Hz)

The sample_rate property modifies the fft.fs value

analysis=Analysis(AnalysisType.AUDIO, sample_rate=48_000, fft=ShortTimeFFT(hamming(1024),512,fs=48_000))
analysis.sample_rate = 32_000
print(analysis.fft.fs)

>>> 32000

🐡 Note

This PR resolves #337

@Gautzilla Gautzilla self-assigned this Feb 11, 2026
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.

No warning when analysis sr and fft sr differ

1 participant