Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGhillie committed Sep 21, 2024
1 parent 18d1428 commit f57378b
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 39 deletions.
2 changes: 2 additions & 0 deletions crates/phonon-fmod/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/phonon-fmod/src/fmod_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions crates/phonon-fmod/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl Into<c_int> 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,
Expand Down
1 change: 1 addition & 0 deletions crates/phonon-fmod/src/parameter_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 0 additions & 10 deletions crates/phonon/src/direct_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion crates/phonon/src/eq_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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
Expand Down
17 changes: 0 additions & 17 deletions crates/phonon/src/hit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
}
}
}
2 changes: 1 addition & 1 deletion crates/phonon/src/iir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion crates/phonon/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/phonon/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion crates/phonon/src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec3>,
Expand Down
2 changes: 1 addition & 1 deletion crates/phonon/src/panning_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/phonon/src/reverb_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions crates/phonon/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -39,15 +39,15 @@ pub struct Scene {
//todo: Only static_meshes[0] should be serialized/deserialized.
pub(crate) static_meshes: [Vec<Arc<StaticMesh>>; 2],

#[cfg_attr(feature = "serde", serde(skip))]
#[cfg_attr(feature = "serde-serialize", serde(skip))]
pub(crate) instanced_meshes: [Vec<Arc<Mutex<InstancedMesh>>>; 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,
}

Expand Down
4 changes: 4 additions & 0 deletions crates/phonon/src/sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion crates/phonon/src/static_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>,
Expand Down
2 changes: 1 addition & 1 deletion crates/phonon/src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit f57378b

Please sign in to comment.