1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_bartlett_f32.c
4  * Description:  Floating-point (f32) Bartlett window
5  *
6  * $Date:        14 December 2022
7  * $Revision:    v1.15.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2022 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
16  * Licensed under the Apache License, Version 2.0 (the License); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28 
29 #include "dsp/window_functions.h"
30 
31 /**
32   @ingroup groupWindow
33  */
34 
35 
36 
37 
38 /**
39   @addtogroup WindowNormal
40   @{
41  */
42 
43 /**
44   @defgroup WindowBARTLETT Bartlett window function (26.5 dB)
45 
46  */
47 
48 /**
49   @ingroup WindowBARTLETT
50  */
51 
52 /**
53   @brief         Bartlett window generating function (f32).
54   @param[out]    pDst       points to the output generated window
55   @param[in]     blockSize  number of samples in the window
56 
57   @par Parameters of the window
58 
59   | Parameter                             | Value              |
60   | ------------------------------------: | -----------------: |
61   | Peak sidelobe level                   |           26.5 dB  |
62   | Normalized equivalent noise bandwidth |       1.3333 bins  |
63   | 3 dB bandwidth                        |       1.2736 bins  |
64   | Flatness                              |        -1.8242 dB  |
65   | Recommended overlap                   |            50.0 %  |
66 
67  */
68 
69 
70 
arm_bartlett_f32(float32_t * pDst,uint32_t blockSize)71 ARM_DSP_ATTRIBUTE void arm_bartlett_f32(
72         float32_t * pDst,
73         uint32_t blockSize)
74 {
75    float32_t k = 2.0f / ((float32_t) blockSize);
76    float32_t w;
77 
78    for(uint32_t i=0;i<blockSize;i++)
79    {
80      w = i * k ;
81      if (i * k > 1.0f)
82      {
83        w = 2.0f - w;
84      }
85      pDst[i] = w;
86    }
87 }
88 
89 /**
90   @} end of WindowNormal group
91  */
92 
93