Sum of N sinusoidal partials, each with its own slow amplitude swell.
coefs is the array phasor_bank_state builds. Every call advances each partial's phase and swell phase by its increment and returns sum(scale * sin(phase) * (0.5 + 0.5 * sin(swell_phase))). The window is not read. An array too short for its stated count gives zero. Increments must stay below one revolution per sample.
239{
240 if (coefs.empty())
241 return 0.0;
242
243 const auto n = static_cast<size_t>(std::max(coefs.front(), 0.0));
244 if (n == 0 || coefs.size() < 1 + 5 * n)
245 return 0.0;
246
247 const auto increments = coefs.subspan(1, n);
248 const auto scales = coefs.subspan(1 + n, n);
249 const auto am_increments = coefs.subspan(1 + 2 * n, n);
250 const auto phases = coefs.subspan(1 + 3 * n, n);
251 const auto am_phases = coefs.subspan(1 + 4 * n, n);
252
254 for (size_t i = 0; i < n; ++i) {
255 phases[i] += increments[i];
256 wrap_revolution(phases[i]);
257
258 const double swell = 0.5 + 0.5 * std::sin(am_phases[i]);
259
260 am_phases[i] += am_increments[i];
261 wrap_revolution(am_phases[i]);
262
263 sum += scales[i] * swell * std::sin(phases[i]);
264 }
265 return sum;
266}
std::vector< double > sum(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sum per window.