Skip to main content

GenericSource

Struct GenericSource 

Source
pub struct GenericSource { /* private fields */ }
Expand description

See module info.

Implementations§

Source§

impl GenericSource

Property key constants

Source

pub const NAME: &'static str = "name"

Source

pub const BUFFER: &'static str = "buffer"

Source

pub const PANNING: &'static str = "panning"

Source

pub const PITCH: &'static str = "pitch"

Source

pub const GAIN: &'static str = "gain"

Source

pub const LOOPING: &'static str = "looping"

Source

pub const RESAMPLING_MULTIPLIER: &'static str = "resampling_multiplier"

Source

pub const STATUS: &'static str = "status"

Source

pub const PLAY_ONCE: &'static str = "play_once"

Source§

impl GenericSource

Source

pub fn set_name<N: AsRef<str>>(&mut self, name: N)

Sets new name of the sound source.

Source

pub fn name(&self) -> &str

Returns the name of the sound source.

Source

pub fn name_owned(&self) -> String

Returns the name of the sound source.

Source

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.

Source

pub fn buffer(&self) -> Option<SoundBufferResource>

Returns current buffer if any.

Source

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.

Source

pub fn is_play_once(&self) -> bool

Returns true if this source is marked for single play, false - otherwise.

Source

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.

Source

pub fn gain(&self) -> f32

Returns current gain (volume) of sound. Value is in 0..1 range.

Source

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.

Source

pub fn panning(&self) -> f32

Returns current panning coefficient in -1..+1 range. For more info see set_panning. Default value is 0.

Source

pub fn status(&self) -> Status

Returns status of sound source.

Source

pub fn play(&mut self) -> &mut Self

Changes status to Playing.

Source

pub fn pause(&mut self) -> &mut Self

Changes status to Paused

Source

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.

Source

pub fn is_looping(&self) -> bool

Returns looping status.

Source

pub fn set_pitch(&mut self, pitch: f64) -> &mut Self

Sets sound pitch. Defines “tone” of sounds. Default value is 1.0

Source

pub fn pitch(&self) -> f64

Returns pitch of sound source.

Source

pub fn stop(&mut self) -> Result<(), SoundError>

Stops sound source. Automatically rewinds streaming buffers.

Source

pub fn playback_time(&self) -> Duration

Returns playback duration.

Source

pub fn set_playback_time(&mut self, time: Duration)

Sets playback duration.

Trait Implementations§

Source§

impl Clone for GenericSource

Source§

fn clone(&self) -> GenericSource

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GenericSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GenericSource

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for GenericSource

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Inspect for GenericSource

Source§

fn properties(&self) -> Vec<PropertyInfo<'_>>

Returns information about “public” properties.
Source§

impl Visit for GenericSource

Source§

fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> PropertyValue for T
where T: Debug + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ResourceLoadError for T
where T: 'static + Debug + Send + Sync,