Struct hrtf::HrirSphere

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

HRIR (Head-Related Impulse Response) spheres is a 3d mesh whose points contains impulse responses for left and right ears. It is used for interpolation of impulse responses.

Implementations§

source§

impl HrirSphere

source

pub fn from_file<P: AsRef<Path>>( path: P, device_sample_rate: u32 ) -> Result<Self, HrtfError>

Tries to load a sphere from a file.

source

pub fn new<R: Read>( reader: R, device_sample_rate: u32 ) -> Result<Self, HrtfError>

Loads HRIR sphere from given source.

Coordinate system

Hrtf spheres made in right-handed coordinate system. This fact can give weird positioning issues if your application uses left-handed coordinate system. However this can be fixed very easily: iterate over every point and invert X coordinate of it.

Sample rate

HRIR spheres from this base recorded in 44100 Hz sample rate. If your output device uses different sample rate, you have to resample initial set of .wav files and regenerate HRIR spheres. There could

source

pub fn transform(&mut self, matrix: &[f32; 16])

Applies specified transform to each point in sphere. Can be used to rotate or scale sphere. Transform shouldn’t have translation part, otherwise result of bilinear sampling is undefined.

source

pub fn points(&self) -> &[HrirPoint]

Returns shared reference to sphere points array.

source

pub fn points_mut(&mut self) -> &mut [HrirPoint]

Returns mutable reference to sphere points array.

source

pub fn len(&self) -> usize

Returns length of impulse response. It is same across all points in the sphere.

source

pub fn source(&self) -> &Path

Returns source file name (if any).

Trait Implementations§

source§

impl Clone for HrirSphere

source§

fn clone(&self) -> HrirSphere

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

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.