diff --git a/src/sound.rs b/src/sound.rs index 8911ad8..c2722d9 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -20,6 +20,7 @@ pub struct Footstep { pub reference_distance: f32, pub max_distance: f32, pub rolloff_factor: f32, + pub pitch: f32, pub pitch_variation: Option, } @@ -32,6 +33,7 @@ impl Default for Footstep { reference_distance: 1., max_distance: f32::MAX, rolloff_factor: 1., + pitch: 1., pitch_variation: Some(0.15), } } @@ -113,8 +115,9 @@ fn footstep( sound.reference_distance = footstep.reference_distance; sound.max_distance = footstep.max_distance; sound.rolloff_factor = footstep.rolloff_factor; + sound.pitch = footstep.pitch; if let Some(pitch_variation) = footstep.pitch_variation { - let mut pitch = 1. - pitch_variation / 2.; + let mut pitch = footstep.pitch - pitch_variation / 2.; pitch += random::() * pitch_variation; sound.pitch = pitch; }