pub struct MathAudioSource {Show 14 fields
pub function: MathFunction,
pub frequency_range: (f32, f32),
pub amplitude: f32,
pub waveform: Waveform,
pub filter: Option<AudioFilter>,
pub position: Vec3,
pub filter2: Option<AudioFilter>,
pub tag: Option<String>,
pub lifetime: f32,
pub detune_cents: f32,
pub spatial: bool,
pub max_distance: f32,
pub fade_in: f32,
pub fade_out: f32,
}Expand description
A mathematical audio source — oscillator driven by a MathFunction.
Fields§
§function: MathFunctionThe function driving this source’s frequency/amplitude modulation.
frequency_range: (f32, f32)Maps function output [-1, 1] to Hz: (freq_at_neg1, freq_at_pos1).
amplitude: f32Base amplitude [0, 1].
waveform: WaveformWaveform shape.
filter: Option<AudioFilter>Optional filter chain.
position: Vec33D world position for stereo panning and distance attenuation.
filter2: Option<AudioFilter>Optional second filter (two-pole filtering).
tag: Option<String>Tag for grouping related sources (e.g. “chaos_rift”, “music”, “sfx”).
lifetime: f32Lifetime in seconds. -1.0 = infinite.
detune_cents: f32Frequency detune in cents (+100 = 1 semitone up).
spatial: boolWhether this source should spatialize (attenuate with distance from listener).
max_distance: f32Maximum distance for spatialization (beyond this = silent).
fade_in: f32Fade-in duration in seconds (0.0 = instant).
fade_out: f32Fade-out duration in seconds before lifetime ends (0.0 = instant).
Implementations§
Source§impl MathAudioSource
impl MathAudioSource
Sourcepub fn ambient_tone(freq: f32, amplitude: f32, position: Vec3) -> Self
pub fn ambient_tone(freq: f32, amplitude: f32, position: Vec3) -> Self
Sine tone driven by a breathing function (volume/pitch gently pulsates).
Sourcepub fn chaos_tone(position: Vec3) -> Self
pub fn chaos_tone(position: Vec3) -> Self
Lorenz-driven chaotic tone (for Chaos Rifts and high-entropy regions).
Sourcepub fn sweep(
freq_start: f32,
freq_end: f32,
period: f32,
position: Vec3,
) -> Self
pub fn sweep( freq_start: f32, freq_end: f32, period: f32, position: Vec3, ) -> Self
Sine sweep — frequency glides between two values over a period.
Sourcepub fn boss_drone(position: Vec3) -> Self
pub fn boss_drone(position: Vec3) -> Self
Low-frequency drone (sub-bass rumble for boss encounters).
Sourcepub fn death_knell(position: Vec3) -> Self
pub fn death_knell(position: Vec3) -> Self
Death knell — descending pitch with exponential decay.
Sourcepub fn electrical_crackle(position: Vec3, duration: f32) -> Self
pub fn electrical_crackle(position: Vec3, duration: f32) -> Self
Electrical crackle (noise burst for lightning effects).
Sourcepub fn attractor_tone(
attractor_scale: f32,
root_hz: f32,
position: Vec3,
) -> Self
pub fn attractor_tone( attractor_scale: f32, root_hz: f32, position: Vec3, ) -> Self
Attractor-driven harmonic resonance (entropic, alien, chaotic but musical).
Sourcepub fn wind(amplitude: f32) -> Self
pub fn wind(amplitude: f32) -> Self
Wind ambience (noise with slow modulation, for outdoor environments).
Sourcepub fn combat_pulse(position: Vec3, frequency_hz: f32) -> Self
pub fn combat_pulse(position: Vec3, frequency_hz: f32) -> Self
Combat pulse — rhythmic hit sound tied to gameplay events.
Sourcepub fn heartbeat(bpm: f32, position: Vec3) -> Self
pub fn heartbeat(bpm: f32, position: Vec3) -> Self
Heartbeat — pulsing low frequency with biological timing.
Sourcepub fn portal_hum(position: Vec3, frequency_hz: f32) -> Self
pub fn portal_hum(position: Vec3, frequency_hz: f32) -> Self
Portal hum — steady resonant tone for dimensional gateways.
pub fn with_tag(self, tag: impl Into<String>) -> Self
pub fn with_lifetime(self, secs: f32) -> Self
pub fn with_amplitude(self, amp: f32) -> Self
pub fn with_position(self, pos: Vec3) -> Self
pub fn with_detune(self, cents: f32) -> Self
pub fn non_spatial(self) -> Self
pub fn with_fade(self, fade_in: f32, fade_out: f32) -> Self
Sourcepub fn is_one_shot(&self) -> bool
pub fn is_one_shot(&self) -> bool
Whether this source is a one-shot (has a finite lifetime).
Sourcepub fn is_expired(&self, age: f32) -> bool
pub fn is_expired(&self, age: f32) -> bool
Whether this source has expired.
Sourcepub fn envelope(&self, age: f32) -> f32
pub fn envelope(&self, age: f32) -> f32
Envelope factor accounting for fade-in and fade-out at a given age.
Sourcepub fn map_to_frequency(&self, value: f32) -> f32
pub fn map_to_frequency(&self, value: f32) -> f32
Map a function output value in [-1, 1] to a frequency in Hz.
Trait Implementations§
Source§impl Clone for MathAudioSource
impl Clone for MathAudioSource
Source§fn clone(&self) -> MathAudioSource
fn clone(&self) -> MathAudioSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more