125 const float toe = noise.
Between(0.04f, 0.07f);
131 Hiss(noise, 0.15f, noise.
Between(250.0f, 400.0f), 0.7f, Pass::kLow,
135 Hiss(noise, 0.2f, noise.
Between(2000.0f, 3500.0f), 1.0f, Pass::kBand,
139 Crackle(noise, 0.15f, 300.0f, noise.
Between(2000.0f, 3000.0f), 1.5f,
143 Hiss(noise, 0.12f, noise.
Between(300.0f, 500.0f), 0.7f, Pass::kLow,
150 Hiss(noise, 0.15f, noise.
Between(150.0f, 250.0f), 0.7f, Pass::kLow,
154 Crackle(noise, 0.3f, 3000.0f, noise.
Between(3000.0f, 4500.0f), 0.8f,
158 Crackle(noise, 0.2f, 2000.0f, noise.
Between(3000.0f, 4500.0f), 0.8f,
165 Hiss(noise, 0.15f, noise.
Between(120.0f, 180.0f), 0.7f, Pass::kLow,
169 Crackle(noise, 0.35f, 1500.0f, noise.
Between(1500.0f, 2200.0f), 1.5f,
173 Crackle(noise, 0.25f, 1200.0f, noise.
Between(1800.0f, 2600.0f), 1.5f,
180 Hiss(noise, 0.15f, noise.
Between(160.0f, 220.0f), 0.7f, Pass::kLow,
184 Crackle(noise, 0.3f, 600.0f, noise.
Between(2400.0f, 3200.0f), 4.0f,
188 Crackle(noise, 0.2f, 500.0f, noise.
Between(2800.0f, 3600.0f), 4.0f,
194 Mix(step, Click(noise, 4500.0f), 0.0f, 0.4f);
196 Hiss(noise, 0.1f, noise.
Between(1000.0f, 1400.0f), 3.0f, Pass::kBand,
200 Crackle(noise, 0.12f, 250.0f, noise.
Between(2000.0f, 3000.0f), 6.0f,
204 Hiss(noise, 0.1f, noise.
Between(1100.0f, 1500.0f), 3.0f, Pass::kBand,
210 Mix(step, Click(noise, 4000.0f), 0.0f, 0.3f);
212 Hiss(noise, 0.2f, noise.
Between(600.0f, 800.0f), 8.0f, Pass::kBand,
216 Hiss(noise, 0.2f, noise.
Between(650.0f, 850.0f), 8.0f, Pass::kBand,
219 Echo(step, 0.06f, 0.35f);
220 Echo(step, 0.13f, 0.15f);
225 Hiss(noise, 0.3f, noise.
Between(1200.0f, 2000.0f), 0.6f, Pass::kBand,
228 Mix(step, Hiss(noise, 0.3f, 400.0f, 0.7f, Pass::kLow, 0.02f, 0.08f), 0.0f,
230 for (
int bubble = 0, n =
static_cast<int>(noise.
Between(3.0f, 7.0f));
231 bubble < n; ++bubble) {
232 const float hertz = noise.
Between(500.0f, 1300.0f);
233 Mix(step, Tone(0.08f, hertz, hertz * 1.6f, 0.002f, 0.02f),
234 noise.
Between(0.01f, 0.18f), 0.3f);
310 const float span =
static_cast<float>(fx.for_ms()) / 1000.0f;
311 const float size = fx.size() > 0.0f ? fx.size() : 1.0f;
312 const float cold =
Coldness(fx.color());
314 const float note = 220.0f * std::exp2(cold);
315 const int count =
static_cast<int>(fx.count() > 0 ? fx.count() : 12);
318 case skills::Fx::TRAIL:
320 sound = Whoosh(noise, span + 0.1f, 300.0f, 2000.0f, 0.4f);
322 case skills::Fx::GLOW: {
326 std::array<Oscillator, 6> voices;
327 constexpr std::array<float, 6> kRatios = {1.0f, 1.004f, 1.5f,
328 1.503f, 2.0f, 2.005f};
329 for (std::size_t i = 0; i < sound.size(); ++i) {
331 for (std::size_t v = 0; v < voices.size(); ++v) {
332 chord += voices[v].Next(note * kRatios[v]);
334 sound[i] = chord *
Envelope(Seconds(i), 0.4f * span, 0.4f * span);
339 case skills::Fx::RING: {
342 const float low = std::clamp(80.0f / std::sqrt(size), 35.0f, 90.0f);
343 Mix(sound, Tone(0.5f, 2.0f * low, low, 0.004f, 0.18f), 0.0f, 0.9f);
346 for (std::size_t i = 0; i < rush.size(); ++i) {
347 const float t = Seconds(i);
349 filter.
Run(noise.
Next(), 2500.0f * std::pow(0.12f, t / span), 1.0f)
351 Envelope(t, 0.05f * span, 0.35f * span);
354 Mix(sound, rush, 0.0f, 0.5f);
357 case skills::Fx::SPARKS: {
361 for (
int i = 0; i < std::min(count, 24); ++i) {
363 const float hertz = noise.
Between(2500.0f, 5000.0f);
364 const float decay = noise.
Between(0.01f, 0.03f);
365 const float gain = noise.
Between(0.3f, 1.0f);
366 Mix(sound, Tone(0.15f, hertz, 0.97f * hertz, 0.0005f, decay), at, gain);
368 Tone(0.1f, 2.76f * hertz, 2.7f * hertz, 0.0005f, 0.5f * decay), at,
373 if (fx.at() == skills::Fx::TARGET) {
374 Mix(sound, Tone(0.3f, 160.0f, 50.0f, 0.001f, 0.07f), 0.0f, 3.0f);
378 case skills::Fx::MOTES: {
381 constexpr std::array<float, 6> kScale = {
382 1.0f, 9.0f / 8.0f, 5.0f / 4.0f, 3.0f / 2.0f, 5.0f / 3.0f, 2.0f};
383 for (
int i = 0; i < std::min(count, 32); ++i) {
385 4.0f * note * kScale[
static_cast<int>(noise.
Uniform() * 5.99f)];
386 const float at = 0.8f * span * std::pow(noise.
Uniform(), 0.7f);
387 Mix(sound, Tone(0.5f, hertz, hertz * 1.03f, 0.004f, 0.12f), at);
391 case skills::Fx::SHAKE:
393 Mix(sound, Tone(span + 0.4f, 60.0f, 32.0f, 0.005f, 0.5f * span + 0.1f),
396 Hiss(noise, span + 0.4f, 100.0f, 0.7f, Pass::kLow, 0.01f,
400 case skills::Fx::SHARDS:
403 Mix(sound, Click(noise, 2500.0f), 0.0f, 1.0f);
404 for (
int i = 0; i < std::min(count, 32); ++i) {
405 const float at = span * noise.
Between(0.4f, 0.95f);
407 const float hertz = noise.
Between(2500.0f, 6000.0f);
408 Mix(sound, Tone(0.2f, hertz, hertz, 0.0005f, 0.035f), at, 0.3f);
410 const float hertz = noise.
Between(400.0f, 900.0f);
411 Mix(sound, Tone(0.08f, hertz, 0.7f * hertz, 0.0005f, 0.015f), at,
416 case skills::Fx::SPIKES: {
420 Mix(sound, Tone(span, 55.0f, 40.0f, 0.15f * span, 0.4f * span), 0.0f,
423 Hiss(noise, span, 90.0f, 0.7f, Pass::kLow, 0.15f * span, 0.4f * span),
425 const int spikes = std::min(count, 24);
426 for (
int i = 0; i < spikes; ++i) {
427 const float at = 0.35f * span *
static_cast<float>(i) / spikes +
429 const float thunk = noise.
Between(150.0f, 220.0f);
430 Mix(sound, Tone(0.15f, thunk, 0.35f * thunk, 0.001f, 0.035f), at, 0.6f);
431 const float knock = noise.
Between(700.0f, 1200.0f);
432 Mix(sound, Tone(0.06f, knock, 0.8f * knock, 0.0005f, 0.008f), at,
435 const float hertz = noise.
Between(2000.0f, 4000.0f);
436 Mix(sound, Tone(0.2f, hertz, hertz, 0.0005f, 0.06f), at, 0.15f);
441 case skills::Fx::BOLT: {
444 Mix(sound, Click(noise, 2500.0f), 0.0f, 1.0f);
449 float hertz = 100.0f;
452 for (std::size_t i = 0; i < buzz.size(); ++i) {
455 hertz = noise.
Between(50.0f, 160.0f);
456 level = noise.
Between(0.3f, 1.0f);
458 phase += hertz /
kRate;
459 phase -= std::floor(phase);
462 const float raw = 2.0f * phase - 1.0f + 0.5f * noise.
Next();
463 buzz[i] = low.
Run(high.
Run(raw, 400.0f).
high, 5000.0f).
low * level *
464 Envelope(Seconds(i), 0.003f, 0.6f * span);
467 Mix(sound, buzz, 0.0f, 0.5f);
468 Mix(sound, Hiss(noise, 1.6f, 120.0f, 0.7f, Pass::kLow, 0.05f, 0.5f),
472 case skills::Fx::WAVE: {
476 for (std::size_t i = 0; i < roar.size(); ++i) {
477 const float swell = Swell(Seconds(i) / (span + 0.2f), 0.3f);
479 filter.
Run(noise.
Next(), 400.0f + 1600.0f * swell).
low * swell;
481 Mix(sound, roar, 0.0f, 1.2f);
482 Mix(sound, Crackle(noise, span, 60.0f, 1500.0f, 3.0f, 0.05f, 0.5f * span),
486 case skills::Fx::EDGE: {
490 const float hertz = 4.0f * note;
494 for (std::size_t i = 0; i < sing.size(); ++i) {
495 const float t = Seconds(i);
496 const float waver = 1.0f + 0.006f * std::sin(2.0f * kPi * 5.5f * t);
497 sing[i] = (first.
Next(hertz * waver) +
498 0.35f * second.
Next(2.76f * hertz * waver)) *
502 Mix(sound, sing, 0.0f, 1.0f);
503 Mix(sound, Tone(0.6f, 2.0f * hertz, 2.0f * hertz, 0.001f, 0.15f), 0.0f,
507 case skills::Fx::GHOSTS:
509 sound = Whoosh(noise, span + 0.15f, 200.0f, 3500.0f, 0.3f);
511 case skills::Fx::SLASH: {
514 const int cuts =
static_cast<int>(std::max(fx.count(), 1u));
515 for (
int i = 0; i < std::min(cuts, 8); ++i) {
516 const float at = 0.06f *
static_cast<float>(i);
518 Hiss(noise, 0.12f, 6000.0f, 0.8f, Pass::kHigh, 0.002f, 0.04f), at,
520 Mix(sound, Click(noise, 5000.0f), at, 0.8f);
521 const float ring = noise.
Between(2800.0f, 3600.0f);
522 Mix(sound, Tone(0.4f, ring, 0.99f * ring, 0.0005f, 0.09f), at, 0.35f);
523 Mix(sound, Tone(0.3f, 2.76f * ring, 2.7f * ring, 0.0005f, 0.05f), at,
528 case skills::Fx::FLASH:
530 Mix(sound, Click(noise, 3000.0f), 0.0f, 1.0f);
531 Mix(sound, Tone(0.5f, 140.0f, 38.0f, 0.002f, 0.12f), 0.0f, 1.4f);