Struct hrtf::HrtfProcessor

source ·
pub struct HrtfProcessor { /* private fields */ }
Expand description

See module docs.

Implementations§

source§

impl HrtfProcessor

source

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.

source

pub fn hrtf_sphere(&self) -> &HrtfSphere

Returns shared reference to current hrtf sphere.

source

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

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HrtfProcessor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.