Function

vDSP_hann_window(_:_:_:)

Creates a single-precision Hanning window.

Declaration

func vDSP_hann_window(_ __C: UnsafeMutablePointer<Float>, _ __N: vDSP_Length, _ __Flag: Int32)

Parameters

__C

Single-precision real output vector.

__N

The desired window length.

__Flag

The Flag parameter can have the following values:

Discussion

The vDSP_hann_window(_:_:_:) and vDSP_hann_windowD(_:_:_:) functions create a Hanning window vector, and write the result to C, which can be multiplied by a vector using vDSP_vmul.

If Flag & vDSP_HANN_NORM:
    W = .8165;
Else
    W = .5;

for (n = 0; n < Length; ++n)
    C[n] = W * (1 - cos(2*pi*n/N));

The following code shows how to generate a Hann window.

let n = vDSP_Length(1024)
var c = [Float](repeating: 0,
                count: Int(n))

vDSP_hann_window(&c,
                 n,
                 Int32(vDSP_HANN_DENORM))

The following illustrates the values of the output vector, c:

Visualization of Hann window.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software