pub struct AudioSource {
pub id: u32,
pub position: Position3D,
pub source_type: SourceType,
pub active: bool,
pub directivity: f32,
pub injection_radius: f32,
}Expand description
A 3D audio source in the simulation.
Fields§
§id: u32Unique identifier
position: Position3DPosition in 3D space (meters)
source_type: SourceTypeSource signal type
active: boolWhether the source is active
directivity: f32Directivity pattern (1.0 = omnidirectional)
injection_radius: f32Source radius for injection (cells)
Implementations§
Source§impl AudioSource
impl AudioSource
Sourcepub fn impulse(id: u32, position: Position3D, amplitude: f32) -> Self
pub fn impulse(id: u32, position: Position3D, amplitude: f32) -> Self
Create a new impulse source.
Sourcepub fn tone(
id: u32,
position: Position3D,
frequency_hz: f32,
amplitude: f32,
) -> Self
pub fn tone( id: u32, position: Position3D, frequency_hz: f32, amplitude: f32, ) -> Self
Create a new tone source.
Sourcepub fn noise(id: u32, position: Position3D, amplitude: f32, pink: bool) -> Self
pub fn noise(id: u32, position: Position3D, amplitude: f32, pink: bool) -> Self
Create a noise source.
Sourcepub fn chirp(
id: u32,
position: Position3D,
start_freq: f32,
end_freq: f32,
duration_s: f32,
amplitude: f32,
) -> Self
pub fn chirp( id: u32, position: Position3D, start_freq: f32, end_freq: f32, duration_s: f32, amplitude: f32, ) -> Self
Create a chirp (frequency sweep) source.
Sourcepub fn gaussian_pulse(
id: u32,
position: Position3D,
center_time: f32,
sigma: f32,
amplitude: f32,
) -> Self
pub fn gaussian_pulse( id: u32, position: Position3D, center_time: f32, sigma: f32, amplitude: f32, ) -> Self
Create a Gaussian pulse source.
Sourcepub fn from_samples(
id: u32,
position: Position3D,
samples: Vec<f32>,
sample_rate: u32,
looping: bool,
) -> Self
pub fn from_samples( id: u32, position: Position3D, samples: Vec<f32>, sample_rate: u32, looping: bool, ) -> Self
Create an audio file source.
Sourcepub fn with_radius(self, radius: f32) -> Self
pub fn with_radius(self, radius: f32) -> Self
Set the injection radius (in grid cells).
Sourcepub fn with_directivity(self, directivity: f32) -> Self
pub fn with_directivity(self, directivity: f32) -> Self
Set directivity (1.0 = omnidirectional).
Sourcepub fn set_position(&mut self, pos: Position3D)
pub fn set_position(&mut self, pos: Position3D)
Move the source to a new position.
Sourcepub fn next_sample(&mut self, time_step: f32) -> f32
pub fn next_sample(&mut self, time_step: f32) -> f32
Get the next sample value and advance the source state.
Returns the pressure value to inject at this time step.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if the source has finished (for one-shot sources).
Trait Implementations§
Source§impl Clone for AudioSource
impl Clone for AudioSource
Source§fn clone(&self) -> AudioSource
fn clone(&self) -> AudioSource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AudioSource
impl RefUnwindSafe for AudioSource
impl Send for AudioSource
impl Sync for AudioSource
impl Unpin for AudioSource
impl UnwindSafe for AudioSource
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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