Applies the configured spectral operation.
Extracts per-channel double spans, calls the corresponding Kinesis::Discrete::Spectral primitive on each channel, then reconstructs the typed output via OperationHelper.
FREQUENCY_SHIFT is implemented as a bandpass repositioning matching the prior behaviour. True single-sideband frequency shift (complex exponential modulation) is a separate primitive.
81 {
83
85 const auto shift_hz = get_parameter_or<double>("shift_hz", 0.0);
86 const auto window_size = get_parameter_or<uint32_t>("window_size", 1024);
87 const auto hop_size = get_parameter_or<uint32_t>("hop_size", 512);
88 const auto sample_rate = get_parameter_or<double>("sample_rate", 48000.0);
89 const double lo = std::max(0.0, shift_hz);
90 const double hi = sample_rate / 2.0 + shift_hz;
91
93 [lo, hi, sample_rate, window_size, hop_size](std::span<double> ch) {
95 });
96 }
97
99 const auto pitch_ratio = get_parameter_or<double>("pitch_ratio", 1.0);
100 const auto window_size = get_parameter_or<uint32_t>("window_size", 2048);
101 const auto hop_size = get_parameter_or<uint32_t>("hop_size", 512);
102 const double semitones = 12.0 * std::log2(pitch_ratio);
103
105 [semitones, window_size, hop_size](std::span<double> ch) {
107 });
108 }
109
111 const auto lo_freq = get_parameter_or<double>("low_freq", 20.0);
112 const auto hi_freq = get_parameter_or<double>("high_freq", 20000.0);
113 const auto sample_rate = get_parameter_or<double>("sample_rate", 48000.0);
114 const auto window_size = get_parameter_or<uint32_t>("window_size", 1024);
115 const auto hop_size = get_parameter_or<uint32_t>("hop_size", 512);
116
118 [lo_freq, hi_freq, sample_rate, window_size, hop_size](std::span<double> ch) {
120 });
121 }
122
124 const auto factor = get_parameter_or<double>("enhancement_factor", 2.0);
125 const auto window_size = get_parameter_or<uint32_t>("window_size", 1024);
126 const auto hop_size = get_parameter_or<uint32_t>("hop_size", 512);
127
129 [factor, window_size, hop_size](std::span<double> ch) {
131 });
132 }
133
135 const auto threshold = get_parameter_or<double>("threshold", -40.0);
136 const auto window_size = get_parameter_or<uint32_t>("window_size", 1024);
137 const auto hop_size = get_parameter_or<uint32_t>("hop_size", 512);
138
140 [threshold, window_size, hop_size](std::span<double> ch) {
142 });
143 }
144
145 default:
147 }
148 }
std::vector< double > spectral_gate(std::span< const double > src, double threshold_db, uint32_t window_size, uint32_t hop_size)
Hard spectral gate: zero bins whose magnitude is below the threshold.
std::vector< double > spectral_filter(std::span< const double > src, double lo_hz, double hi_hz, double sample_rate, uint32_t window_size, uint32_t hop_size)
Hard bandpass filter: zero all bins outside [lo_hz, hi_hz].
std::vector< double > harmonic_enhance(std::span< const double > src, double enhancement_factor, uint32_t window_size, uint32_t hop_size)
Linear spectral tilt: scale each bin by a factor that rises linearly from 1 at bin 0 to enhancement_f...
std::vector< double > pitch_shift(std::span< const double > src, double semitones, uint32_t window_size, uint32_t analysis_hop)
Pitch-shift by resampling around a phase vocoder stretch.
@ SPECTRAL_FILTER
Hard bandpass filter.
@ SPECTRAL_GATE
Hard magnitude gate.
@ HARMONIC_ENHANCE
Linear spectral tilt.
@ PITCH_SHIFT
Phase-vocoder pitch shift, duration preserved.
@ FREQUENCY_SHIFT
Bandpass repositioning (approximate frequency shift)