euv_core/game/audio/struct.rs
1use super::*;
2
3/// Individual spatialized audio playback command queued by game scenes.
4#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
5pub struct AudioCommand {
6 /// Sound cue identifier.
7 #[get(type(copy))]
8 pub(crate) cue: SoundCue,
9 /// Linear gain in `[0.0, 1.0]`.
10 #[get(type(copy))]
11 pub(crate) volume: f32,
12 /// Stereo pan in `[-1.0, 1.0]` (`0.0` = center).
13 #[get(type(copy))]
14 pub(crate) pan: f32,
15 /// Pitch multiplier (`1.0` = nominal playback speed).
16 #[get(type(copy))]
17 pub(crate) pitch: f32,
18}
19
20/// Cross-platform deterministic game audio mixer queue (bridged to WebAudio / CoreAudio / AAudio / WASAPI).
21#[derive(Clone, Data, Debug)]
22pub struct AudioBus {
23 /// Master gain in `[0.0, 1.0]`.
24 #[get(type(copy))]
25 pub(crate) master_volume: f32,
26 /// Global mute toggle.
27 #[get(type(copy))]
28 pub(crate) muted: bool,
29 /// Pending audio commands emitted during the current frame.
30 pub(crate) queue: Vec<AudioCommand>,
31 /// Cumulative sound commands triggered over the lifetime of the bus.
32 #[get(type(copy))]
33 pub(crate) total_played: u64,
34}
35
36/// 3D spatial audio listener pose derived from a `Camera3D` or player avatar.
37#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
38pub struct AudioListener3D {
39 /// Listener world position in meters.
40 #[get(type(copy))]
41 pub(crate) position: Vec3,
42 /// Listener linear velocity in meters/sec for Doppler shift.
43 #[get(type(copy))]
44 pub(crate) velocity: Vec3,
45 /// Unit listener right ear axis for stereo HRTF panning.
46 #[get(type(copy))]
47 pub(crate) right: Vec3,
48}
49
50/// 3D world-space sound emitter with distance rolloff and Doppler velocity.
51#[derive(Clone, Copy, Data, Debug, PartialEq)]
52pub struct SpatialAudioSource3D {
53 /// Sound cue identifier.
54 #[get(type(copy))]
55 pub(crate) cue: SoundCue,
56 /// Emitter world position in meters.
57 #[get(type(copy))]
58 pub(crate) position: Vec3,
59 /// Emitter linear velocity in meters/sec for Doppler shift.
60 #[get(type(copy))]
61 pub(crate) velocity: Vec3,
62 /// Nominal unattenuated gain `[0.0, 1.0]`.
63 #[get(type(copy))]
64 pub(crate) volume: f32,
65 /// Nominal playback pitch multiplier (`1.0` = unshifted).
66 #[get(type(copy))]
67 pub(crate) pitch: f32,
68 /// Reference distance in meters inside which gain stays at maximum.
69 #[get(type(copy))]
70 pub(crate) min_distance: f32,
71 /// Maximum audible radius in meters beyond which sound is culled.
72 #[get(type(copy))]
73 pub(crate) max_distance: f32,
74}