Library for expressive game audio.
cpal
to 0.15.1cpal
to 0.14.1ringbuf
to 0.3.1PartialEq
for StaticSoundData
, DistortionKind
, DistortionBuilder
, FilterMode
, FilterBuilder
, PanningControlBuilder
, ReverbBuilder
, VolumeControlBuilder
, and TrackRoutes
Debug
for StaticSoundData
and TrackRoutes
Clone
for TrackRoutes
This is a bugfix release, but unfortunately one of the bugfixes did require a breaking change. Fortunately, this breaking change only affects people who have created their own Sound
or Effect
implementations, which is not the most common use case.
Fixes:
StaticSound
with a start position later than the end of the sound0.0
. Now sounds played with negative start positions will output silence until the position reaches 0.0
, at which point normal playback will resume. This is the behavior from versions 0.5.x and prior, and it was not meant to change in 0.6.x.Breaking changes (only for Sound
and Effect
implementations):
on_clock_tick
callback from Sound
, Effect
, and Tweener
Sound::process
, Effect::process
, and Tweener::update
receive a &ClockInfoProvider
argument. ClockInfoProvider
can report the current state of any active clock.ClockHandle::fractional_position
StaticSoundData::with_settings
and StaticSoundData::with_modified_settings
&self
arguments instead of &mut self
(thanks @nobbele!):
ClockHandle::set_speed
ClockHandle::start
ClockHandle::pause
ClockHandle::stop
AudioManager::pause
AudioManager::resume
TrackHandle::set_volume
TrackHandle::set_route
Kira v0.6 is a complete rewrite of Kira with the following goals:
Of course, the overall goals of Kira are the same: provide a library that fills missing niches in most audio libraries and enables people to be creative with their game audio.
Kira now supports streaming sounds! Unlike static sounds, which keep all audio data in memory, streaming sounds decode audio from the filesystem in realtime. This has a much leaner memory footprint at the cost of higher CPU usage.
Sound
traitStatic and streaming sounds are both implementors of the new Sound
trait. Sound
s produce arbitrary streams of audio, so they can be used for both finite sounds or infinite sounds, like voice chat audio. In this sense, they're similar to AudioStream
s from previous versions of Kira, but they can be automatically unloaded when they're finished, and they can receive clock events (see below). They're better integrated with the rest of Kira, making them first class citizens instead of escape hatches.
Kira no longer has any concept of "instances". If you want to play a static sound multiple times, you can clone it each time you want to pass it to AudioManager::play
. (Static sounds share their samples via an Arc
, so cloning is cheap.) Streaming sounds cannot be cloned since each one opens up a new file handle.
Metronomes and sequences from previous versions of Kira were useful for complex audio scripting, but most games don't need such a complex system. In Kira v0.6, they're both replaced by clocks, which are simple timing sources.
Static and streaming sounds can be set to start playing at a certain clock time. Additionally, tweens can be set to start at a clock time. This means anything involving a tween, such as fading out a sound or changing its playback rate, can be synced to a clock.
If you need a more complex system, you should be able to build it in gameplay code using clocks as a building block.
The mixer no longer makes a distinction between sub-tracks and send tracks. Any sub-track can be routed to any number of other sub-tracks.
Previous versions of Kira were hardcoded to use cpal to talk to the operation system's audio drivers. Kira v0.6.0 has a Backend
trait, so you can implement your own backends.
Kira is now available under the MIT or Apache-2.0 license. (Previous versions were only available under MIT.)
Previous versions of Kira had global "parameters" that you could link settings to, like metronome tempos and instance playback rates. The only way to smoothly tween a setting was to link it to a parameter and tween that parameter. It is useful to be able to link multiple settings to one parameter, but the more common use case was to create a parameter just to tween one setting, which isn't very ergonomic.
In Kira v0.6, parameters have been removed, and all settings can be tweened directly. In future versions, I'd like to bring back global parameters and allow users to either tween settings directly or link them to parameters, I just haven't figured out a good way to architect that.
The main purpose of arrangements was to make it easier to create looping music with intro sections. It served that purpose well, but it was overkill for that purpose, and it wouldn't work with streaming sounds.
Groups were meant to help with pausing, resuming, stopping, and unloading large categories of resources. It tried to cover different types of resources with different notions of pausing, resuming, and stopping. It mapped decently to instances and sequences, but I think it would have been likely that future versions of Kira would have a resource type that groups didn't make sense for, and the abstraction would become shakier over time. Furthermore, resource management can be done from gameplay code, so it's not even necessary for Kira to provide this feature.
kira-cpal
and kira-loaders
into the main kira
crate. kira-cpal
and kira-loaders
are now unneeded and deprecated.
CpalBackend
from kira-cpal
is now available as kira::manager::backend::cpal::CpalBackend
kira_loaders::load
and kira_loaders::load_from_cursor
are now StaticSoundData::from_file
and StaticSoundData::from_cursor
kira_loaders::stream
and kira_loaders::stream_from_cursor
are now StreamingSoundData::from_file
and StreamingSoundData::from_cursor
Renderer::on_change_sample_rate
, which the Backend
should call if the audio sample rate changesEffect::on_change_sample_rate
, which is called when the audio sample rate changesBackend
trait:
Backend::settings
and the method Backend::setup
, which is used for creating Backend
s (basically a new
function, but required by the Backend
trait)Backend::init
to Backend::start
Backend::sample_rate
UnusedResourceCollector
from the public API. Backend
s are no longer responsible for dropping unused resources.MockBackend
to the new APIbackend
argument to AudioManager::new
AudioManagerSettings
From<f64>
implementation for ClockSpeed
AudioManager::add_clock
to take a ClockSpeed
argument instead of an impl Into<ClockSpeed>
argumentClock
and Clocks
from the public APIon_clock_tick
callback instead of having a &Clocks
argument passed into process
Value
s can now be tweened directly without needing to link them to a parameterCommandError
as their error typeEffectBuilder
- trait for types that can be converted to an Effect
and a handleEffect
- runs on the rendererTrackSettings
is now TrackBuilder
. Effects can be added by passing an EffectBuilder
to TrackBuilder::add_effect
.Distortion
from the public API, DistortionSettings
is now DistortionBuilder
, added DistortionHandle
Delay
from the public API, DelaySettings
is now DelayBuilder
, added DelayHandle
Reverb
from the public API, ReverbSettings
is now ReverbBuilder
, added ReverbHandle
Filter
from the public API, FilterSettings
is now FilterBuilder
, added FilterHandle
Tweenable
to Tweener
Tweenable
trait for things that a Tweener
can control. Tweener
is now generic over the type of the Tweenable
valueVolume
type instead of f64
PlaybackRate
type instead of f64
ClockSpeed
type instead of f64
TrackBuilder
in AudioManagerSettings