pub enum SoundSource {
Generic(GenericSource),
Spatial(SpatialSource),
}Expand description
See module docs.
Variants§
Implementations§
Source§impl SoundSource
impl SoundSource
Sourcepub fn spatial(&self) -> &SpatialSource
pub fn spatial(&self) -> &SpatialSource
Tries to “cast” sound source to spatial source. It will panic if this is not spatial source. This is useful method for situations where you definitely know that source is spatial. So there is no need to use pattern matching to take reference as a spatial source.
Sourcepub fn spatial_mut(&mut self) -> &mut SpatialSource
pub fn spatial_mut(&mut self) -> &mut SpatialSource
Tries to “cast” sound source to spatial source. It will panic if this is not spatial source. This is useful method for situations where you definitely know that source is spatial. So there is no need to use pattern matching to take reference as a spatial source.
Methods from Deref<Target = GenericSource>§
pub const NAME: &'static str = "name"
pub const BUFFER: &'static str = "buffer"
pub const PANNING: &'static str = "panning"
pub const PITCH: &'static str = "pitch"
pub const GAIN: &'static str = "gain"
pub const LOOPING: &'static str = "looping"
pub const RESAMPLING_MULTIPLIER: &'static str = "resampling_multiplier"
pub const STATUS: &'static str = "status"
pub const PLAY_ONCE: &'static str = "play_once"
Sourcepub fn name_owned(&self) -> String
pub fn name_owned(&self) -> String
Returns the name of the sound source.
Sourcepub fn set_buffer(
&mut self,
buffer: Option<SoundBufferResource>,
) -> Result<Option<SoundBufferResource>, SoundError>
pub fn set_buffer( &mut self, buffer: Option<SoundBufferResource>, ) -> Result<Option<SoundBufferResource>, SoundError>
Changes buffer of source. Returns old buffer. Source will continue playing from beginning, old position will be discarded.
Sourcepub fn buffer(&self) -> Option<SoundBufferResource>
pub fn buffer(&self) -> Option<SoundBufferResource>
Returns current buffer if any.
Sourcepub fn set_play_once(&mut self, play_once: bool)
pub fn set_play_once(&mut self, play_once: bool)
Marks buffer for single play. It will be automatically destroyed when it will finish playing.
§Notes
Make sure you not using handles to “play once” sounds, attempt to get reference of “play once” sound may result in panic if source already deleted. Looping sources will never be automatically deleted because their playback never stops.
Sourcepub fn is_play_once(&self) -> bool
pub fn is_play_once(&self) -> bool
Returns true if this source is marked for single play, false - otherwise.
Sourcepub fn set_gain(&mut self, gain: f32) -> &mut Self
pub fn set_gain(&mut self, gain: f32) -> &mut Self
Sets new gain (volume) of sound. Value should be in 0..1 range, but it is not clamped and larger values can be used to “overdrive” sound.
§Notes
Physical volume has non-linear scale (logarithmic) so perception of sound at 0.25 gain will be different if logarithmic scale was used.
Sourcepub fn set_panning(&mut self, panning: f32) -> &mut Self
pub fn set_panning(&mut self, panning: f32) -> &mut Self
Sets panning coefficient. Value must be in -1..+1 range. Where -1 - only left channel will be audible, 0 - both, +1 - only right.
Sourcepub fn panning(&self) -> f32
pub fn panning(&self) -> f32
Returns current panning coefficient in -1..+1 range. For more info see set_panning. Default value is 0.
Sourcepub fn set_looping(&mut self, looping: bool) -> &mut Self
pub fn set_looping(&mut self, looping: bool) -> &mut Self
Enabled or disables sound looping. Looping sound will never stop by itself, but can be stopped or paused
by calling stop or pause methods. Useful for music, ambient sounds, etc.
Sourcepub fn is_looping(&self) -> bool
pub fn is_looping(&self) -> bool
Returns looping status.
Sourcepub fn set_pitch(&mut self, pitch: f64) -> &mut Self
pub fn set_pitch(&mut self, pitch: f64) -> &mut Self
Sets sound pitch. Defines “tone” of sounds. Default value is 1.0
Sourcepub fn stop(&mut self) -> Result<(), SoundError>
pub fn stop(&mut self) -> Result<(), SoundError>
Stops sound source. Automatically rewinds streaming buffers.
Sourcepub fn playback_time(&self) -> Duration
pub fn playback_time(&self) -> Duration
Returns playback duration.
Sourcepub fn set_playback_time(&mut self, time: Duration)
pub fn set_playback_time(&mut self, time: Duration)
Sets playback duration.
Trait Implementations§
Source§impl Clone for SoundSource
impl Clone for SoundSource
Source§fn clone(&self) -> SoundSource
fn clone(&self) -> SoundSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SoundSource
impl Debug for SoundSource
Source§impl Default for SoundSource
impl Default for SoundSource
Source§impl Deref for SoundSource
impl Deref for SoundSource
Source§impl DerefMut for SoundSource
impl DerefMut for SoundSource
Source§impl Inspect for SoundSource
impl Inspect for SoundSource
Source§fn properties(&self) -> Vec<PropertyInfo<'_>>
fn properties(&self) -> Vec<PropertyInfo<'_>>
Source§impl Visit for SoundSource
impl Visit for SoundSource
Auto Trait Implementations§
impl Freeze for SoundSource
impl !RefUnwindSafe for SoundSource
impl Send for SoundSource
impl Sync for SoundSource
impl Unpin for SoundSource
impl UnsafeUnpin for SoundSource
impl !UnwindSafe for SoundSource
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PropertyValue for Twhere
T: Debug + 'static,
impl<T> PropertyValue for Twhere
T: Debug + 'static,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.