[][src]Struct hrtf::HrtfProcessor

pub struct HrtfProcessor { /* fields omitted */ }

See module docs.

Implementations

impl HrtfProcessor[src]

pub fn new(
    hrir_sphere: HrirSphere,
    interpolation_steps: usize,
    block_len: usize
) -> Self
[src]

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.

pub fn hrtf_sphere(&self) -> &HrtfSphere[src]

Returns shared reference to current hrtf sphere.

pub fn process_samples<T: InterleavedSamples>(
    &mut self,
    context: HrtfContext<'_, '_, '_, T>
)
[src]

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

impl Clone for HrtfProcessor[src]

impl Debug for HrtfProcessor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.