Luftzig / elm-signal-processing / WindowFunctions

Different windows used for sampling when working with FFT and convolution algorithms. See: https://en.wikipedia.org/wiki/Window_function

Impulse

The impulse is the simplest window, it takes only the first value

impulse : Basics.Int -> List Basics.Float

The impulse window is a window in which the first element is 1, and all other elements are zero

Square

Square is just a list of ones (1). A centered square window is padded by zeros on both sides.

square : Basics.Int -> List Basics.Float

The square window is 1 everywhere

centeredSquare : Basics.Int -> Basics.Int -> List Basics.Float

The centered square window is 1 for width number of elements around the middle of size. If size - width is odd, than the returned window will be smaller than size by 1.

centeredSquare 3 1 --> [0, 1, 0]

centeredSquare 5 2 -> [0, 1, 1, 0]

Cosine-sum windows

These windows use the sum of cosine functions to create the window. They are very common in filtering.

blackman : Basics.Int -> List Basics.Float

returns a Blackman window of size n. See: https://en.wikipedia.org/wiki/Window_function#Blackman_window

hann : Basics.Int -> List Basics.Float

hann window is a cosine sum window with a0 parameter set to 0.5. See: https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows

hamming : Basics.Int -> List Basics.Float

hann window is a cosine sum window with a0 parameter set to 0.54. See: https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows