From f57378b627b9aea63b650176b304cefc19267aae Mon Sep 17 00:00:00 2001 From: GitGhillie Date: Sat, 21 Sep 2024 15:26:46 +0200 Subject: [PATCH] Cleanup --- crates/phonon-fmod/src/callbacks.rs | 2 ++ crates/phonon-fmod/src/fmod_state.rs | 1 + crates/phonon-fmod/src/lib.rs | 1 + crates/phonon-fmod/src/parameter_init.rs | 1 + crates/phonon/src/direct_simulator.rs | 10 ---------- crates/phonon/src/eq_effect.rs | 4 +++- crates/phonon/src/hit.rs | 17 ----------------- crates/phonon/src/iir.rs | 2 +- crates/phonon/src/lib.rs | 2 +- crates/phonon/src/material.rs | 2 +- crates/phonon/src/mesh.rs | 2 +- crates/phonon/src/panning_effect.rs | 2 +- crates/phonon/src/reverb_effect.rs | 1 + crates/phonon/src/scene.rs | 8 ++++---- crates/phonon/src/sphere.rs | 4 ++++ crates/phonon/src/static_mesh.rs | 2 +- crates/phonon/src/triangle.rs | 2 +- 17 files changed, 24 insertions(+), 39 deletions(-) diff --git a/crates/phonon-fmod/src/callbacks.rs b/crates/phonon-fmod/src/callbacks.rs index 537ff56..8ea1329 100644 --- a/crates/phonon-fmod/src/callbacks.rs +++ b/crates/phonon-fmod/src/callbacks.rs @@ -143,6 +143,7 @@ pub(crate) unsafe extern "C" fn process_callback( // todo: Check if all set and get callbacks return FMOD_ERR_INVALID_PARAM when the index is unknown +#[expect(dead_code, reason = "No float params have been added yet")] pub(crate) unsafe extern "C" fn set_float_callback( dsp_state: *mut FMOD_DSP_STATE, _index: c_int, @@ -154,6 +155,7 @@ pub(crate) unsafe extern "C" fn set_float_callback( FMOD_OK } +#[expect(dead_code, reason = "No float params have been added yet")] pub(crate) unsafe extern "C" fn get_float_callback( dsp_state: *mut FMOD_DSP_STATE, _index: c_int, diff --git a/crates/phonon-fmod/src/fmod_state.rs b/crates/phonon-fmod/src/fmod_state.rs index 5baf694..5cb764f 100644 --- a/crates/phonon-fmod/src/fmod_state.rs +++ b/crates/phonon-fmod/src/fmod_state.rs @@ -46,6 +46,7 @@ impl FmodDspState { } } + #[expect(dead_code, reason = "Not sure yet how this works")] pub(crate) unsafe fn log_message(&self, message: &'static str) { let functions = (*self.0).functions; let log_fn = (*functions).log.unwrap(); diff --git a/crates/phonon-fmod/src/lib.rs b/crates/phonon-fmod/src/lib.rs index 0d9a4e9..4f376e7 100644 --- a/crates/phonon-fmod/src/lib.rs +++ b/crates/phonon-fmod/src/lib.rs @@ -71,6 +71,7 @@ impl Into for ParameterApplyType { } } +#[expect(dead_code, reason = "Not everything is implemented yet")] pub(crate) struct EffectState { source: FMOD_DSP_PARAMETER_3DATTRIBUTES, overall_gain: FMOD_DSP_PARAMETER_OVERALLGAIN, diff --git a/crates/phonon-fmod/src/parameter_init.rs b/crates/phonon-fmod/src/parameter_init.rs index c7bda98..b5ed016 100644 --- a/crates/phonon-fmod/src/parameter_init.rs +++ b/crates/phonon-fmod/src/parameter_init.rs @@ -41,6 +41,7 @@ fn create_param_data( } } +#[expect(dead_code, reason = "No float params have been added yet")] fn create_param_float(name: &str, description: &'static str) -> DspParameterDesc { DspParameterDesc { type_: DspParameterType::Float, diff --git a/crates/phonon/src/direct_simulator.rs b/crates/phonon/src/direct_simulator.rs index b7e0554..3a8b37b 100644 --- a/crates/phonon/src/direct_simulator.rs +++ b/crates/phonon/src/direct_simulator.rs @@ -28,16 +28,6 @@ use crate::scene::Scene; use crate::sphere::Sphere; use glam::Vec3; -// todo: Remove in favor of DirectApplyFlags? -enum DirectSimulationType { - CalcDistanceAttenuation, - CalcAirAbsorption, - CalcDirectivity, - CalcOcclusion, - CalcTransmission, - CalcDelay, -} - pub enum OcclusionType { Raycast, Volumetric, diff --git a/crates/phonon/src/eq_effect.rs b/crates/phonon/src/eq_effect.rs index 0b8ef7a..db9513e 100644 --- a/crates/phonon/src/eq_effect.rs +++ b/crates/phonon/src/eq_effect.rs @@ -108,9 +108,10 @@ impl EqEffect { self.apply_filter_cascade(self.current, &input[0], &mut output[0]); } - return AudioEffectState::TailComplete; + AudioEffectState::TailComplete } + #[expect(dead_code, reason = "Used in HybridReverbEffect, not ported yet")] fn tail_apply( &mut self, input: &AudioBuffer<1>, @@ -125,6 +126,7 @@ impl EqEffect { ) } + #[expect(dead_code, reason = "Used in HybridReverbEffect, not ported yet")] fn tail(output: &mut AudioBuffer<1>) -> AudioEffectState { output.make_silent(); AudioEffectState::TailComplete diff --git a/crates/phonon/src/hit.rs b/crates/phonon/src/hit.rs index 3c37248..1964679 100644 --- a/crates/phonon/src/hit.rs +++ b/crates/phonon/src/hit.rs @@ -27,20 +27,3 @@ pub(crate) struct Hit { pub(crate) normal: Vec3, pub(crate) material: Material, } - -impl Hit { - pub(crate) fn new_empty() -> Self { - Self { - distance: f32::MAX, - triangle_index: 0, - object_index: 0, - material_index: 0, - normal: Default::default(), - material: Material { - absorption: [0.0, 0.0, 0.0], - scattering: 0.0, - transmission: [0.0, 0.0, 0.0], - }, - } - } -} diff --git a/crates/phonon/src/iir.rs b/crates/phonon/src/iir.rs index e2adff9..94a3ef1 100644 --- a/crates/phonon/src/iir.rs +++ b/crates/phonon/src/iir.rs @@ -135,7 +135,7 @@ impl IIRFilterer { } /// Applies the filter to an entire buffer of input, using SIMD operations. - pub fn apply(&mut self, size: usize, input: &[f32], output: &mut [f32]) { + pub fn apply(&mut self, _size: usize, input: &[f32], output: &mut [f32]) { //todo: Temporary implementation, no SIMD optimizations yet //todo: Can panic for i in 0..input.len() { diff --git a/crates/phonon/src/lib.rs b/crates/phonon/src/lib.rs index fddb537..dc73373 100644 --- a/crates/phonon/src/lib.rs +++ b/crates/phonon/src/lib.rs @@ -1,6 +1,6 @@ //! A community effort to rewrite Valve's Steam Audio into a Rust library. -#[cfg(feature = "serde")] +#[cfg(feature = "serde-serialize")] #[macro_use] extern crate serde; diff --git a/crates/phonon/src/material.rs b/crates/phonon/src/material.rs index 303d75a..f4a49f3 100644 --- a/crates/phonon/src/material.rs +++ b/crates/phonon/src/material.rs @@ -20,7 +20,7 @@ use crate::bands::NUM_BANDS; /// An acoustic material. The acoustic surface properties of an object are represented using multi-band absorption /// and transmission loss coefficients, and a single random-incidence scattering coefficient. /// All values are in the 0.0 to 1.0 range. -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Copy, Clone, Debug, PartialEq)] pub struct Material { pub absorption: [f32; NUM_BANDS], diff --git a/crates/phonon/src/mesh.rs b/crates/phonon/src/mesh.rs index 017f0e1..40a2a77 100644 --- a/crates/phonon/src/mesh.rs +++ b/crates/phonon/src/mesh.rs @@ -23,7 +23,7 @@ use parry3d::shape::TriMesh; /// A triangle mesh. Vertices are stored in a contiguous array, and the triangles are stored in indexed form. Each /// triangle requires three indices to store (i.e., strip or fan representations are not supported). -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub struct Mesh { pub(crate) mesh: TriMesh, normals: Array1, diff --git a/crates/phonon/src/panning_effect.rs b/crates/phonon/src/panning_effect.rs index cc4daa3..37fdba2 100644 --- a/crates/phonon/src/panning_effect.rs +++ b/crates/phonon/src/panning_effect.rs @@ -96,7 +96,7 @@ impl PanningEffect { direction: Vec3, speaker_layout: &SpeakerLayout, index: usize, - panning_data: &PanningData, + _panning_data: &PanningData, // todo: Can't this be based on the SpeakerLayout? ) -> f32 { match speaker_layout.layout_type { SpeakerLayoutType::Mono => 1.0, diff --git a/crates/phonon/src/reverb_effect.rs b/crates/phonon/src/reverb_effect.rs index 5988c92..e32c4db 100644 --- a/crates/phonon/src/reverb_effect.rs +++ b/crates/phonon/src/reverb_effect.rs @@ -51,6 +51,7 @@ pub struct ReverbEffect { num_tail_frames_remaining: i32, } +#[expect(dead_code, reason = "ReverbEffect is a WIP")] impl ReverbEffect { pub fn new(audio_settings: AudioSettings) -> Self { let delay_values = Self::calc_delays_for_reverb_time(2.0, audio_settings.sampling_rate); diff --git a/crates/phonon/src/scene.rs b/crates/phonon/src/scene.rs index 7bd2336..620ce62 100644 --- a/crates/phonon/src/scene.rs +++ b/crates/phonon/src/scene.rs @@ -29,7 +29,7 @@ use std::sync::{Arc, Mutex}; /// Objects can be added and removed from the scene at any time. /// Objects can also be defined as instances of one another. /// This class also allows rays to be traced through the scene. -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub struct Scene { /// Two lists of static meshes. The one at index 0 is used internally while /// the one at index 1 can be changed by the user through `add_static_mesh` @@ -39,15 +39,15 @@ pub struct Scene { //todo: Only static_meshes[0] should be serialized/deserialized. pub(crate) static_meshes: [Vec>; 2], - #[cfg_attr(feature = "serde", serde(skip))] + #[cfg_attr(feature = "serde-serialize", serde(skip))] pub(crate) instanced_meshes: [Vec>>; 2], /// Flag indicating whether the scene has changed in some way since the previous call to commit(). - #[cfg_attr(feature = "serde", serde(skip))] + #[cfg_attr(feature = "serde-serialize", serde(skip))] has_changed: bool, /// The change version of the scene. - #[cfg_attr(feature = "serde", serde(skip))] + #[cfg_attr(feature = "serde-serialize", serde(skip))] change_version: u32, } diff --git a/crates/phonon/src/sphere.rs b/crates/phonon/src/sphere.rs index 6e9351f..0fe1145 100644 --- a/crates/phonon/src/sphere.rs +++ b/crates/phonon/src/sphere.rs @@ -27,6 +27,10 @@ impl Sphere { Self { center, radius } } + #[expect( + dead_code, + reason = "Features that use this have not been implemented yet" + )] pub(crate) fn contains(&self, point: Vec3) -> bool { (point - self.center).length_squared() <= self.radius * self.radius } diff --git a/crates/phonon/src/static_mesh.rs b/crates/phonon/src/static_mesh.rs index bcaa007..d989d44 100644 --- a/crates/phonon/src/static_mesh.rs +++ b/crates/phonon/src/static_mesh.rs @@ -26,7 +26,7 @@ use parry3d::query::RayCast; /// A static triangle mesh. The geometry of this mesh is assumed to never change at runtime. It is described in /// world-space coordinates. Materials are specified for each triangle. -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub struct StaticMesh { mesh: Mesh, material_indices: Array1, diff --git a/crates/phonon/src/triangle.rs b/crates/phonon/src/triangle.rs index 2fc5848..28224be 100644 --- a/crates/phonon/src/triangle.rs +++ b/crates/phonon/src/triangle.rs @@ -16,7 +16,7 @@ // /// An indexed triangle, which can only be interpreted relative to a vertex buffer. -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Copy, Clone)] pub struct Triangle { pub indices: [usize; 3],