pub struct Mixer<G: Eq + Hash + Send + 'static = ()> { /* private fields */ }
Expand description

Keep track of each Sound, and mix they output together.

Implementations

Create a new Mixer.

The created Mixer output samples with given sample rate and number of channels. This configuration can be changed by calling set_config.

Change the number of channels and the sample rate.

This keep also keep all currently playing sounds, and convert them to the new config, if necessary.

Add new sound to the Mixer.

Return the SoundId associated with that sound. This Id is globally unique.

The added sound is started in stopped state, and play must be called to start playing it. mark_to_remove is true by default.

Start playing the sound associated with the given id.

If the sound was paused or stop, it will start playing again. Otherwise, does nothing.

Pause the sound associated with the given id.

If the sound is playing, it will pause. If play is called, this sound will continue from where it was when paused. If the sound is not playing, does nothing.

Stop the sound associated with the given id.

If the sound is playing, it will pause and reset the song. When play is called, this sound will start from the begging.

Even if the sound is not playing, it will reset the sound to the start. If the sound is marked to be removed, this sound will be removed from the Mixer.

Reset the sound associated with the given id.

This reset the sound to the start, the sound being playing or not.

Set if the sound associated with the given id will loop.

If true, ever time the sound reachs its end, it will reset, and continue to play in a loop.

This also set mark_to_remove to false.

Set the volume of the sound associated with the given id.

The output samples of the SoundSource assicociated with the given id will be multiplied by this volume.

Set the volume of the given group.

The volume of all sounds associated with this group is multiplied by this volume.

Mark if the sound will be removed after it reachs its end.

If false, it will be possible to reset the sound and play it again after it has already reached its end. Otherwise, the sound will be removed when it reachs its end, even if it is marked to loop.

The number of sounds in the mixer.

This include the sounds that are currently stopped.

The number of sounds being played currently.

Does not include the sounds that are currently stopped.

Trait Implementations

Return the number of channels.

Return the sample rate.

Start the sound from the begining.

Write the samples to buffer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.