Skip to main content

StreamingBuffer

Struct StreamingBuffer 

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

Streaming buffer for long sounds. Does not support random access.

Implementations§

Source§

impl StreamingBuffer

Source

pub const STREAM_SAMPLE_COUNT: usize = 44100

Defines amount of samples per channel which each streaming buffer will use for internal buffer.

Source

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

Creates new streaming buffer using given data source. May fail if data source has unsupported format or it has corrupted data. Length of internal generic buffer cannot be changed but can be fetched from StreamingBuffer::STREAM_SAMPLE_COUNT

§Notes

This function will return Err if data source is Raw. It makes no sense to stream raw data which is already loaded into memory. Use Generic source instead!

Source

pub fn duration(&self) -> Option<Duration>

Returns total duration of data. Can be None if internal decoder does not supports seeking.

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 StreamingBuffer

Source§

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

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

impl Default for StreamingBuffer

Source§

fn default() -> StreamingBuffer

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

impl Deref for StreamingBuffer

Source§

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

Returns shared reference to internal generic buffer. Can be useful to get some info (sample rate, channel count).

Source§

type Target = GenericBuffer

The resulting type after dereferencing.
Source§

impl DerefMut for StreamingBuffer

Source§

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

Returns mutable reference to internal generic buffer. Can be used to modify it.

Source§

impl Visit for StreamingBuffer

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,