Skip to main content

GenericBuffer

Struct GenericBuffer 

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

Generic sound buffer that contains decoded samples and allows random access.

Implementations§

Source§

impl GenericBuffer

Source

pub fn new(source: DataSource) -> Result<Self, DataSource>

Creates new generic buffer from specified data source. May fail if data source has unsupported format, corrupted, etc.

§Notes

DataSource::RawStreaming is not supported with generic buffers, use streaming buffer instead!

Data source with raw samples must have sample count multiple of channel count, otherwise this function will return Err.

Source

pub fn external_data_path(&self) -> &Path

In case if buffer was created from file, this method returns file name. Can be useful for serialization needs where you just need to know which file needs to be reloaded from disk when you loading a saved game.

Source

pub fn set_external_data_path(&mut self, path: PathBuf) -> PathBuf

Sets new path for external data source.

Source

pub fn is_empty(&self) -> bool

Checks if buffer is empty or not.

Source

pub fn samples(&self) -> &[f32]

Returns shared reference to an array with samples.

Source

pub fn samples_mut(&mut self) -> &mut [f32]

Returns mutable reference to an array with samples that could be modified.

Source

pub fn channel_count(&self) -> usize

Returns exact amount of channels in the buffer.

Source

pub fn sample_rate(&self) -> usize

Returns sample rate of the buffer.

Source

pub fn duration(&self) -> Duration

Returns exact duration of the buffer.

Trait Implementations§

Source§

impl Debug for GenericBuffer

Source§

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

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

impl Default for GenericBuffer

Source§

fn default() -> GenericBuffer

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

impl Visit for GenericBuffer

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> 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, 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,