Module kira::instance [−][src]
Expand description
Individual occurrences of Sound
s
and Arrangement
s.
You can control the volume and playback rate of individual instances as well as pausing, resuming, and stopping them.
Examples
Playing a sound at a lower playback rate than normal
let instance_handle = sound.play(InstanceSettings::new().playback_rate(0.5))?;
Fading out a sound over 2 seconds
instance_handle.stop(StopInstanceSettings::new().fade_tween(Some(2.0.into())))?;
Reverse playback and loop points
There are two ways to enable reverse playback:
- Enabling the reverse setting
- Setting the playback rate of the instance to a negative number
Enabling the reverse setting also adjusts the instance’s starting position to be relative to the end of the sound, while setting the playback rate to a negative number doesn’t. In 99% of cases, if you want an instance to play backwards, you should use the reverse flag.
You can get some interesting effects by tweening a playback rate from a positive to a negative number and vice versa, so there’s still some value to using negative playback rates.
If you have the reverse playback enabled and the playback rate is negative, you will end up with forward playback.
If the instance has a loop start point and it’s playing backward, when the playback position is earlier than the loop start point, it will wrap around to the end of the instance.
Modules
handle | An interface for controlling instances of sounds and arrangements. |
Structs
InstanceId | A unique identifier for an instance. |
InstanceSettings | Settings for an instance. |
PauseInstanceSettings | Settings for pausing an instance. |
ResumeInstanceSettings | Settings for resuming an instance. |
StopInstanceSettings | Settings for stopping an instance. |
Enums
InstanceLoopStart | A loop start point for an instance. |
InstanceState | The playback state of the instance. |
InstanceTrackIndex | A track index for an instance to play on. |