| 186 | } |
| 187 | |
| 188 | double SpectrumStack::window(uint64_t i, int type) |
| 189 | { |
| 190 | const double n_m_1 = _sample_num-1; |
| 191 | switch(type) { |
| 192 | case 1: // Hann window |
| 193 | return 0.5*(1-cos(2*PI*i/n_m_1)); |
| 194 | case 2: // Hamming window |
| 195 | return 0.54-0.46*cos(2*PI*i/n_m_1); |
| 196 | case 3: // Blackman window |
| 197 | return 0.42659-0.49656*cos(2*PI*i/n_m_1) + 0.076849*cos(4*PI*i/n_m_1); |
| 198 | case 4: // Flat_top window |
| 199 | return 1-1.93*cos(2*PI*i/n_m_1)+1.29*cos(4*PI*i/n_m_1)- |
| 200 | 0.388*cos(6*PI*i/n_m_1)+0.028*cos(8*PI*i/n_m_1); |
| 201 | default: |
| 202 | return 1; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | } // namespace data |
| 207 | } // namespace pv |