pub struct Sound { /* private fields */ }Expand description
A sound that can be played by the runtime.
Internally stores data as an array of 32 bit floating point values that range from -1.0 to 1.0
Implementations§
Source§impl Sound
impl Sound
Sourcepub fn from_data(sample_rate: i32, samples: &[f32]) -> Self
pub fn from_data(sample_rate: i32, samples: &[f32]) -> Self
Create a sound from a slice of existing data
§Arguments
sample_rate- the number of samples per seconddata- slice of existing data
Sourcepub fn with_buffer_size(sample_rate: i32, sample_count: i32) -> Self
pub fn with_buffer_size(sample_rate: i32, sample_count: i32) -> Self
Create a blank/silent sound
§Arguments
sample_rate- the number of samples per secondsample_count- the number of samples
Sourcepub fn with_buffer_sized_to_step(
sample_rate: i32,
steps_per_second: i32,
) -> Self
pub fn with_buffer_sized_to_step( sample_rate: i32, steps_per_second: i32, ) -> Self
Create a sound with the number of samples needed to cover a specific step time
§Arguments
sample_rate- the number of samples per secondsteps_per_second- the number of steps per second
Sourcepub fn set_sample(&mut self, index: i32, sample: f32)
pub fn set_sample(&mut self, index: i32, sample: f32)
Sourcepub fn sample_rate(&self) -> i32
pub fn sample_rate(&self) -> i32
Gets the sample rate of the sound
Sourcepub fn sample_count(&self) -> i32
pub fn sample_count(&self) -> i32
Gets the number of samples stored in this sound
Sourcepub fn samples_mut(&mut self) -> &mut [f32]
pub fn samples_mut(&mut self) -> &mut [f32]
Gets a mutable reference to the raw sample data
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Sound
impl<'de> Deserialize<'de> for Sound
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Sound
impl RefUnwindSafe for Sound
impl Send for Sound
impl Sync for Sound
impl Unpin for Sound
impl UnwindSafe for Sound
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
Mutably borrows from an owned value. Read more