pub trait Sound {
// Required methods
fn toggle_pause(&mut self);
fn is_paused(&self) -> bool;
fn toggle_mute(&mut self);
fn is_muted(&self) -> bool;
fn process(&mut self, input: SampleT) -> SampleT;
fn register(&mut self, id: usize);
fn unregister(&mut self);
fn get_id(&self) -> Option<usize>;
}Expand description
This trait defines the interface that anything producing sound that will be
output to a Channel must define.
Required Methods§
Sourcefn toggle_pause(&mut self)
fn toggle_pause(&mut self)
Toggles the pause state of the sound. If the sound is paused, the
internal structures aren’t process during a call to process, instead
only Default::default() is returned.
Sourcefn toggle_mute(&mut self)
fn toggle_mute(&mut self)
Toggles the mute state of the sound. If the sound is muted, the internal
structures are still processed during a call to process, but
Default::default() is returned.
Sourcefn process(&mut self, input: SampleT) -> SampleT
fn process(&mut self, input: SampleT) -> SampleT
Processes the sound and its internal structures, returning the resulting audio sample.
If the sound is paused, no processing of the internal structures is
performed, instead only Default::default() is returned.
If the sound is muted, the internal structures are still processed, but
Default::default() is still returned.
Sourcefn register(&mut self, id: usize)
fn register(&mut self, id: usize)
Sets itself as registered with the given ID.
Caution should be taken when registering and unregistering sounds to or
from a Channel, as Sounds don’t control their own registration.
As such you should be registering through Channel::add_sound.
Sourcefn unregister(&mut self)
fn unregister(&mut self)
Sets itself as unregistered and clears the saved ID.
Caution should be taken when registering and unregistering sounds to or
from a Channel as Sounds don’t control their own registration.
As such you should be registering through Channel::remove_sound.