configurable sample rate for fyrox-sound

This commit is contained in:
Dmitry Stepanov
2026-04-08 22:59:04 +03:00
parent 1c18ee7c92
commit a4df8a1301
15 changed files with 156 additions and 116 deletions
+11 -1
View File
@@ -315,7 +315,6 @@ pub struct Engine {
model_events_receiver: Receiver<ResourceEvent>,
#[allow(dead_code)] // Keep engine instance alive.
sound_engine: SoundEngine,
// A set of plugins used by the engine.
@@ -1501,6 +1500,17 @@ impl Engine {
}
}
/// Returns current sample rate of the sound engine.
pub fn sound_sample_rate(&self) -> u32 {
self.sound_engine.sample_rate()
}
/// Normalizes given frequency using sampling rate of the sound output device. Normalized frequency
/// then can be used to create filters.
pub fn normalize_sound_frequency(&self, f: f32) -> f32 {
self.sound_engine.normalize_frequency(f)
}
/// Tries to destroy current graphics context. It will succeed only if the `graphics_context` is fully initialized.
/// The method will try to save all possible runtime changes of the window, so the next [`Engine::initialize_graphics_context`]
/// will result in the almost exact copy of the context that was made before destruction.
-6
View File
@@ -80,12 +80,6 @@ impl SoundContextGuard<'_> {
self.guard.distance_model()
}
/// Normalizes given frequency using context's sampling rate. Normalized frequency then can be used
/// to create filters.
pub fn normalize_frequency(&self, f: f32) -> f32 {
self.guard.normalize_frequency(f)
}
/// Returns amount of time context spent on rendering all sound sources.
pub fn full_render_duration(&self) -> Duration {
self.guard.full_render_duration()
+1 -1
View File
@@ -47,7 +47,7 @@ pub use fyrox_sound::{
DataSource, SoundBuffer, SoundBufferResource, SoundBufferResourceLoadError,
},
bus::*,
context::{DistanceModel, SAMPLE_RATE},
context::DistanceModel,
dsp::{filters::*, DelayLine},
effects::*,
engine::SoundEngine,