1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Shared types for creature and fluid sound synthesis.
use serde::{Deserialize, Serialize};
/// Type of insect sound.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum InsectType {
/// Wing buzz — frequency-modulated vibration (bee, fly, mosquito).
WingBuzz,
/// Cricket chirp — stridulation (leg-on-wing friction).
CricketChirp,
/// Cicada drone — sustained high-frequency rattle.
CicadaDrone,
}
/// Type of bubble sound.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum BubbleType {
/// Underwater air bubbles — rising, popping.
Underwater,
/// Boiling water — rapid stochastic bubbles.
Boiling,
/// Viscous fluid — slow, thick bubbles (lava, mud).
Viscous,
/// Pouring liquid — stream of small bubbles.
Pouring,
}
impl InsectType {
/// Returns (base_freq_hz, modulation_rate_hz, chirp_rate_hz, amplitude).
#[inline]
#[must_use]
pub(crate) fn config(self) -> (f32, f32, f32, f32) {
match self {
// Wing buzz: high freq carrier, slow AM modulation
Self::WingBuzz => (200.0, 8.0, 0.0, 0.3),
// Cricket: silence-chirp pattern, ~4kHz carrier, ~15Hz pulse rate
Self::CricketChirp => (4000.0, 15.0, 3.0, 0.2),
// Cicada: broadband ~6kHz, slow AM
Self::CicadaDrone => (6000.0, 20.0, 0.5, 0.25),
}
}
}
impl BubbleType {
/// Returns (base_freq_hz, event_rate, freq_spread, decay_time_s).
#[inline]
#[must_use]
pub(crate) fn config(self) -> (f32, f32, f32, f32) {
match self {
Self::Underwater => (400.0, 5.0, 300.0, 0.03),
Self::Boiling => (800.0, 30.0, 600.0, 0.01),
Self::Viscous => (150.0, 2.0, 100.0, 0.08),
Self::Pouring => (600.0, 40.0, 400.0, 0.005),
}
}
}