pub struct SpatialAudioField { /* private fields */ }Expand description
Spatial audio processor using the MEM8 wave grid
Implementations§
Source§impl SpatialAudioField
impl SpatialAudioField
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new spatial audio field with default ear positions Ears are placed at the center of the grid, separated horizontally
Sourcepub fn set_sample_rate(&mut self, rate: f32)
pub fn set_sample_rate(&mut self, rate: f32)
Set sample rate
Sourcepub fn add_source(&mut self, source: SoundSource) -> usize
pub fn add_source(&mut self, source: SoundSource) -> usize
Add a sound source to the field
Sourcepub fn add_tone(
&mut self,
x: u8,
y: u8,
frequency: f32,
amplitude: f32,
) -> usize
pub fn add_tone( &mut self, x: u8, y: u8, frequency: f32, amplitude: f32, ) -> usize
Add a simple tone at a position
Sourcepub fn remove_source(&mut self, idx: usize) -> Option<SoundSource>
pub fn remove_source(&mut self, idx: usize) -> Option<SoundSource>
Remove a sound source
Sourcepub fn set_source_active(&mut self, idx: usize, active: bool)
pub fn set_source_active(&mut self, idx: usize, active: bool)
Activate/deactivate a source
Sourcepub fn move_source(&mut self, idx: usize, new_pos: Position)
pub fn move_source(&mut self, idx: usize, new_pos: Position)
Move a source to a new position
Sourcepub fn sample(&mut self) -> StereoSample
pub fn sample(&mut self) -> StereoSample
Sample all sources at the current time, returning stereo output
Sourcepub fn sample_frames(&mut self, num_frames: usize) -> Vec<f32>
pub fn sample_frames(&mut self, num_frames: usize) -> Vec<f32>
Sample N frames and return as interleaved stereo buffer
Sourcepub fn direction_of(&self, pos: &Position) -> f32
pub fn direction_of(&self, pos: &Position) -> f32
Calculate the perceived direction of a position from the listener Returns angle in degrees (-90 = full left, 0 = center, 90 = full right)
Sourcepub fn itd_for(&self, pos: &Position) -> f32
pub fn itd_for(&self, pos: &Position) -> f32
Get Interaural Time Difference for a position (in seconds)
Sourcepub fn ild_for(&self, pos: &Position) -> f32
pub fn ild_for(&self, pos: &Position) -> f32
Get Interaural Level Difference for a position (as ratio)
Sourcepub fn reset_time(&mut self)
pub fn reset_time(&mut self)
Reset time to zero
Sourcepub fn source_count(&self) -> usize
pub fn source_count(&self) -> usize
Number of active sources
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpatialAudioField
impl RefUnwindSafe for SpatialAudioField
impl Send for SpatialAudioField
impl Sync for SpatialAudioField
impl Unpin for SpatialAudioField
impl UnsafeUnpin for SpatialAudioField
impl UnwindSafe for SpatialAudioField
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more