| 149 | |
| 150 | |
| 151 | def get_window(window, Nx, *, fftbins=True): |
| 152 | if callable(window): |
| 153 | return window(Nx) |
| 154 | |
| 155 | elif isinstance(window, (str, tuple)) or np.isscalar(window): |
| 156 | # TODO: if we add custom window functions in librosa, call them here |
| 157 | |
| 158 | return scipy.signal.get_window(window, Nx, fftbins=fftbins) |
| 159 | |
| 160 | elif isinstance(window, (np.ndarray, list)): |
| 161 | if len(window) == Nx: |
| 162 | return np.asarray(window) |
| 163 | |
| 164 | raise RuntimeError("Window size mismatch: " "{:d} != {:d}".format(len(window), Nx)) |
| 165 | else: |
| 166 | raise RuntimeError("Invalid window specification: {}".format(window)) |
| 167 | |
| 168 | |
| 169 | def stft( |