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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//! Science crate bridge — pure value conversions.
//!
//! Converts bioacoustic measurements and behavioral state into prani
//! synthesis parameters. These functions accept primitive values so
//! consumers (kiran, joshua) can call them regardless of which science
//! crates are in their dependency graph.
//!
//! ```text
//! jantu (behavior) ──┐
//! goonj (acoustics) ┤
//! ushma (thermo) ├──> bridge functions ──> prani parameters
//! pavan (aerodynamics)┘
//! ```
use crateSpecies;
use crateCallIntent;
// ---------------------------------------------------------------------------
// Body-mass / allometry → voice parameters
// ---------------------------------------------------------------------------
/// Estimates creature size scale from body mass in kilograms.
///
/// Uses the allometric relationship: vocal tract length scales with
/// body mass^(1/3). Reference mass is 30 kg (wolf-sized).
///
/// Returns a size scale suitable for [`CreatureVoice::with_size`](crate::voice::CreatureVoice::with_size).
/// Estimates f0 offset from body temperature deviation.
///
/// Ectotherms (reptiles, insects) have temperature-dependent call rates.
/// Cricket chirp rate follows Dolbear's law. Warmer = higher f0.
///
/// `temp_c` — body or ambient temperature in Celsius.
/// `baseline_c` — the species' reference temperature (typically 20-25°C).
///
/// Returns an f0 offset in Hz to pass to [`CreatureVoice::with_f0_offset`](crate::voice::CreatureVoice::with_f0_offset).
// ---------------------------------------------------------------------------
// Behavioral state → call intent
// ---------------------------------------------------------------------------
/// Maps a threat-level value (0.0–1.0) to the most appropriate call intent.
///
/// Designed for integration with jantu's creature behavior state machine.
/// Maps an arousal level (0.0–1.0) to a breathiness value.
///
/// Higher arousal → more breathiness (panting, stressed phonation).
// ---------------------------------------------------------------------------
// Acoustic environment → spatial parameters
// ---------------------------------------------------------------------------
/// Converts sound pressure level (SPL) at source to an amplitude scale.
///
/// Reference: 94 dB SPL ≈ 1.0 amplitude (1 Pa RMS).
/// Estimates atmospheric HF absorption distance factor from humidity
/// and temperature.
///
/// Higher humidity + higher temperature = less HF absorption at distance.
/// Returns a multiplier for the reference distance in
/// [`apply_distance_attenuation`](crate::spatial::apply_distance_attenuation).
// ---------------------------------------------------------------------------
// Wind / aerodynamics → Doppler
// ---------------------------------------------------------------------------
/// Converts wind speed (m/s) and bearing to an effective radial velocity
/// for Doppler shift.
///
/// `wind_speed_ms` — wind speed in meters per second.
/// `angle_rad` — angle between wind direction and source-listener axis
/// (0 = wind blowing source toward listener, π = away).
// ---------------------------------------------------------------------------
// RTPC-style continuous parameters (what game AI systems drive)
// ---------------------------------------------------------------------------
/// Maps a valence value (−1.0 = negative, +1.0 = positive) to a pitch scale.
///
/// Positive valence (contentment, playfulness) raises pitch slightly.
/// Negative valence (fear, aggression) lowers pitch.
/// Designed for the emotion state machine's valence axis.
/// Maps arousal (0.0–1.0) to a vocal effort value (0.0–1.0).
///
/// Low arousal → whisper-level effort. High arousal → shout-level.
/// This is the primary bridge between the emotion model and the
/// vocal effort parameter on `CreatureVoice`.
/// Maps an urgency value (0.0–1.0) to jitter and shimmer scale factors.
///
/// Returns `(jitter_scale, shimmer_scale)`. Higher urgency = more
/// perturbation (vocal instability under stress).
/// Maps ambient noise SPL to a Lombard effect vocal effort boost.
///
/// The Lombard effect is an involuntary ~3 dB vocal increase per 10 dB
/// ambient noise increase above a quiet baseline (~40 dB SPL).
///
/// Returns an additive effort boost (0.0–0.5) to add to the current
/// vocal effort parameter.
/// Suggests a species from a fundamental frequency measurement.
///
/// Useful when a bioacoustic detector provides an f0 and the caller
/// needs the closest prani species match.