Skip to main content

SoundBufferState

Enum SoundBufferState 

Source
pub enum SoundBufferState {
    Generic(GenericBuffer),
    Streaming(StreamingBuffer),
}
Expand description

Sound buffer is a data source for sound sources. See module documentation for more info.

Variants§

§

Generic(GenericBuffer)

General-purpose buffer, usually contains all the data and allows random access to samples. It is also used to make streaming buffer via composition.

§

Streaming(StreamingBuffer)

Buffer that will be filled by small portions of data only when it is needed. Ideal for large sounds (music, ambient, etc.), because unpacked PCM data takes very large amount of RAM. Allows random access only to currently loaded block, so in general there is no true random access.

Implementations§

Source§

impl SoundBufferState

Source

pub fn raw_streaming(data_source: DataSource) -> Result<Self, DataSource>

Tries to create new streaming sound buffer from a given data source. It returns raw sound buffer that has to be wrapped into Arc<Mutex<>> for use with sound sources.

Source

pub fn raw_generic(data_source: DataSource) -> Result<Self, DataSource>

Tries to create new generic sound buffer from a given data source. It returns raw sound buffer that has to be wrapped into Arc<Mutex<>> for use with sound sources.

Methods from Deref<Target = GenericBuffer>§

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 SoundBufferState

Source§

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

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

impl Default for SoundBufferState

Source§

fn default() -> Self

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

impl Deref for SoundBufferState

Source§

fn deref(&self) -> &Self::Target

Returns shared reference to generic buffer for any enum variant. It is possible because streaming sound buffers are built on top of generic buffers.

Source§

type Target = GenericBuffer

The resulting type after dereferencing.
Source§

impl DerefMut for SoundBufferState

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Returns mutable reference to generic buffer for any enum variant. It is possible because streaming sound buffers are built on top of generic buffers.

Source§

impl ResourceData for SoundBufferState

Source§

fn path(&self) -> Cow<'_, Path>

Returns path of resource data.
Source§

fn set_path(&mut self, path: PathBuf)

Sets new path to resource data.
Source§

impl Visit for SoundBufferState

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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,