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)
| 302 | |
| 303 | |
| 304 | def 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 | |
| 323 | def power_spectrum(frames, scale=False): |