From cb50ecb70d441eea5157ea7eceac32ce9c5d2cbe Mon Sep 17 00:00:00 2001 From: GitGhillie Date: Sun, 22 Sep 2024 10:41:07 +0200 Subject: [PATCH 1/3] Organize core --- crates/phonon-fmod/examples/create_dsp.rs | 2 +- crates/phonon-fmod/src/callbacks.rs | 10 +++---- crates/phonon-fmod/src/lib.rs | 8 ++--- crates/phonon-kira/examples/direct_effect.rs | 4 +-- crates/phonon-kira/examples/reverb_effect.rs | 4 +-- .../phonon-kira/src/direct_effect/builder.rs | 4 +-- .../phonon-kira/src/direct_effect/effect.rs | 8 ++--- .../phonon-kira/src/direct_effect/handle.rs | 4 +-- crates/phonon-kira/src/direct_effect/mod.rs | 4 +-- crates/phonon-kira/src/eq_effect/effect.rs | 6 ++-- .../phonon-kira/src/reverb_effect/effect.rs | 6 ++-- crates/phonon/benches/audio_buffer_bench.rs | 2 +- crates/phonon/benches/direct_effect_bench.rs | 6 ++-- crates/phonon/benches/panning_bench.rs | 6 ++-- crates/phonon/benches/reverb_bench.rs | 6 ++-- crates/phonon/src/{ => dsp}/audio_buffer.rs | 0 crates/phonon/src/{ => dsp}/bands.rs | 0 crates/phonon/src/{ => dsp}/delay.rs | 2 +- crates/phonon/src/{ => dsp}/iir.rs | 0 crates/phonon/src/dsp/mod.rs | 8 +++++ .../phonon/src/{ => dsp}/reverb_estimator.rs | 2 +- crates/phonon/src/{ => dsp}/speaker_layout.rs | 0 .../phonon/src/{ => effects}/direct_effect.rs | 10 +++---- crates/phonon/src/{ => effects}/eq_effect.rs | 6 ++-- .../phonon/src/{ => effects}/gain_effect.rs | 2 +- crates/phonon/src/effects/mod.rs | 8 +++++ .../src/{ => effects}/panning_effect.rs | 4 +-- .../phonon/src/{ => effects}/reverb_effect.rs | 10 +++---- crates/phonon/src/lib.rs | 30 +++---------------- .../phonon/src/{ => models}/air_absorption.rs | 2 +- crates/phonon/src/{ => models}/directivity.rs | 2 +- .../src/{ => models}/distance_attenuation.rs | 0 crates/phonon/src/models/mod.rs | 7 +++++ .../src/{ => models}/propagation_medium.rs | 0 .../src/{ => scene}/coordinate_space.rs | 0 crates/phonon/src/{ => scene}/hit.rs | 2 +- .../phonon/src/{ => scene}/instanced_mesh.rs | 4 +-- crates/phonon/src/{ => scene}/material.rs | 2 +- crates/phonon/src/{ => scene}/mesh.rs | 2 +- crates/phonon/src/scene/mod.rs | 15 ++++++++++ crates/phonon/src/{ => scene}/ray.rs | 0 crates/phonon/src/{ => scene}/sampling.rs | 2 +- crates/phonon/src/{ => scene}/scene.rs | 14 ++++----- crates/phonon/src/{ => scene}/sphere.rs | 0 crates/phonon/src/{ => scene}/static_mesh.rs | 10 +++---- crates/phonon/src/{ => scene}/triangle.rs | 0 .../src/{ => simulators}/direct_simulator.rs | 20 ++++++------- crates/phonon/src/simulators/mod.rs | 4 +++ crates/phonon/tests/audio_buffer_test.rs | 2 +- crates/phonon/tests/coordinate_space_test.rs | 2 +- crates/phonon/tests/iir_filter_test.rs | 2 +- crates/phonon/tests/triangle.rs | 4 +-- 52 files changed, 139 insertions(+), 119 deletions(-) rename crates/phonon/src/{ => dsp}/audio_buffer.rs (100%) rename crates/phonon/src/{ => dsp}/bands.rs (100%) rename crates/phonon/src/{ => dsp}/delay.rs (99%) rename crates/phonon/src/{ => dsp}/iir.rs (100%) create mode 100644 crates/phonon/src/dsp/mod.rs rename crates/phonon/src/{ => dsp}/reverb_estimator.rs (96%) rename crates/phonon/src/{ => dsp}/speaker_layout.rs (100%) rename crates/phonon/src/{ => effects}/direct_effect.rs (95%) rename crates/phonon/src/{ => effects}/eq_effect.rs (97%) rename crates/phonon/src/{ => effects}/gain_effect.rs (97%) create mode 100644 crates/phonon/src/effects/mod.rs rename crates/phonon/src/{ => effects}/panning_effect.rs (96%) rename crates/phonon/src/{ => effects}/reverb_effect.rs (98%) rename crates/phonon/src/{ => models}/air_absorption.rs (97%) rename crates/phonon/src/{ => models}/directivity.rs (96%) rename crates/phonon/src/{ => models}/distance_attenuation.rs (100%) create mode 100644 crates/phonon/src/models/mod.rs rename crates/phonon/src/{ => models}/propagation_medium.rs (100%) rename crates/phonon/src/{ => scene}/coordinate_space.rs (100%) rename crates/phonon/src/{ => scene}/hit.rs (96%) rename crates/phonon/src/{ => scene}/instanced_mesh.rs (98%) rename crates/phonon/src/{ => scene}/material.rs (97%) rename crates/phonon/src/{ => scene}/mesh.rs (98%) create mode 100644 crates/phonon/src/scene/mod.rs rename crates/phonon/src/{ => scene}/ray.rs (100%) rename crates/phonon/src/{ => scene}/sampling.rs (98%) rename crates/phonon/src/{ => scene}/scene.rs (96%) rename crates/phonon/src/{ => scene}/sphere.rs (100%) rename crates/phonon/src/{ => scene}/static_mesh.rs (97%) rename crates/phonon/src/{ => scene}/triangle.rs (100%) rename crates/phonon/src/{ => simulators}/direct_simulator.rs (96%) create mode 100644 crates/phonon/src/simulators/mod.rs diff --git a/crates/phonon-fmod/examples/create_dsp.rs b/crates/phonon-fmod/examples/create_dsp.rs index f978cd6..a1464ea 100644 --- a/crates/phonon-fmod/examples/create_dsp.rs +++ b/crates/phonon-fmod/examples/create_dsp.rs @@ -9,7 +9,7 @@ use libfmod::ffi::{ FMOD_VECTOR, }; use libfmod::{Error, System}; -use phonon::direct_simulator::DirectSoundPath; +use phonon::simulators::direct_simulator::DirectSoundPath; use phonon_fmod::create_dsp_description; use std::io; use std::io::BufRead; diff --git a/crates/phonon-fmod/src/callbacks.rs b/crates/phonon-fmod/src/callbacks.rs index 4bc616a..df6a61b 100644 --- a/crates/phonon-fmod/src/callbacks.rs +++ b/crates/phonon-fmod/src/callbacks.rs @@ -8,11 +8,11 @@ use libfmod::ffi::{ FMOD_DSP_STATE, FMOD_ERR_DSP_DONTPROCESS, FMOD_ERR_INVALID_PARAM, FMOD_ERR_MEMORY, FMOD_OK, FMOD_RESULT, FMOD_SPEAKERMODE_STEREO, }; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::direct_effect::{DirectEffect, TransmissionType}; -use phonon::direct_simulator::DirectSoundPath; -use phonon::panning_effect::PanningEffect; -use phonon::speaker_layout::SpeakerLayoutType; +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::dsp::speaker_layout::SpeakerLayoutType; +use phonon::effects::direct_effect::{DirectEffect, TransmissionType}; +use phonon::effects::panning_effect::PanningEffect; +use phonon::simulators::direct_simulator::DirectSoundPath; use std::os::raw::{c_char, c_float, c_int, c_uint, c_void}; use std::ptr::{null_mut, slice_from_raw_parts_mut}; use std::slice; diff --git a/crates/phonon-fmod/src/lib.rs b/crates/phonon-fmod/src/lib.rs index 4f376e7..26921c6 100644 --- a/crates/phonon-fmod/src/lib.rs +++ b/crates/phonon-fmod/src/lib.rs @@ -33,12 +33,12 @@ use libfmod::ffi::{ FMOD_DSP_PARAMETER_ATTENUATION_RANGE, FMOD_DSP_PARAMETER_OVERALLGAIN, FMOD_PLUGIN_SDK_VERSION, }; use libfmod::DspDescription; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::direct_effect::{ +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::effects::direct_effect::{ DirectApplyFlags, DirectEffect, DirectEffectParameters, TransmissionType, }; -use phonon::direct_simulator::DirectSoundPath; -use phonon::panning_effect::{PanningEffect, PanningEffectParameters}; +use phonon::effects::panning_effect::{PanningEffect, PanningEffectParameters}; +use phonon::simulators::direct_simulator::DirectSoundPath; use std::ffi::CString; use std::os::raw::{c_char, c_int}; use std::ptr::null_mut; diff --git a/crates/phonon-kira/examples/direct_effect.rs b/crates/phonon-kira/examples/direct_effect.rs index 5fdcb3a..484175d 100644 --- a/crates/phonon-kira/examples/direct_effect.rs +++ b/crates/phonon-kira/examples/direct_effect.rs @@ -4,8 +4,8 @@ use kira::manager::backend::cpal::CpalBackend; use kira::manager::{AudioManager, AudioManagerSettings}; use kira::sound::static_sound::StaticSoundData; use kira::track::TrackBuilder; -use phonon::direct_effect::{DirectApplyFlags, DirectEffectParameters, TransmissionType}; -use phonon::direct_simulator::DirectSoundPath; +use phonon::effects::direct_effect::{DirectApplyFlags, DirectEffectParameters, TransmissionType}; +use phonon::simulators::direct_simulator::DirectSoundPath; use phonon_kira::direct_effect::builder::DirectEffectBuilder; diff --git a/crates/phonon-kira/examples/reverb_effect.rs b/crates/phonon-kira/examples/reverb_effect.rs index dbd4c42..60074bc 100644 --- a/crates/phonon-kira/examples/reverb_effect.rs +++ b/crates/phonon-kira/examples/reverb_effect.rs @@ -4,8 +4,8 @@ use kira::manager::backend::cpal::CpalBackend; use kira::manager::{AudioManager, AudioManagerSettings}; use kira::sound::static_sound::StaticSoundData; use kira::track::TrackBuilder; -use phonon::reverb_effect::ReverbEffectParams; -use phonon::reverb_estimator::Reverb; +use phonon::dsp::reverb_estimator::Reverb; +use phonon::effects::reverb_effect::ReverbEffectParams; use phonon_kira::reverb_effect::builder::ReverbEffectBuilder; diff --git a/crates/phonon-kira/src/direct_effect/builder.rs b/crates/phonon-kira/src/direct_effect/builder.rs index 298055b..2932755 100644 --- a/crates/phonon-kira/src/direct_effect/builder.rs +++ b/crates/phonon-kira/src/direct_effect/builder.rs @@ -2,8 +2,8 @@ use super::command_writers_and_readers; use super::effect::DirectEffectWrapped; use super::handle::DirectEffectHandle; use kira::effect::{Effect, EffectBuilder}; -use phonon::direct_effect::DirectEffectParameters; -use phonon::panning_effect::PanningEffectParameters; +use phonon::effects::direct_effect::DirectEffectParameters; +use phonon::effects::panning_effect::PanningEffectParameters; #[derive(Debug, Copy, Clone)] pub struct DirectEffectBuilder { diff --git a/crates/phonon-kira/src/direct_effect/effect.rs b/crates/phonon-kira/src/direct_effect/effect.rs index 1513b29..eb38569 100644 --- a/crates/phonon-kira/src/direct_effect/effect.rs +++ b/crates/phonon-kira/src/direct_effect/effect.rs @@ -4,10 +4,10 @@ use kira::clock::clock_info::ClockInfoProvider; use kira::effect::Effect; use kira::modulator::value_provider::ModulatorValueProvider; use kira::Frame; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::direct_effect::{DirectEffect, DirectEffectParameters}; -use phonon::panning_effect::{PanningEffect, PanningEffectParameters}; -use phonon::speaker_layout::SpeakerLayoutType; +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::dsp::speaker_layout::SpeakerLayoutType; +use phonon::effects::direct_effect::{DirectEffect, DirectEffectParameters}; +use phonon::effects::panning_effect::{PanningEffect, PanningEffectParameters}; pub(crate) struct DirectEffectWrapped { command_readers: CommandReaders, diff --git a/crates/phonon-kira/src/direct_effect/handle.rs b/crates/phonon-kira/src/direct_effect/handle.rs index b636a3a..c6d36ae 100644 --- a/crates/phonon-kira/src/direct_effect/handle.rs +++ b/crates/phonon-kira/src/direct_effect/handle.rs @@ -1,6 +1,6 @@ use super::CommandWriters; -use phonon::direct_effect::DirectEffectParameters; -use phonon::panning_effect::PanningEffectParameters; +use phonon::effects::direct_effect::DirectEffectParameters; +use phonon::effects::panning_effect::PanningEffectParameters; /// Controls an EQ effect. pub struct DirectEffectHandle { diff --git a/crates/phonon-kira/src/direct_effect/mod.rs b/crates/phonon-kira/src/direct_effect/mod.rs index c7ca66f..e1d8e59 100644 --- a/crates/phonon-kira/src/direct_effect/mod.rs +++ b/crates/phonon-kira/src/direct_effect/mod.rs @@ -1,6 +1,6 @@ use kira::command::{CommandReader, CommandWriter}; -use phonon::direct_effect::DirectEffectParameters; -use phonon::panning_effect::PanningEffectParameters; +use phonon::effects::direct_effect::DirectEffectParameters; +use phonon::effects::panning_effect::PanningEffectParameters; pub mod builder; pub(crate) mod effect; diff --git a/crates/phonon-kira/src/eq_effect/effect.rs b/crates/phonon-kira/src/eq_effect/effect.rs index f833b3c..a1e0042 100644 --- a/crates/phonon-kira/src/eq_effect/effect.rs +++ b/crates/phonon-kira/src/eq_effect/effect.rs @@ -4,9 +4,9 @@ use kira::clock::clock_info::ClockInfoProvider; use kira::effect::Effect; use kira::modulator::value_provider::ModulatorValueProvider; use kira::Frame; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::eq_effect::{EqEffect, EqEffectParameters}; -use phonon::gain_effect::{GainEffect, GainEffectParameters}; +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::effects::eq_effect::{EqEffect, EqEffectParameters}; +use phonon::effects::gain_effect::{GainEffect, GainEffectParameters}; pub(crate) struct EqEffectWrapped { command_readers: CommandReaders, diff --git a/crates/phonon-kira/src/reverb_effect/effect.rs b/crates/phonon-kira/src/reverb_effect/effect.rs index 94c6405..e53ec48 100644 --- a/crates/phonon-kira/src/reverb_effect/effect.rs +++ b/crates/phonon-kira/src/reverb_effect/effect.rs @@ -4,9 +4,9 @@ use kira::clock::clock_info::ClockInfoProvider; use kira::effect::Effect; use kira::modulator::value_provider::ModulatorValueProvider; use kira::Frame; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::reverb_effect::{ReverbEffect, ReverbEffectParams}; -use phonon::reverb_estimator::Reverb; +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::dsp::reverb_estimator::Reverb; +use phonon::effects::reverb_effect::{ReverbEffect, ReverbEffectParams}; pub(crate) struct ReverbEffectWrapped { command_readers: CommandReaders, diff --git a/crates/phonon/benches/audio_buffer_bench.rs b/crates/phonon/benches/audio_buffer_bench.rs index 187a3ab..5a36cd7 100644 --- a/crates/phonon/benches/audio_buffer_bench.rs +++ b/crates/phonon/benches/audio_buffer_bench.rs @@ -1,5 +1,5 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use phonon::audio_buffer::AudioBuffer; +use phonon::dsp::audio_buffer::AudioBuffer; fn mix_buffers(in1: AudioBuffer<1>) -> AudioBuffer<1> { let mut in2: AudioBuffer<1> = AudioBuffer::new(200); diff --git a/crates/phonon/benches/direct_effect_bench.rs b/crates/phonon/benches/direct_effect_bench.rs index 3aee393..f372cb7 100644 --- a/crates/phonon/benches/direct_effect_bench.rs +++ b/crates/phonon/benches/direct_effect_bench.rs @@ -16,11 +16,11 @@ // use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::direct_effect::{ +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::effects::direct_effect::{ DirectApplyFlags, DirectEffect, DirectEffectParameters, TransmissionType, }; -use phonon::direct_simulator::DirectSoundPath; +use phonon::simulators::direct_simulator::DirectSoundPath; use rand::Rng; pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/crates/phonon/benches/panning_bench.rs b/crates/phonon/benches/panning_bench.rs index 42fc448..5597c98 100644 --- a/crates/phonon/benches/panning_bench.rs +++ b/crates/phonon/benches/panning_bench.rs @@ -20,9 +20,9 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use glam::Vec3; -use phonon::audio_buffer::AudioBuffer; -use phonon::panning_effect::{PanningEffect, PanningEffectParameters}; -use phonon::speaker_layout::SpeakerLayoutType; +use phonon::dsp::audio_buffer::AudioBuffer; +use phonon::dsp::speaker_layout::SpeakerLayoutType; +use phonon::effects::panning_effect::{PanningEffect, PanningEffectParameters}; use rand::Rng; pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/crates/phonon/benches/reverb_bench.rs b/crates/phonon/benches/reverb_bench.rs index 234c39c..f6fb6a6 100644 --- a/crates/phonon/benches/reverb_bench.rs +++ b/crates/phonon/benches/reverb_bench.rs @@ -16,9 +16,9 @@ // use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use phonon::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::reverb_effect::{ReverbEffect, ReverbEffectParams}; -use phonon::reverb_estimator::Reverb; +use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; +use phonon::dsp::reverb_estimator::Reverb; +use phonon::effects::reverb_effect::{ReverbEffect, ReverbEffectParams}; fn bench_reverb(input: f32) -> f32 { const NUM_RUNS: i32 = 100_000; //todo this should be a Criterion argument probably diff --git a/crates/phonon/src/audio_buffer.rs b/crates/phonon/src/dsp/audio_buffer.rs similarity index 100% rename from crates/phonon/src/audio_buffer.rs rename to crates/phonon/src/dsp/audio_buffer.rs diff --git a/crates/phonon/src/bands.rs b/crates/phonon/src/dsp/bands.rs similarity index 100% rename from crates/phonon/src/bands.rs rename to crates/phonon/src/dsp/bands.rs diff --git a/crates/phonon/src/delay.rs b/crates/phonon/src/dsp/delay.rs similarity index 99% rename from crates/phonon/src/delay.rs rename to crates/phonon/src/dsp/delay.rs index bf23cdf..f4a93a9 100644 --- a/crates/phonon/src/delay.rs +++ b/crates/phonon/src/dsp/delay.rs @@ -133,7 +133,7 @@ mod tests { #[test] fn test_delay_buffer() { - let mut delay = Delay { + let delay = Delay { ring_buffer: vec![1.0, 2.0, 3.0], cursor: 0, read_cursor: 0, diff --git a/crates/phonon/src/iir.rs b/crates/phonon/src/dsp/iir.rs similarity index 100% rename from crates/phonon/src/iir.rs rename to crates/phonon/src/dsp/iir.rs diff --git a/crates/phonon/src/dsp/mod.rs b/crates/phonon/src/dsp/mod.rs new file mode 100644 index 0000000..7996123 --- /dev/null +++ b/crates/phonon/src/dsp/mod.rs @@ -0,0 +1,8 @@ +//! Processing of audio samples. + +pub mod audio_buffer; +pub mod bands; +pub mod delay; +pub mod iir; +pub mod reverb_estimator; +pub mod speaker_layout; diff --git a/crates/phonon/src/reverb_estimator.rs b/crates/phonon/src/dsp/reverb_estimator.rs similarity index 96% rename from crates/phonon/src/reverb_estimator.rs rename to crates/phonon/src/dsp/reverb_estimator.rs index d0b5c92..7aa73a3 100644 --- a/crates/phonon/src/reverb_estimator.rs +++ b/crates/phonon/src/dsp/reverb_estimator.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::bands::NUM_BANDS; +use crate::dsp::bands::NUM_BANDS; pub struct Reverb { pub reverb_times: [f32; NUM_BANDS], diff --git a/crates/phonon/src/speaker_layout.rs b/crates/phonon/src/dsp/speaker_layout.rs similarity index 100% rename from crates/phonon/src/speaker_layout.rs rename to crates/phonon/src/dsp/speaker_layout.rs diff --git a/crates/phonon/src/direct_effect.rs b/crates/phonon/src/effects/direct_effect.rs similarity index 95% rename from crates/phonon/src/direct_effect.rs rename to crates/phonon/src/effects/direct_effect.rs index 0912214..3656439 100644 --- a/crates/phonon/src/direct_effect.rs +++ b/crates/phonon/src/effects/direct_effect.rs @@ -15,14 +15,14 @@ // limitations under the License. // -use crate::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; -use crate::bands::NUM_BANDS; +use crate::dsp::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; +use crate::dsp::bands::NUM_BANDS; use bitflags::bitflags; use std::cmp::PartialEq; -use crate::direct_simulator::DirectSoundPath; -use crate::eq_effect::{EqEffect, EqEffectParameters}; -use crate::gain_effect::{GainEffect, GainEffectParameters}; +use crate::effects::eq_effect::{EqEffect, EqEffectParameters}; +use crate::effects::gain_effect::{GainEffect, GainEffectParameters}; +use crate::simulators::direct_simulator::DirectSoundPath; bitflags! { //todo check if these are all necessary diff --git a/crates/phonon/src/eq_effect.rs b/crates/phonon/src/effects/eq_effect.rs similarity index 97% rename from crates/phonon/src/eq_effect.rs rename to crates/phonon/src/effects/eq_effect.rs index db9513e..4464ea9 100644 --- a/crates/phonon/src/eq_effect.rs +++ b/crates/phonon/src/effects/eq_effect.rs @@ -15,11 +15,11 @@ // limitations under the License. // -use crate::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; +use crate::dsp::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; use ndarray::{Array, Array1}; -use crate::bands::{HIGH_CUTOFF_FREQUENCIES, LOW_CUTOFF_FREQUENCIES, NUM_BANDS}; -use crate::iir::{IIRFilterer, IIR}; +use crate::dsp::bands::{HIGH_CUTOFF_FREQUENCIES, LOW_CUTOFF_FREQUENCIES, NUM_BANDS}; +use crate::dsp::iir::{IIRFilterer, IIR}; pub struct EqEffectParameters { pub gains: [f32; NUM_BANDS], diff --git a/crates/phonon/src/gain_effect.rs b/crates/phonon/src/effects/gain_effect.rs similarity index 97% rename from crates/phonon/src/gain_effect.rs rename to crates/phonon/src/effects/gain_effect.rs index 77d6240..bc7e532 100644 --- a/crates/phonon/src/gain_effect.rs +++ b/crates/phonon/src/effects/gain_effect.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; +use crate::dsp::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; const NUM_INTERPOLATION_FRAMES: usize = 4; diff --git a/crates/phonon/src/effects/mod.rs b/crates/phonon/src/effects/mod.rs new file mode 100644 index 0000000..df04097 --- /dev/null +++ b/crates/phonon/src/effects/mod.rs @@ -0,0 +1,8 @@ +//! Higher level audio effects which are controlled by parameters. +//! In some cases these parameters are intended to be set by the simulators. + +pub mod direct_effect; +pub mod eq_effect; +pub mod gain_effect; +pub mod panning_effect; +pub mod reverb_effect; diff --git a/crates/phonon/src/panning_effect.rs b/crates/phonon/src/effects/panning_effect.rs similarity index 96% rename from crates/phonon/src/panning_effect.rs rename to crates/phonon/src/effects/panning_effect.rs index 37fdba2..bc317a3 100644 --- a/crates/phonon/src/panning_effect.rs +++ b/crates/phonon/src/effects/panning_effect.rs @@ -15,8 +15,8 @@ // limitations under the License. // -use crate::audio_buffer::{AudioBuffer, AudioEffectState}; -use crate::speaker_layout::{SpeakerLayout, SpeakerLayoutType}; +use crate::dsp::audio_buffer::{AudioBuffer, AudioEffectState}; +use crate::dsp::speaker_layout::{SpeakerLayout, SpeakerLayoutType}; use glam::Vec3; use std::f32::consts::PI; diff --git a/crates/phonon/src/reverb_effect.rs b/crates/phonon/src/effects/reverb_effect.rs similarity index 98% rename from crates/phonon/src/reverb_effect.rs rename to crates/phonon/src/effects/reverb_effect.rs index e32c4db..9943dbc 100644 --- a/crates/phonon/src/reverb_effect.rs +++ b/crates/phonon/src/effects/reverb_effect.rs @@ -15,12 +15,12 @@ // limitations under the License. // -use crate::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; -use crate::bands::NUM_BANDS; -use crate::delay::Delay; -use crate::reverb_estimator::Reverb; +use crate::dsp::audio_buffer::{AudioBuffer, AudioEffectState, AudioSettings}; +use crate::dsp::bands::NUM_BANDS; +use crate::dsp::delay::Delay; +use crate::dsp::reverb_estimator::Reverb; -use crate::iir::{IIRFilterer, IIR}; +use crate::dsp::iir::{IIRFilterer, IIR}; use derive_deref::{Deref, DerefMut}; use ndarray::{s, Array, Array2, ArrayView, Axis}; use rand::Rng; diff --git a/crates/phonon/src/lib.rs b/crates/phonon/src/lib.rs index dc73373..a2cdf3b 100644 --- a/crates/phonon/src/lib.rs +++ b/crates/phonon/src/lib.rs @@ -4,31 +4,9 @@ #[macro_use] extern crate serde; -pub mod air_absorption; -pub mod audio_buffer; -pub mod bands; pub mod context; -pub mod coordinate_space; -pub mod delay; -pub mod direct_effect; -pub mod direct_simulator; -pub mod directivity; -pub mod distance_attenuation; -pub mod eq_effect; -pub mod gain_effect; -pub mod hit; -pub mod iir; -pub mod instanced_mesh; -pub mod material; -pub mod mesh; -pub mod panning_effect; -pub mod propagation_medium; -pub mod ray; -pub mod reverb_effect; -pub mod reverb_estimator; -pub mod sampling; +pub mod dsp; +pub mod effects; +pub mod models; pub mod scene; -pub mod speaker_layout; -mod sphere; -pub mod static_mesh; -pub mod triangle; +pub mod simulators; diff --git a/crates/phonon/src/air_absorption.rs b/crates/phonon/src/models/air_absorption.rs similarity index 97% rename from crates/phonon/src/air_absorption.rs rename to crates/phonon/src/models/air_absorption.rs index 6056af3..a9e9843 100644 --- a/crates/phonon/src/air_absorption.rs +++ b/crates/phonon/src/models/air_absorption.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::bands::NUM_BANDS; +use crate::dsp::bands::NUM_BANDS; pub trait AirAbsorptionModel { fn evaluate(&self, distance: f32, band: usize) -> f32; diff --git a/crates/phonon/src/directivity.rs b/crates/phonon/src/models/directivity.rs similarity index 96% rename from crates/phonon/src/directivity.rs rename to crates/phonon/src/models/directivity.rs index b54ce8c..43aab38 100644 --- a/crates/phonon/src/directivity.rs +++ b/crates/phonon/src/models/directivity.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::coordinate_space::CoordinateSpace3f; +use crate::scene::coordinate_space::CoordinateSpace3f; use glam::Vec3; // todo: Describe what these do and what the limits are diff --git a/crates/phonon/src/distance_attenuation.rs b/crates/phonon/src/models/distance_attenuation.rs similarity index 100% rename from crates/phonon/src/distance_attenuation.rs rename to crates/phonon/src/models/distance_attenuation.rs diff --git a/crates/phonon/src/models/mod.rs b/crates/phonon/src/models/mod.rs new file mode 100644 index 0000000..ae6eb09 --- /dev/null +++ b/crates/phonon/src/models/mod.rs @@ -0,0 +1,7 @@ +//! Models for audio propagation/attenuation. Each should have a good default +//! but the user should be able to use a custom model as well. + +pub mod air_absorption; +pub mod directivity; +pub mod distance_attenuation; +pub mod propagation_medium; diff --git a/crates/phonon/src/propagation_medium.rs b/crates/phonon/src/models/propagation_medium.rs similarity index 100% rename from crates/phonon/src/propagation_medium.rs rename to crates/phonon/src/models/propagation_medium.rs diff --git a/crates/phonon/src/coordinate_space.rs b/crates/phonon/src/scene/coordinate_space.rs similarity index 100% rename from crates/phonon/src/coordinate_space.rs rename to crates/phonon/src/scene/coordinate_space.rs diff --git a/crates/phonon/src/hit.rs b/crates/phonon/src/scene/hit.rs similarity index 96% rename from crates/phonon/src/hit.rs rename to crates/phonon/src/scene/hit.rs index 1964679..a913479 100644 --- a/crates/phonon/src/hit.rs +++ b/crates/phonon/src/scene/hit.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::material::Material; +use crate::scene::material::Material; use glam::Vec3; #[derive(Copy, Clone, Debug)] diff --git a/crates/phonon/src/instanced_mesh.rs b/crates/phonon/src/scene/instanced_mesh.rs similarity index 98% rename from crates/phonon/src/instanced_mesh.rs rename to crates/phonon/src/scene/instanced_mesh.rs index 5713468..a044ed6 100644 --- a/crates/phonon/src/instanced_mesh.rs +++ b/crates/phonon/src/scene/instanced_mesh.rs @@ -15,8 +15,8 @@ // limitations under the License. // -use crate::hit::Hit; -use crate::ray::Ray; +use crate::scene::hit::Hit; +use crate::scene::ray::Ray; use crate::scene::Scene; use glam::Mat4; use std::sync::{Arc, Mutex}; diff --git a/crates/phonon/src/material.rs b/crates/phonon/src/scene/material.rs similarity index 97% rename from crates/phonon/src/material.rs rename to crates/phonon/src/scene/material.rs index f4a49f3..a26cd9e 100644 --- a/crates/phonon/src/material.rs +++ b/crates/phonon/src/scene/material.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::bands::NUM_BANDS; +use crate::dsp::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. diff --git a/crates/phonon/src/mesh.rs b/crates/phonon/src/scene/mesh.rs similarity index 98% rename from crates/phonon/src/mesh.rs rename to crates/phonon/src/scene/mesh.rs index 40a2a77..747043d 100644 --- a/crates/phonon/src/mesh.rs +++ b/crates/phonon/src/scene/mesh.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::triangle::Triangle; +use crate::scene::triangle::Triangle; use glam::Vec3; use ndarray::Array1; use parry3d::math::Point; diff --git a/crates/phonon/src/scene/mod.rs b/crates/phonon/src/scene/mod.rs new file mode 100644 index 0000000..79def82 --- /dev/null +++ b/crates/phonon/src/scene/mod.rs @@ -0,0 +1,15 @@ +//! Everything related to ray tracing and representing a scene in 3D space. + +pub mod coordinate_space; +pub mod hit; +pub mod instanced_mesh; +pub mod material; +pub mod mesh; +pub mod ray; +pub mod sampling; +pub mod scene; +pub mod sphere; +pub mod static_mesh; +pub mod triangle; + +pub use scene::Scene; diff --git a/crates/phonon/src/ray.rs b/crates/phonon/src/scene/ray.rs similarity index 100% rename from crates/phonon/src/ray.rs rename to crates/phonon/src/scene/ray.rs diff --git a/crates/phonon/src/sampling.rs b/crates/phonon/src/scene/sampling.rs similarity index 98% rename from crates/phonon/src/sampling.rs rename to crates/phonon/src/scene/sampling.rs index fe25507..cbf17f8 100644 --- a/crates/phonon/src/sampling.rs +++ b/crates/phonon/src/scene/sampling.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use crate::sphere::Sphere; +use crate::scene::sphere::Sphere; use glam::Vec3; use std::f32::consts::PI; diff --git a/crates/phonon/src/scene.rs b/crates/phonon/src/scene/scene.rs similarity index 96% rename from crates/phonon/src/scene.rs rename to crates/phonon/src/scene/scene.rs index 620ce62..c5d05b5 100644 --- a/crates/phonon/src/scene.rs +++ b/crates/phonon/src/scene/scene.rs @@ -15,10 +15,10 @@ // limitations under the License. // -use crate::hit::Hit; -use crate::instanced_mesh::InstancedMesh; -use crate::ray::Ray; -use crate::static_mesh::StaticMesh; +use crate::scene::hit::Hit; +use crate::scene::instanced_mesh::InstancedMesh; +use crate::scene::ray::Ray; +use crate::scene::static_mesh::StaticMesh; use glam::Vec3; use std::sync::{Arc, Mutex}; @@ -187,8 +187,8 @@ impl Scene { #[cfg(test)] mod tests { use super::*; - use crate::material::Material; - use crate::triangle::Triangle; + use crate::scene::material::Material; + use crate::scene::triangle::Triangle; use glam::{Affine3A, Mat4, Vec3}; #[test] @@ -235,7 +235,7 @@ mod tests { assert!(!scene.any_hit(&ray_hit, 0.0, 1.0)); - let mut sub_scene = Arc::new(Mutex::new(Scene::new())); + let sub_scene = Arc::new(Mutex::new(Scene::new())); sub_scene.lock().unwrap().add_static_mesh(static_mesh); let transform = Affine3A::from_translation(Vec3::new(1.0, 0.0, 2.0)); diff --git a/crates/phonon/src/sphere.rs b/crates/phonon/src/scene/sphere.rs similarity index 100% rename from crates/phonon/src/sphere.rs rename to crates/phonon/src/scene/sphere.rs diff --git a/crates/phonon/src/static_mesh.rs b/crates/phonon/src/scene/static_mesh.rs similarity index 97% rename from crates/phonon/src/static_mesh.rs rename to crates/phonon/src/scene/static_mesh.rs index d989d44..cfaa5d5 100644 --- a/crates/phonon/src/static_mesh.rs +++ b/crates/phonon/src/scene/static_mesh.rs @@ -15,11 +15,11 @@ // limitations under the License. // -use crate::hit::Hit; -use crate::material::Material; -use crate::mesh::Mesh; -use crate::ray::Ray; -use crate::triangle::Triangle; +use crate::scene::hit::Hit; +use crate::scene::material::Material; +use crate::scene::mesh::Mesh; +use crate::scene::ray::Ray; +use crate::scene::triangle::Triangle; use glam::Vec3; use ndarray::Array1; use parry3d::query::RayCast; diff --git a/crates/phonon/src/triangle.rs b/crates/phonon/src/scene/triangle.rs similarity index 100% rename from crates/phonon/src/triangle.rs rename to crates/phonon/src/scene/triangle.rs diff --git a/crates/phonon/src/direct_simulator.rs b/crates/phonon/src/simulators/direct_simulator.rs similarity index 96% rename from crates/phonon/src/direct_simulator.rs rename to crates/phonon/src/simulators/direct_simulator.rs index 3a8b37b..f0f949b 100644 --- a/crates/phonon/src/direct_simulator.rs +++ b/crates/phonon/src/simulators/direct_simulator.rs @@ -15,17 +15,17 @@ // limitations under the License. // -use crate::air_absorption::AirAbsorptionModel; -use crate::bands::NUM_BANDS; -use crate::coordinate_space::CoordinateSpace3f; -use crate::direct_effect::DirectApplyFlags; -use crate::directivity::Directivity; -use crate::distance_attenuation::DistanceAttenuationModel; -use crate::propagation_medium::SPEED_OF_SOUND; -use crate::ray::Ray; -use crate::sampling::{generate_sphere_volume_sample, transform_sphere_volume_sample}; +use crate::dsp::bands::NUM_BANDS; +use crate::effects::direct_effect::DirectApplyFlags; +use crate::models::air_absorption::AirAbsorptionModel; +use crate::models::directivity::Directivity; +use crate::models::distance_attenuation::DistanceAttenuationModel; +use crate::models::propagation_medium::SPEED_OF_SOUND; +use crate::scene::coordinate_space::CoordinateSpace3f; +use crate::scene::ray::Ray; +use crate::scene::sampling::{generate_sphere_volume_sample, transform_sphere_volume_sample}; +use crate::scene::sphere::Sphere; use crate::scene::Scene; -use crate::sphere::Sphere; use glam::Vec3; pub enum OcclusionType { diff --git a/crates/phonon/src/simulators/mod.rs b/crates/phonon/src/simulators/mod.rs new file mode 100644 index 0000000..f706145 --- /dev/null +++ b/crates/phonon/src/simulators/mod.rs @@ -0,0 +1,4 @@ +//! Simulators calculate the parameters for their corresponding effects +//! based on the `scene` and `models`. + +pub mod direct_simulator; diff --git a/crates/phonon/tests/audio_buffer_test.rs b/crates/phonon/tests/audio_buffer_test.rs index 4539020..2673fbb 100644 --- a/crates/phonon/tests/audio_buffer_test.rs +++ b/crates/phonon/tests/audio_buffer_test.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use phonon::audio_buffer::AudioBuffer; +use phonon::dsp::audio_buffer::AudioBuffer; #[test] fn mixing_audio_buffers() { diff --git a/crates/phonon/tests/coordinate_space_test.rs b/crates/phonon/tests/coordinate_space_test.rs index 5987bc1..6572c76 100644 --- a/crates/phonon/tests/coordinate_space_test.rs +++ b/crates/phonon/tests/coordinate_space_test.rs @@ -16,7 +16,7 @@ // use glam::Vec3; -use phonon::coordinate_space::CoordinateSpace3f; +use phonon::scene::coordinate_space::CoordinateSpace3f; #[test] fn coordinate_system_right_handed() { diff --git a/crates/phonon/tests/iir_filter_test.rs b/crates/phonon/tests/iir_filter_test.rs index 5829688..e0782ba 100644 --- a/crates/phonon/tests/iir_filter_test.rs +++ b/crates/phonon/tests/iir_filter_test.rs @@ -15,7 +15,7 @@ // limitations under the License. // -use phonon::iir::{IIRFilterer, IIR}; +use phonon::dsp::iir::{IIRFilterer, IIR}; #[test] fn iir_filter() { diff --git a/crates/phonon/tests/triangle.rs b/crates/phonon/tests/triangle.rs index 0371da1..cb289ed 100644 --- a/crates/phonon/tests/triangle.rs +++ b/crates/phonon/tests/triangle.rs @@ -16,8 +16,8 @@ // use glam::Vec3; -use phonon::mesh::Mesh; -use phonon::triangle::Triangle; +use phonon::scene::mesh::Mesh; +use phonon::scene::triangle::Triangle; #[test] fn triangle_normals() { From 5a74adb0c0d8eccff8259f1efdf12356bab3791f Mon Sep 17 00:00:00 2001 From: GitGhillie Date: Sun, 22 Sep 2024 10:44:36 +0200 Subject: [PATCH 2/3] Shorten names --- crates/phonon-fmod/examples/create_dsp.rs | 2 +- crates/phonon-fmod/src/callbacks.rs | 6 +++--- crates/phonon-fmod/src/lib.rs | 6 +++--- crates/phonon-kira/examples/direct_effect.rs | 4 ++-- crates/phonon-kira/examples/reverb_effect.rs | 2 +- crates/phonon-kira/src/direct_effect/builder.rs | 4 ++-- crates/phonon-kira/src/direct_effect/effect.rs | 4 ++-- crates/phonon-kira/src/direct_effect/handle.rs | 4 ++-- crates/phonon-kira/src/direct_effect/mod.rs | 4 ++-- crates/phonon-kira/src/eq_effect/effect.rs | 4 ++-- crates/phonon-kira/src/reverb_effect/effect.rs | 2 +- crates/phonon/benches/direct_effect_bench.rs | 4 ++-- crates/phonon/benches/panning_bench.rs | 2 +- crates/phonon/benches/reverb_bench.rs | 2 +- .../phonon/src/effects/{direct_effect.rs => direct.rs} | 6 +++--- crates/phonon/src/effects/{eq_effect.rs => eq.rs} | 0 crates/phonon/src/effects/{gain_effect.rs => gain.rs} | 0 crates/phonon/src/effects/mod.rs | 10 +++++----- .../src/effects/{panning_effect.rs => panning.rs} | 0 .../phonon/src/effects/{reverb_effect.rs => reverb.rs} | 0 .../src/simulators/{direct_simulator.rs => direct.rs} | 2 +- crates/phonon/src/simulators/mod.rs | 2 +- 22 files changed, 35 insertions(+), 35 deletions(-) rename crates/phonon/src/effects/{direct_effect.rs => direct.rs} (97%) rename crates/phonon/src/effects/{eq_effect.rs => eq.rs} (100%) rename crates/phonon/src/effects/{gain_effect.rs => gain.rs} (100%) rename crates/phonon/src/effects/{panning_effect.rs => panning.rs} (100%) rename crates/phonon/src/effects/{reverb_effect.rs => reverb.rs} (100%) rename crates/phonon/src/simulators/{direct_simulator.rs => direct.rs} (99%) diff --git a/crates/phonon-fmod/examples/create_dsp.rs b/crates/phonon-fmod/examples/create_dsp.rs index a1464ea..5c06822 100644 --- a/crates/phonon-fmod/examples/create_dsp.rs +++ b/crates/phonon-fmod/examples/create_dsp.rs @@ -9,7 +9,7 @@ use libfmod::ffi::{ FMOD_VECTOR, }; use libfmod::{Error, System}; -use phonon::simulators::direct_simulator::DirectSoundPath; +use phonon::simulators::direct::DirectSoundPath; use phonon_fmod::create_dsp_description; use std::io; use std::io::BufRead; diff --git a/crates/phonon-fmod/src/callbacks.rs b/crates/phonon-fmod/src/callbacks.rs index df6a61b..5d2814e 100644 --- a/crates/phonon-fmod/src/callbacks.rs +++ b/crates/phonon-fmod/src/callbacks.rs @@ -10,9 +10,9 @@ use libfmod::ffi::{ }; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; use phonon::dsp::speaker_layout::SpeakerLayoutType; -use phonon::effects::direct_effect::{DirectEffect, TransmissionType}; -use phonon::effects::panning_effect::PanningEffect; -use phonon::simulators::direct_simulator::DirectSoundPath; +use phonon::effects::direct::{DirectEffect, TransmissionType}; +use phonon::effects::panning::PanningEffect; +use phonon::simulators::direct::DirectSoundPath; use std::os::raw::{c_char, c_float, c_int, c_uint, c_void}; use std::ptr::{null_mut, slice_from_raw_parts_mut}; use std::slice; diff --git a/crates/phonon-fmod/src/lib.rs b/crates/phonon-fmod/src/lib.rs index 26921c6..1beba72 100644 --- a/crates/phonon-fmod/src/lib.rs +++ b/crates/phonon-fmod/src/lib.rs @@ -34,11 +34,11 @@ use libfmod::ffi::{ }; use libfmod::DspDescription; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::effects::direct_effect::{ +use phonon::effects::direct::{ DirectApplyFlags, DirectEffect, DirectEffectParameters, TransmissionType, }; -use phonon::effects::panning_effect::{PanningEffect, PanningEffectParameters}; -use phonon::simulators::direct_simulator::DirectSoundPath; +use phonon::effects::panning::{PanningEffect, PanningEffectParameters}; +use phonon::simulators::direct::DirectSoundPath; use std::ffi::CString; use std::os::raw::{c_char, c_int}; use std::ptr::null_mut; diff --git a/crates/phonon-kira/examples/direct_effect.rs b/crates/phonon-kira/examples/direct_effect.rs index 484175d..ba544bd 100644 --- a/crates/phonon-kira/examples/direct_effect.rs +++ b/crates/phonon-kira/examples/direct_effect.rs @@ -4,8 +4,8 @@ use kira::manager::backend::cpal::CpalBackend; use kira::manager::{AudioManager, AudioManagerSettings}; use kira::sound::static_sound::StaticSoundData; use kira::track::TrackBuilder; -use phonon::effects::direct_effect::{DirectApplyFlags, DirectEffectParameters, TransmissionType}; -use phonon::simulators::direct_simulator::DirectSoundPath; +use phonon::effects::direct::{DirectApplyFlags, DirectEffectParameters, TransmissionType}; +use phonon::simulators::direct::DirectSoundPath; use phonon_kira::direct_effect::builder::DirectEffectBuilder; diff --git a/crates/phonon-kira/examples/reverb_effect.rs b/crates/phonon-kira/examples/reverb_effect.rs index 60074bc..12fc4b8 100644 --- a/crates/phonon-kira/examples/reverb_effect.rs +++ b/crates/phonon-kira/examples/reverb_effect.rs @@ -5,7 +5,7 @@ use kira::manager::{AudioManager, AudioManagerSettings}; use kira::sound::static_sound::StaticSoundData; use kira::track::TrackBuilder; use phonon::dsp::reverb_estimator::Reverb; -use phonon::effects::reverb_effect::ReverbEffectParams; +use phonon::effects::reverb::ReverbEffectParams; use phonon_kira::reverb_effect::builder::ReverbEffectBuilder; diff --git a/crates/phonon-kira/src/direct_effect/builder.rs b/crates/phonon-kira/src/direct_effect/builder.rs index 2932755..a60d3fe 100644 --- a/crates/phonon-kira/src/direct_effect/builder.rs +++ b/crates/phonon-kira/src/direct_effect/builder.rs @@ -2,8 +2,8 @@ use super::command_writers_and_readers; use super::effect::DirectEffectWrapped; use super::handle::DirectEffectHandle; use kira::effect::{Effect, EffectBuilder}; -use phonon::effects::direct_effect::DirectEffectParameters; -use phonon::effects::panning_effect::PanningEffectParameters; +use phonon::effects::direct::DirectEffectParameters; +use phonon::effects::panning::PanningEffectParameters; #[derive(Debug, Copy, Clone)] pub struct DirectEffectBuilder { diff --git a/crates/phonon-kira/src/direct_effect/effect.rs b/crates/phonon-kira/src/direct_effect/effect.rs index eb38569..e8a2829 100644 --- a/crates/phonon-kira/src/direct_effect/effect.rs +++ b/crates/phonon-kira/src/direct_effect/effect.rs @@ -6,8 +6,8 @@ use kira::modulator::value_provider::ModulatorValueProvider; use kira::Frame; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; use phonon::dsp::speaker_layout::SpeakerLayoutType; -use phonon::effects::direct_effect::{DirectEffect, DirectEffectParameters}; -use phonon::effects::panning_effect::{PanningEffect, PanningEffectParameters}; +use phonon::effects::direct::{DirectEffect, DirectEffectParameters}; +use phonon::effects::panning::{PanningEffect, PanningEffectParameters}; pub(crate) struct DirectEffectWrapped { command_readers: CommandReaders, diff --git a/crates/phonon-kira/src/direct_effect/handle.rs b/crates/phonon-kira/src/direct_effect/handle.rs index c6d36ae..f5849b8 100644 --- a/crates/phonon-kira/src/direct_effect/handle.rs +++ b/crates/phonon-kira/src/direct_effect/handle.rs @@ -1,6 +1,6 @@ use super::CommandWriters; -use phonon::effects::direct_effect::DirectEffectParameters; -use phonon::effects::panning_effect::PanningEffectParameters; +use phonon::effects::direct::DirectEffectParameters; +use phonon::effects::panning::PanningEffectParameters; /// Controls an EQ effect. pub struct DirectEffectHandle { diff --git a/crates/phonon-kira/src/direct_effect/mod.rs b/crates/phonon-kira/src/direct_effect/mod.rs index e1d8e59..51172f5 100644 --- a/crates/phonon-kira/src/direct_effect/mod.rs +++ b/crates/phonon-kira/src/direct_effect/mod.rs @@ -1,6 +1,6 @@ use kira::command::{CommandReader, CommandWriter}; -use phonon::effects::direct_effect::DirectEffectParameters; -use phonon::effects::panning_effect::PanningEffectParameters; +use phonon::effects::direct::DirectEffectParameters; +use phonon::effects::panning::PanningEffectParameters; pub mod builder; pub(crate) mod effect; diff --git a/crates/phonon-kira/src/eq_effect/effect.rs b/crates/phonon-kira/src/eq_effect/effect.rs index a1e0042..50b46a9 100644 --- a/crates/phonon-kira/src/eq_effect/effect.rs +++ b/crates/phonon-kira/src/eq_effect/effect.rs @@ -5,8 +5,8 @@ use kira::effect::Effect; use kira::modulator::value_provider::ModulatorValueProvider; use kira::Frame; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::effects::eq_effect::{EqEffect, EqEffectParameters}; -use phonon::effects::gain_effect::{GainEffect, GainEffectParameters}; +use phonon::effects::eq::{EqEffect, EqEffectParameters}; +use phonon::effects::gain::{GainEffect, GainEffectParameters}; pub(crate) struct EqEffectWrapped { command_readers: CommandReaders, diff --git a/crates/phonon-kira/src/reverb_effect/effect.rs b/crates/phonon-kira/src/reverb_effect/effect.rs index e53ec48..74ceb47 100644 --- a/crates/phonon-kira/src/reverb_effect/effect.rs +++ b/crates/phonon-kira/src/reverb_effect/effect.rs @@ -6,7 +6,7 @@ use kira::modulator::value_provider::ModulatorValueProvider; use kira::Frame; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; use phonon::dsp::reverb_estimator::Reverb; -use phonon::effects::reverb_effect::{ReverbEffect, ReverbEffectParams}; +use phonon::effects::reverb::{ReverbEffect, ReverbEffectParams}; pub(crate) struct ReverbEffectWrapped { command_readers: CommandReaders, diff --git a/crates/phonon/benches/direct_effect_bench.rs b/crates/phonon/benches/direct_effect_bench.rs index f372cb7..e492891 100644 --- a/crates/phonon/benches/direct_effect_bench.rs +++ b/crates/phonon/benches/direct_effect_bench.rs @@ -17,10 +17,10 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; -use phonon::effects::direct_effect::{ +use phonon::effects::direct::{ DirectApplyFlags, DirectEffect, DirectEffectParameters, TransmissionType, }; -use phonon::simulators::direct_simulator::DirectSoundPath; +use phonon::simulators::direct::DirectSoundPath; use rand::Rng; pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/crates/phonon/benches/panning_bench.rs b/crates/phonon/benches/panning_bench.rs index 5597c98..5323931 100644 --- a/crates/phonon/benches/panning_bench.rs +++ b/crates/phonon/benches/panning_bench.rs @@ -22,7 +22,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use glam::Vec3; use phonon::dsp::audio_buffer::AudioBuffer; use phonon::dsp::speaker_layout::SpeakerLayoutType; -use phonon::effects::panning_effect::{PanningEffect, PanningEffectParameters}; +use phonon::effects::panning::{PanningEffect, PanningEffectParameters}; use rand::Rng; pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/crates/phonon/benches/reverb_bench.rs b/crates/phonon/benches/reverb_bench.rs index f6fb6a6..d6e9733 100644 --- a/crates/phonon/benches/reverb_bench.rs +++ b/crates/phonon/benches/reverb_bench.rs @@ -18,7 +18,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use phonon::dsp::audio_buffer::{AudioBuffer, AudioSettings}; use phonon::dsp::reverb_estimator::Reverb; -use phonon::effects::reverb_effect::{ReverbEffect, ReverbEffectParams}; +use phonon::effects::reverb::{ReverbEffect, ReverbEffectParams}; fn bench_reverb(input: f32) -> f32 { const NUM_RUNS: i32 = 100_000; //todo this should be a Criterion argument probably diff --git a/crates/phonon/src/effects/direct_effect.rs b/crates/phonon/src/effects/direct.rs similarity index 97% rename from crates/phonon/src/effects/direct_effect.rs rename to crates/phonon/src/effects/direct.rs index 3656439..7e3d00f 100644 --- a/crates/phonon/src/effects/direct_effect.rs +++ b/crates/phonon/src/effects/direct.rs @@ -20,9 +20,9 @@ use crate::dsp::bands::NUM_BANDS; use bitflags::bitflags; use std::cmp::PartialEq; -use crate::effects::eq_effect::{EqEffect, EqEffectParameters}; -use crate::effects::gain_effect::{GainEffect, GainEffectParameters}; -use crate::simulators::direct_simulator::DirectSoundPath; +use crate::effects::eq::{EqEffect, EqEffectParameters}; +use crate::effects::gain::{GainEffect, GainEffectParameters}; +use crate::simulators::direct::DirectSoundPath; bitflags! { //todo check if these are all necessary diff --git a/crates/phonon/src/effects/eq_effect.rs b/crates/phonon/src/effects/eq.rs similarity index 100% rename from crates/phonon/src/effects/eq_effect.rs rename to crates/phonon/src/effects/eq.rs diff --git a/crates/phonon/src/effects/gain_effect.rs b/crates/phonon/src/effects/gain.rs similarity index 100% rename from crates/phonon/src/effects/gain_effect.rs rename to crates/phonon/src/effects/gain.rs diff --git a/crates/phonon/src/effects/mod.rs b/crates/phonon/src/effects/mod.rs index df04097..c47c55e 100644 --- a/crates/phonon/src/effects/mod.rs +++ b/crates/phonon/src/effects/mod.rs @@ -1,8 +1,8 @@ //! Higher level audio effects which are controlled by parameters. //! In some cases these parameters are intended to be set by the simulators. -pub mod direct_effect; -pub mod eq_effect; -pub mod gain_effect; -pub mod panning_effect; -pub mod reverb_effect; +pub mod direct; +pub mod eq; +pub mod gain; +pub mod panning; +pub mod reverb; diff --git a/crates/phonon/src/effects/panning_effect.rs b/crates/phonon/src/effects/panning.rs similarity index 100% rename from crates/phonon/src/effects/panning_effect.rs rename to crates/phonon/src/effects/panning.rs diff --git a/crates/phonon/src/effects/reverb_effect.rs b/crates/phonon/src/effects/reverb.rs similarity index 100% rename from crates/phonon/src/effects/reverb_effect.rs rename to crates/phonon/src/effects/reverb.rs diff --git a/crates/phonon/src/simulators/direct_simulator.rs b/crates/phonon/src/simulators/direct.rs similarity index 99% rename from crates/phonon/src/simulators/direct_simulator.rs rename to crates/phonon/src/simulators/direct.rs index f0f949b..a78fe32 100644 --- a/crates/phonon/src/simulators/direct_simulator.rs +++ b/crates/phonon/src/simulators/direct.rs @@ -16,7 +16,7 @@ // use crate::dsp::bands::NUM_BANDS; -use crate::effects::direct_effect::DirectApplyFlags; +use crate::effects::direct::DirectApplyFlags; use crate::models::air_absorption::AirAbsorptionModel; use crate::models::directivity::Directivity; use crate::models::distance_attenuation::DistanceAttenuationModel; diff --git a/crates/phonon/src/simulators/mod.rs b/crates/phonon/src/simulators/mod.rs index f706145..f535ac9 100644 --- a/crates/phonon/src/simulators/mod.rs +++ b/crates/phonon/src/simulators/mod.rs @@ -1,4 +1,4 @@ //! Simulators calculate the parameters for their corresponding effects //! based on the `scene` and `models`. -pub mod direct_simulator; +pub mod direct; From 71e8d3482962f03543519f469e6dae8b5e4fc2b3 Mon Sep 17 00:00:00 2001 From: GitGhillie Date: Sun, 22 Sep 2024 10:46:27 +0200 Subject: [PATCH 3/3] Update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ce7bdc3..efbbe0c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ Please contact me on Discord (user: ixml) to check what is being worked on and w At this stage the focus is on the following: - Try to get the tests and benchmarks working -- Roughly follow the file structure of Steam Audio - Write Rusty code - Don't worry too much about performance yet (leave a 'todo' if necessary) - Look for opportunities to make use of the Rust ecosystem