bae_rs::sounds

Trait Sound

Source
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§

Source

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.

Source

fn is_paused(&self) -> bool

Returns the pause state of the sound.

Source

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.

Source

fn is_muted(&self) -> bool

Returns the mute state of the sound.

Source

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.

Source

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.

Source

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.

Source

fn get_id(&self) -> Option<usize>

Returns the ID given to the Sound during registration with a Channel. If the Sound is unregistered, it will return None.

Implementors§