You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If spectral bandwidth is requested with other window than hamming, the spectral centroid should be calculated using that window.
The following code in the function should be fixed:
# centroid or center?
if centroid is None:
centroid = spectral_centroid(
y=y, sr=sr, S=S, n_fft=n_fft, hop_length=hop_length, freq=freq
)
should be:
# centroid or center?
if centroid is None:
centroid = spectral_centroid(
y=y, sr=sr, S=S, n_fft=n_fft, hop_length=hop_length, freq=freq, window = window
)
The text was updated successfully, but these errors were encountered:
There is also a related issue with this. spectral centroid always recomputes the spectrogram even if it is provided as parameter. The normal behaviour should be not to recalculate spectrogram S if provided
Thanks for noting this. I believe the code actually is correct here, but it's not obvious upon a first read through. Here's what's happening:
In these feature functions, either the signal (y) or spectrogram (S) can be provided as input. When S is not provided, it is computed by calling the _spectrogram function.
If _spectrogram is called with S already provided, it behaves as a no-op and returns whatever value of S was provided initially. So your second point is not actually correct: the spectrogram is not recalculated.
When spectral_bandwidth first computes the spectrogram (if needed), all parameters are passed in correctly (including the window function). This spectrogram is then handed over to spectral_centroid later on, and no recalculation takes place: the correct window is used here.
It's true that the code would be more readable if all parameters were correctly passed through to spectral_centroid, but I don't think it would actually affect the behavior.
If spectral bandwidth is requested with other window than hamming, the spectral centroid should be calculated using that window.
The following code in the function should be fixed:
# centroid or center?
if centroid is None:
centroid = spectral_centroid(
y=y, sr=sr, S=S, n_fft=n_fft, hop_length=hop_length, freq=freq
)
should be:
# centroid or center?
if centroid is None:
centroid = spectral_centroid(
y=y, sr=sr, S=S, n_fft=n_fft, hop_length=hop_length, freq=freq, window = window
)
The text was updated successfully, but these errors were encountered: