Skip to content

Releases: tesselode/kira

v0.10.4

17 Feb 04:36
Compare
Choose a tag to compare
  • Clamp all audio internally to the -1.0 to 1.0 range

From my testing, not all audio drivers clamp audio signals to the -1.0 to 1.0 range before applying the operating system volume, so in cases where Kira would have previously played sounds outside of that range, your application would play audio that's unexpectedly loud for the operating system's volume setting. This change prevents Kira from playing anything louder than it's "supposed" to.

v0.10.3

10 Feb 03:25
Compare
Choose a tag to compare
  • Clamp some parameters to valid values

v0.10.2

18 Jan 01:14
Compare
Choose a tag to compare
  • Add Static/StreamingSoundData::unsliced_duration (thanks @Roms1383!)

v0.10.1

08 Jan 13:28
Compare
Choose a tag to compare
  • Fix spatial audio tracks immediately outputting non-spatialized audio if the corresponding listener is dropped. This could result in unexpectedly loud audio playback. Now if the listener is dropped, the spatial track will output silence.

v0.10.0

06 Jan 02:34
Compare
Choose a tag to compare

Buffered audio

Kira now processes audio in chunks instead of one sample at a time. This means that Sound::process no longer returns a Frame; instead it receives a slice of Frames to overwrite. Effect::process takes an input slice instead of a single frame, and it overwrites that slice instead of returning a new Frame.

The benefit of this change is significantly improved performance. The criterion benchmarks aren't comparable to the ones in v0.9.x and earlier, but in my unscientific test, I can play about twice as many sounds on my PC without crackling.

There are some tradeoffs, but I think they're reasonable:

  • Modulators are no longer sample accurate. Instead, they update once per internal processing chunk. Sounds and effects can interpolate between the previous and current modulator value using Parameter::interpolated_value to avoid discontinuities.
  • Clocks are no longer sample accurate. For my use case which involves dynamically generating music, the default internal buffer size of 128 frames sounds almost exactly the same as sample-accurate clocks. You can adjust the internal buffer size to get the right tradeoff of performance vs. accuracy for your game. I have some ideas for how sample-accurate clocks could be implemented within the buffered architecture, so if you find yourself needing sample-accurate clocks, let me know!
  • The delay effect can no longer have its delay time changed after the fact. If you know how to implement a delay that can smoothly change its delay time with the buffered architecture, please make a PR!

Hierarchical mixer

Sounds now live inside mixer tracks. Previously, to play a sound on a mixer track, you would use StaticSoundData/StreamingSoundData::output_destination. Now, you pass the sound to TrackHandle::play. Additionally, tracks can contain other tracks. Tracks can also route their outputs to send tracks, which are a separate concept now. This change enables the following feature:

Pausing and resuming mixer tracks

Mixer tracks can now be paused and resumed. Pausing a mixer track pauses all sounds playing on the track, as well as all child tracks.

Spatial audio overhaul

The concepts of spatial scenes and emitters have been removed, and listeners no longer output to a mixer track. Instead, mixer tracks can optionally have spatial properties, like position and spatialization strength. Sounds and child tracks on the track will have spatialization applied relative to a specified listener.

This release also adds Value::FromListenerDistance, which can be used to map sound and effect parameters to the distance between a spatial track and its corresponding listener.

Simplified volume and playback rate types

Previously, Volume was an enum with Amplitude and Decibels variants, and PlaybackRate was an enum with Factor and Semitones variants. There's a couple problems with this:

  • It's unclear what scale a tween uses when tweening from one variant to another. For instance, if you tween a Volume::Amplitude to a Volume::Decibels with linear easing, is it linear in the amplitude domain or decibels?
  • Amplitude isn't a good default representation for volume because it's not perceptually linear.

Now, everything that previously used Volume uses the simpler Decibels type, and PlaybackRate always contains a factor. (Semitones still exists as a separate type that implements Into<PlaybackRate>).

There's also a new Panning type that's used instead of bare f64s. Panning has been changed so -1.0 is left instead of 0.0, since this makes more sense mathematically.

Other changes

  • Reorganized some types and modules to reduce unnecessary nesting
  • Added WaitingToResume and Resuming variants to PlaybackState
  • Changes to Mapping:
    • Added an easing field
    • Inputs are now always clamped to the input range
    • Removed the Default implementation
    • Added methods for performing math operations on the output range
  • Implemented some math operations to Value
  • Changed the fields of Capacities back to u64s
  • ClockInfoProvider and ModulatorValueProvider and now combined into one
    Info struct, which also provides info about spatial audio state
  • Added CpalBackend::pop_cpu_usage (desktop only for now)

v0.9.6

10 Nov 07:44
Compare
Choose a tag to compare
  • Improve performance when adding or subtracting large f64s from a ClockTime (thanks @crabm4n!)
  • Fix UB detected by miri in the stacked borrows model (thanks @Imberflur!)

v0.9.5

02 Sep 04:42
Compare
Choose a tag to compare
  • Update glam to 0.29.0

v0.9.4

10 Aug 01:16
Compare
Choose a tag to compare
  • Fix bug where static sounds played backwards would never be marked as finished, and thus never unloaded
  • Update triple_buffer to 8.0.0

v0.9.3

15 Jun 07:38
Compare
Choose a tag to compare
  • Update glam to 0.28.0

v0.9.2

03 Jun 01:45
Compare
Choose a tag to compare
  • Fix StaticSoundHandle/StreamingSoundHandle::pause/resume/stop not taking effect immediately if the sound has a start time. This was an unintended change from the behavior in v0.8.x and earlier versions.
  • Fix sounds erroneously reporting their state as Playing before playback has resumed after calling StaticSoundHandle/StreamingSoundHandle::resume_at with a non-immediate StartTime
  • Fix sounds entering a limbo state where they output no sound and can never be unloaded when their output destination (track or emitter) is removed
  • Fix a bug where static sounds could enter a limbo state where they're stopped, but never unloaded if the clock they're waiting on is removed