W_cosinemultiplies the sequence in arrayAby a cosine window function of parameterrand returns the product in arrayB. ArrayAis unmodified.Ris the peak-to-peak amplitude of the cosine portion of the window; it must be between 0 and 1, inclusive. IfNis the number of elements in the arrayAandkis the position in the arrayB, the formula for the window function,wk, is
In the above formula,kranges in value from 0 toN- 1.
If the arrayBcontains more elements thanA, the extra elements inBare unmodified.
Cosine windows forN=128
Special cases of the cosine window are the Hamming and Hanning windows; these are available as separate subroutines.
Errors
W_cosinecauses an HTBasic error if its arguments are not of the types listed in the USAGEsection, above, ifris not between 0 and 1, inclusive, or ifBcontains fewer elements thanA.