MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
WindowGenerator.hpp
Go to the documentation of this file.
1#pragma once
2
4
11
12/**
13 * @brief Creates a Hann window function
14 * @param length Number of samples in the window
15 * @return Vector containing the window function values
16 *
17 * The Hann window (sometimes called Hanning) is a bell-shaped window
18 * function that tapers smoothly to zero at both ends. It's commonly
19 * used for:
20 * - Smoothing signal transitions
21 * - Reducing spectral leakage in frequency domain analysis
22 * - Creating envelope shapes for synthesis
23 *
24 * Mathematical formula: w(n) = 0.5 * (1 - cos(2π*n/(N-1)))
25 */
26std::vector<double> HannWindow(size_t length);
27
28/**
29 * @brief Creates a Hamming window function
30 * @param length Number of samples in the window
31 * @return Vector containing the window function values
32 *
33 * The Hamming window is similar to the Hann window but doesn't
34 * reach zero at the edges. It offers different spectral characteristics
35 * and is often used in:
36 * - Signal processing
37 * - Filter design
38 * - Spectral analysis
39 *
40 * Mathematical formula: w(n) = 0.54 - 0.46*cos(2π*n/(N-1))
41 */
42std::vector<double> HammingWindow(size_t length);
43
44/**
45 * @brief Creates a Blackman window function
46 * @param length Number of samples in the window
47 * @return Vector containing the window function values
48 *
49 * The Blackman window provides better sidelobe suppression than
50 * Hamming or Hann windows, making it useful for:
51 * - High-quality spectral analysis
52 * - Applications requiring minimal spectral leakage
53 * - Creating smooth envelopes with minimal artifacts
54 *
55 * Mathematical formula: w(n) = 0.42 - 0.5*cos(2π*n/(N-1)) + 0.08*cos(4π*n/(N-1))
56 */
57std::vector<double> BlackmanWindow(size_t length);
58
59/**
60 * @brief Creates a linear ramp function
61 * @param length Number of samples in the ramp
62 * @param start Starting value (default: 0.0)
63 * @param end Ending value (default: 1.0)
64 * @return Vector containing the ramp function values
65 *
66 * A linear ramp increases or decreases at a constant rate from
67 * start to end value. Useful for:
68 * - Creating linear transitions
69 * - Parameter automation
70 * - Simple envelope shapes
71 */
72std::vector<double> LinearRamp(size_t length, double start = 0.0, double end = 1.0);
73
74/**
75 * @brief Creates an exponential ramp function
76 * @param length Number of samples in the ramp
77 * @param start Starting value (default: 0.001)
78 * @param end Ending value (default: 1.0)
79 * @return Vector containing the ramp function values
80 *
81 * An exponential ramp changes at a rate proportional to its current value,
82 * creating a curve that follows natural growth or decay patterns. Useful for:
83 * - Perceptually balanced transitions
84 * - Parameter sweeps with natural-sounding transitions
85 * - Creating more organic envelope shapes
86 *
87 * Note: The start value defaults to 0.001 instead of 0.0 because a true
88 * exponential curve cannot start at zero.
89 */
90std::vector<double> ExponentialRamp(size_t length, double start = 0.001, double end = 1.0);
91
92/**
93 * @brief Generate window coefficients using C++20 ranges
94 * @param size Window size
95 * @param window_type Type of window function
96 * @return Window coefficients
97 */
98std::vector<double> generate_window(uint32_t size, WindowType window_type);
99
100}
std::vector< double > ExponentialRamp(size_t length, double start, double end)
Creates an exponential ramp function.
std::vector< double > BlackmanWindow(size_t length)
Creates a Blackman window function.
std::vector< double > generate_window(uint32_t size, WindowType window_type)
Generate window coefficients using C++20 ranges.
std::vector< double > LinearRamp(size_t length, double start, double end)
Creates a linear ramp function.
std::vector< double > HammingWindow(size_t length)
Creates a Hamming window function.
std::vector< double > HannWindow(size_t length)
Creates a Hann window function.