function window_function(window_length, name, {
    periodic = true,
    frame_length = null,
    center = true,
} = {}) {
    const length = periodic ? window_length + 1 : window_length;
    let window;
    switch (name) {
        case 'boxcar':
            window = new Float64Array(length).fill(1.0);
            break;
        case 'hann':
        case 'hann_window':
            window = hanning(length);
            break;
        case 'hamming':
            window = hamming(length);
            break;
        case 'povey':
            window = hanning(length).map(x => Math.pow(x, 0.85));
            break;
        default:
            throw new Error(`Unknown window type ${name}.`);
    }
    if (periodic) {
        window = window.subarray(0, window_length);
    }
    if (frame_length === null) {
        return window;
    }
    if (window_length > frame_length) {
        throw new Error(`Length of the window (${window_length}) may not be larger than frame_length (${frame_length})`);
    }

    return window;
}
Returns an array containing the specified window.
@param {number} window_length The length of the window in samples.
@param {string} name The name of the window function.
@param {Object} options Additional options.
@param {boolean} [options.periodic=true] Whether the window is periodic or symmetric.
@param {number} [options.frame_length=null] The length of the analysis frames in samples.
Provide a value for `frame_length` if the window is smaller than the frame length, so that it will be zero-padded.
@param {boolean} [options.center=true] Whether to center the window inside the FFT buffer. Only used when `frame_length` is provided.
@returns {Float64Array} The window of shape `(window_length,)` or `(frame_length,)`.