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
impl SoundBufferState
Sourcepub fn raw_streaming(data_source: DataSource) -> Result<Self, DataSource>
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.
Sourcepub fn raw_generic(data_source: DataSource) -> Result<Self, DataSource>
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>§
Sourcepub fn external_data_path(&self) -> &Path
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.
Sourcepub fn set_external_data_path(&mut self, path: PathBuf) -> PathBuf
pub fn set_external_data_path(&mut self, path: PathBuf) -> PathBuf
Sets new path for external data source.
Sourcepub fn samples_mut(&mut self) -> &mut [f32]
pub fn samples_mut(&mut self) -> &mut [f32]
Returns mutable reference to an array with samples that could be modified.
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Returns exact amount of channels in the buffer.
Sourcepub fn sample_rate(&self) -> usize
pub fn sample_rate(&self) -> usize
Returns sample rate of the buffer.
Trait Implementations§
Source§impl Debug for SoundBufferState
impl Debug for SoundBufferState
Source§impl Default for SoundBufferState
impl Default for SoundBufferState
Source§impl Deref for SoundBufferState
impl Deref for SoundBufferState
Source§impl DerefMut for SoundBufferState
impl DerefMut for SoundBufferState
Source§impl ResourceData for SoundBufferState
impl ResourceData for SoundBufferState
Source§impl Visit for SoundBufferState
impl Visit for SoundBufferState
Auto Trait Implementations§
impl Freeze for SoundBufferState
impl !RefUnwindSafe for SoundBufferState
impl Send for SoundBufferState
impl Sync for SoundBufferState
impl Unpin for SoundBufferState
impl UnsafeUnpin for SoundBufferState
impl !UnwindSafe for SoundBufferState
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> 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.