11 releases (4 breaking)

0.5.3 May 31, 2021
0.5.2 Apr 28, 2021
0.5.1 Mar 29, 2021
0.4.1 Jan 24, 2021
0.1.1 Nov 18, 2020

#18 in Audio

Download history 169/week @ 2021-08-13 538/week @ 2021-08-20 489/week @ 2021-08-27 142/week @ 2021-09-03 271/week @ 2021-09-10 174/week @ 2021-09-17 144/week @ 2021-09-24 168/week @ 2021-10-01 117/week @ 2021-10-08 250/week @ 2021-10-15 240/week @ 2021-10-22 116/week @ 2021-10-29 227/week @ 2021-11-05 336/week @ 2021-11-12 250/week @ 2021-11-19 411/week @ 2021-11-26

1,249 downloads per month
Used in 8 crates (3 directly)

MIT license

275KB
7K SLoC

Kira

Documentation | Web demo (source)

Kira is an audio library designed to help create expressive audio for games. Besides the common features you'd expect from an audio library, it provides interfaces for scripting audio events, seamlessly looping complex pieces of music, smoothly changing parameters, and more.

Examples

Simple sound playback

let mut audio_manager = AudioManager::new(AudioManagerSettings::default())?;
let mut sound_handle = audio_manager.load_sound("sound.ogg", SoundSettings::default())?;
sound_handle.play(InstanceSettings::default())?;

Looping a song while preserving trailing sounds

let sound_handle = audio_manager.load_sound(
	"loop.ogg",
	SoundSettings::new().semantic_duration(Tempo(128.0).beats_to_seconds(8.0)),
)?;
let mut arrangement_handle = audio_manager.add_arrangement(Arrangement::new_loop(
	&sound_handle,
	LoopArrangementSettings::default(),
))?;
arrangement_handle.play(InstanceSettings::default())?;

Playing sounds and emitting events in time with a metronome

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum CustomEvent {
	Kick,
}

let kick_sound_handle = audio_manager.load_sound("kick.wav", SoundSettings::default())?;
let mut metronome_handle =
	audio_manager.add_metronome(MetronomeSettings::new().tempo(Tempo(150.0)))?;
audio_manager.start_sequence(
	{
		let mut sequence = Sequence::new(SequenceSettings::default());
		sequence.start_loop();
		sequence.play(&kick_sound_handle, InstanceSettings::default());
		sequence.emit(CustomEvent::Kick);
		sequence.wait(kira::Duration::Beats(1.0));
		sequence
	},
	SequenceInstanceSettings::new().metronome(&metronome_handle),
)?;
metronome_handle.start()?;

Platform support

Kira should support all of the platforms supported by cpal. Windows, Linux, and WASM have been tested.

Roadmap

Kira is in early development, and is not production ready. Here are some features that I'd like the library to have:

  • More mixer effects (EQ, compressor, better reverb, etc.)
  • C API
  • Streaming sounds
  • 3d audio (maybe!)

Contributing

I'd love for other people to get involved with development! Since the library is still in the early stages, I'm open to all kinds of input - bug reports, feature requests, design critiques, etc. Feel free to open an issue or pull request!

License

MIT

Dependencies

~1.5–5MB
~107K SLoC