Struct hrtf::HrtfProcessor
source · pub struct HrtfProcessor { /* private fields */ }
Expand description
See module docs.
Implementations§
source§impl HrtfProcessor
impl HrtfProcessor
sourcepub fn new(
hrir_sphere: HrirSphere,
interpolation_steps: usize,
block_len: usize
) -> Self
pub fn new( hrir_sphere: HrirSphere, interpolation_steps: usize, block_len: usize ) -> Self
Creates new HRTF processor using specified HRTF sphere. See module docs for more info.
interpolation_steps
is the amount of slices to cut source to.
block_len
is the length of each slice.
sourcepub fn hrtf_sphere(&self) -> &HrtfSphere
pub fn hrtf_sphere(&self) -> &HrtfSphere
Returns shared reference to current hrtf sphere.
sourcepub fn process_samples<T: InterleavedSamples>(
&mut self,
context: HrtfContext<'_, '_, '_, T>
)
pub fn process_samples<T: InterleavedSamples>( &mut self, context: HrtfContext<'_, '_, '_, T> )
Processes given input samples and sums processed signal with output buffer. This method designed
to be used in a loop, it requires some info from previous frame. Check HrtfContext
for more info.
Example
use hrtf::{HrirSphere, HrtfContext, HrtfProcessor, Vec3};
let hrir_sphere = HrirSphere::from_file("your_file", 44100).unwrap();
let mut processor = HrtfProcessor::new(hrir_sphere, 8, 128);
let source = vec![0.; 1024]; // Fill with something useful.
let mut output = vec![(0.0, 0.0); 1024];
let mut prev_left_samples = vec![];
let mut prev_right_samples = vec![];
let context = HrtfContext {
source: &source,
output: &mut output,
new_sample_vector: Vec3{x: 0.0, y: 0.0, z: 1.0},
prev_sample_vector: Vec3{x: 0.0, y: 0.0, z: 1.0},
prev_left_samples: &mut prev_left_samples,
prev_right_samples: &mut prev_right_samples,
// For simplicity, keep gain at 1.0 so there will be no interpolation.
new_distance_gain: 1.0,
prev_distance_gain: 1.0
};
processor.process_samples(context);
Trait Implementations§
source§impl Clone for HrtfProcessor
impl Clone for HrtfProcessor
Auto Trait Implementations§
impl !RefUnwindSafe for HrtfProcessor
impl Send for HrtfProcessor
impl Sync for HrtfProcessor
impl Unpin for HrtfProcessor
impl !UnwindSafe for HrtfProcessor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more