Skip to content

Commit

Permalink
Cleanup, change to glam 0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGhillie committed Sep 8, 2024
1 parent 81b5cf3 commit 4099abe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/phonon-fmod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["cdylib", "lib"]
[dependencies]
phonon = { path = "../phonon" }
libfmod = "~2.222.4"
glam = "0.25" # todo how do we ensure the same version is used accross the different crates in the workspace?
glam = "0.27" # todo how do we ensure the same version is used accross the different crates in the workspace?
strum = { version = "0.26", features = ["derive"] }

[[example]]
Expand Down
21 changes: 11 additions & 10 deletions crates/phonon-fmod/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub(crate) unsafe extern "C" fn create_callback(dsp_state: *mut FMOD_DSP_STATE)
// any time in the other callbacks.

let dsp_state_wrapped = FmodDspState::new(dsp_state);
//dsp_state_wrapped.log_message("testMessage");
let frame_size = dsp_state_wrapped.get_block_size().unwrap() as usize;
let sampling_rate = dsp_state_wrapped.get_sample_rate().unwrap();

Expand Down Expand Up @@ -88,7 +87,7 @@ pub(crate) unsafe extern "C" fn release_callback(dsp_state: *mut FMOD_DSP_STATE)
/// See FMOD_DSP_PROCESS_CALLBACK docs.
pub(crate) unsafe extern "C" fn process_callback(
dsp_state: *mut FMOD_DSP_STATE,
length: std::os::raw::c_uint,
length: c_uint,
in_buffer_array: *const FMOD_DSP_BUFFER_ARRAY,
out_buffer_array: *mut FMOD_DSP_BUFFER_ARRAY,
inputs_idle: FMOD_BOOL,
Expand All @@ -113,6 +112,8 @@ pub(crate) unsafe extern "C" fn process_callback(
let num_channels = *(*in_buffer_array).buffernumchannels as usize;
let num_samples = num_channels * length as usize;

// todo I think these can technically change at any time and that is currently
// not taken into account
let block_size = dsp_state.get_block_size().unwrap();
let sample_rate = dsp_state.get_sample_rate().unwrap();

Expand All @@ -133,11 +134,11 @@ pub(crate) unsafe extern "C" fn process_callback(

pub(crate) unsafe extern "C" fn set_float_callback(
dsp_state: *mut FMOD_DSP_STATE,
index: c_int,
value: c_float,
_index: c_int,
_value: c_float,
) -> FMOD_RESULT {
let state: *mut EffectState = (*dsp_state).plugindata as *mut EffectState;
let state = state.as_mut().unwrap();
let _state = state.as_mut().unwrap();

FMOD_OK
}
Expand All @@ -149,7 +150,7 @@ pub(crate) unsafe extern "C" fn get_float_callback(
_value_str: *mut c_char,
) -> FMOD_RESULT {
let state: *mut EffectState = (*dsp_state).plugindata as *mut EffectState;
let state = state.as_mut().unwrap();
let _state = state.as_mut().unwrap();

FMOD_OK
}
Expand Down Expand Up @@ -194,13 +195,13 @@ pub(crate) unsafe extern "C" fn set_data_callback(

pub(crate) unsafe extern "C" fn get_data_callback(
dsp_state: *mut FMOD_DSP_STATE,
index: c_int,
data: *mut *mut c_void,
length: *mut c_uint,
_index: c_int,
_data: *mut *mut c_void,
_length: *mut c_uint,
_valuestr: *mut c_char,
) -> FMOD_RESULT {
let dsp_state_wrapped = FmodDspState::new(dsp_state);
let effect = dsp_state_wrapped.get_effect_state();
let _effect = dsp_state_wrapped.get_effect_state();

FMOD_OK
}
Expand Down
14 changes: 9 additions & 5 deletions crates/phonon-fmod/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pub(crate) mod callbacks;
mod fmod_state;
mod parameter_init;
mod parameter_spec;
pub mod parameter_spec;

use crate::callbacks::{
create_callback, get_data_callback, get_int_callback, process_callback, release_callback,
Expand Down Expand Up @@ -118,22 +118,26 @@ impl EffectState {
length: usize,
channels: usize,
) {
let num_samples = length * channels;
let _num_samples = length * channels;

// update parameters
let position = self.source.relative.position;
let direction = Vec3::new(position.x, position.y, position.z);
let panning_params = PanningEffectParameters { direction };

let mut flags = DirectApplyFlags::AirAbsorption;
let mut flags = DirectApplyFlags::AirAbsorption
| DirectApplyFlags::Occlusion
| DirectApplyFlags::Transmission;

match self.apply_distance_attenuation {
ParameterApplyType::Disable => flags.set(DirectApplyFlags::DistanceAttenuation, false),
ParameterApplyType::SimulationDefined => {
flags.set(DirectApplyFlags::DistanceAttenuation, true)
}
ParameterApplyType::UserDefined => {
// todo
flags.set(DirectApplyFlags::DistanceAttenuation, true)
} // todo
}
}

let direct_params = DirectEffectParameters {
Expand All @@ -160,7 +164,7 @@ pub fn create_dsp_description() -> DspDescription {
DspDescription {
pluginsdkversion: FMOD_PLUGIN_SDK_VERSION,
name: str_to_c_char_array("Phonon Spatializer"),
version: 2,
version: 1,
numinputbuffers: 1,
numoutputbuffers: 1,
create: Some(create_callback),
Expand Down
4 changes: 2 additions & 2 deletions crates/phonon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ serde-serialize = ["dep:serde", "parry3d/serde-serialize", "ndarray/serde"]

[dependencies]
derive_deref = "1"
glam = "0.25"
glam = "0.27"
biquad = "0.4"
rand = "0.8"
ndarray = "0.15"
parry3d = "0.13" # todo: Enable SIMD? Replace with glam-based parry?
nalgebra = { version = "0.32", features = ["default", "convert-glam025"] } # todo: Replace with glam after replacing parry3d
nalgebra = { version = "0.32", features = ["default", "convert-glam027"] } # todo: Replace with glam after replacing parry3d
bitflags = "2"
ultraviolet = "0.9"
serde = {version = "1", optional = true}
Expand Down

0 comments on commit 4099abe

Please sign in to comment.