pub struct GenericSource { /* private fields */ }Expand description
See module info.
Implementations§
Source§impl GenericSource
Property key constants
impl GenericSource
Property key constants
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"
Source§impl GenericSource
impl GenericSource
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 GenericSource
impl Clone for GenericSource
Source§fn clone(&self) -> GenericSource
fn clone(&self) -> GenericSource
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 GenericSource
impl Debug for GenericSource
Source§impl Default for GenericSource
impl Default for GenericSource
Source§impl Drop for GenericSource
impl Drop for GenericSource
Source§impl Inspect for GenericSource
impl Inspect for GenericSource
Source§fn properties(&self) -> Vec<PropertyInfo<'_>>
fn properties(&self) -> Vec<PropertyInfo<'_>>
Source§impl Visit for GenericSource
impl Visit for GenericSource
Auto Trait Implementations§
impl Freeze for GenericSource
impl !RefUnwindSafe for GenericSource
impl Send for GenericSource
impl Sync for GenericSource
impl Unpin for GenericSource
impl UnsafeUnpin for GenericSource
impl !UnwindSafe for GenericSource
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.