pub fn apply_window(signal: &[f64], window: &[f64]) -> FFTResult<Vec<f64>>
Expand description
Apply a window function to a signal
§Arguments
signal
- The signal to apply the window towindow
- The window function to apply
§Returns
A vector containing the windowed signal
§Examples
use scirs2_fft::fft::windowing::{apply_window, create_window, WindowType};
// Create a simple signal
let signal = vec![1.0, 2.0, 3.0, 4.0, 3.0, 2.0, 1.0];
// Create a Hann window
let window = create_window(WindowType::Hann, signal.len()).unwrap();
// Apply the window to the signal
let windowed_signal = apply_window(&signal, &window).unwrap();
// Check that the window was applied correctly
assert_eq!(windowed_signal.len(), signal.len());
assert!(windowed_signal[0] < signal[0]); // Edges are attenuated
assert!(windowed_signal[3] <= signal[3]); // Middle is preserved or slightly attenuated