EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
echomap::WindowFunctions::BlackmanHarris Struct Reference

The minimum four-term Blackman-Harris cosine-sum window. More...

#include <WindowFunctions.hpp>

Static Public Member Functions

static float operator() (std::size_t index, std::size_t size) noexcept
 Maps the index into the Blackman-Harris function.

Detailed Description

The minimum four-term Blackman-Harris cosine-sum window.

Definition at line 213 of file WindowFunctions.hpp.

Member Function Documentation

◆ operator()()

float echomap::WindowFunctions::BlackmanHarris::operator() ( std::size_t index,
std::size_t size )
staticnoexcept

Maps the index into the Blackman-Harris function.

For a window of size \( M \), let \( N = M - 1 \).

\[ w[n] = a_0 - a_1\cos\left(\frac{2\pi n}{N}\right) + a_2\cos\left(\frac{4\pi n}{N}\right) - a_3\cos\left(\frac{6\pi n}{N}\right) \]

where

\[ a_0 = 0.35875,\quad a_1 = 0.48829,\quad a_2 = 0.14128,\quad a_3 = 0.01168. \]

for index \( n \).

Parameters
indexThe index within the window.
sizeThe size of the window.
Returns
The Blackman-Harris-mapped index.

Definition at line 77 of file WindowFunctions.cpp.

81{
82 if (size <= 1)
83 return 1.0f;
84
85 // Disabled warnings: a{0,1,2,3} are standard names in the literature describing Blackman-Harris.
86
87 constexpr auto a0 = 0.35875f; // NOLINT(*-identifier-length)
88 constexpr auto a1 = 0.48829f; // NOLINT(*-identifier-length)
89 constexpr auto a2 = 0.14128f; // NOLINT(*-identifier-length)
90 constexpr auto a3 = 0.01168f; // NOLINT(*-identifier-length)
91
92 const auto phase = 2.0f * std::numbers::pi_v<float> * static_cast<float>(index) / static_cast<float>(size - 1);
93 return a0 - a1 * std::cos(phase) + a2 * std::cos(2.0f * phase) - a3 * std::cos(3.0f * phase);
94}
T cos(T... args)

The documentation for this struct was generated from the following files: