MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / magnitude_spectrum

Function magnitude_spectrum

numpy_ml/preprocessing/dsp.py:304–320  ·  view source on GitHub ↗

Compute the magnitude spectrum (i.e., absolute value of the DFT spectrum) for each frame in `frames`. Assumes each frame is real-valued only. Parameters ---------- frames : :py:class:`ndarray ` of shape `(M, N)` A sequence of `M` frames each consisting of

(frames)

Source from the content-addressed store, hash-verified

302
303
304def magnitude_spectrum(frames):
305 """
306 Compute the magnitude spectrum (i.e., absolute value of the DFT spectrum)
307 for each frame in `frames`. Assumes each frame is real-valued only.
308
309 Parameters
310 ----------
311 frames : :py:class:`ndarray <numpy.ndarray>` of shape `(M, N)`
312 A sequence of `M` frames each consisting of `N` samples
313
314 Returns
315 -------
316 magnitude_spec : :py:class:`ndarray <numpy.ndarray>` of shape `(M, N // 2 + 1)`
317 The magnitude spectrum for each frame in `frames`. Only includes the
318 coefficients for the positive spectrum frequencies.
319 """
320 return np.vstack([np.abs(DFT(frame, positive_only=True)) for frame in frames])
321
322
323def power_spectrum(frames, scale=False):

Callers 1

power_spectrumFunction · 0.85

Calls 1

DFTFunction · 0.85

Tested by

no test coverage detected