MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ spectral_filter()

std::vector< double > MayaFlux::Kinesis::Discrete::spectral_filter ( std::span< const double >  src,
double  lo_hz,
double  hi_hz,
double  sample_rate,
uint32_t  window_size = 1024,
uint32_t  hop_size = 256 
)

Hard bandpass filter: zero all bins outside [lo_hz, hi_hz].

Parameters
srcInput samples
lo_hzLower frequency bound (Hz)
hi_hzUpper frequency bound (Hz)
sample_rateSample rate (Hz)
window_sizeFFT frame size
hop_sizeAnalysis hop
Returns
Filtered output

Definition at line 123 of file Spectral.cpp.

130{
131 const double bin_hz = sample_rate / static_cast<double>(window_size);
132
133 return apply_spectral(src, window_size, hop_size,
134 [lo_hz, hi_hz, bin_hz](std::vector<std::complex<double>>& spec, size_t) {
135 for (size_t b = 0; b < spec.size(); ++b) {
136 const double f = static_cast<double>(b) * bin_hz;
137 if (f < lo_hz || f > hi_hz)
138 spec[b] = {};
139 }
140 });
141}
size_t b
std::vector< double > apply_spectral(std::span< const double > src, uint32_t window_size, uint32_t hop_size, const SpectrumProcessor &processor)
Apply a per-frame spectrum processor via WOLA analysis-synthesis.
Definition Spectral.cpp:59

References apply_spectral(), and b.

+ Here is the call graph for this function: