Expand description
kittyaudio is an audio library focusing on simplicity.
§Example
ⓘ
use kittyaudio::{include_sound, Mixer};
fn main() {
// include a sound into the executable.
// this type can be cheaply cloned.
let sound = include_sound!("jump.ogg").unwrap();
// create sound mixer
let mut mixer = Mixer::new();
mixer.init(); // use init_ex to specify settings
let playing_sound = mixer.play(sound);
playing_sound.set_volume(0.5); // decrease volume
mixer.wait(); // wait for all sounds to finish
}
See more examples in the examples
directory.
§Features
- Low-latency audio playback
- Cross-platform audio playback (including wasm)
- Handle device changes or disconnects in real time
- Low CPU usage
- Minimal dependencies
- Minimal memory allocations
- No
panic!()
or.unwrap()
, always propogate errors - No unsafe code
- Simple API, while being customizable
- Optionally use Symphonia to support most audio formats
- Feature to disable audio playback support, if you want to use kittyaudio purely as an audio library
- Commands to change volume, playback rate, position and panning in the sound with easings
- Loops, and commands to change them with easings
§Roadmap
Those features are not implemented yet.
- Effects (reverb, delay, eq, etc.)
- C API
- Audio streaming from disk
Re-exports§
Macros§
- include_
sound - Includes a sound in the executable. The
symphonia
feature must be enabled for this macro to exist.
Structs§
- Backend
- A wrapper around
cpal
’s stream. TheBackend
will check for device changes or disconnections, handle errors and manage the stream. - Command
- A command that specifies an action that is applied on a
crate::Sound
with an optional tween. - Default
Renderer - Default audio renderer.
- Frame
- Represents an audio sample. Stores a left and right channel.
- Mixer
- Audio mixer. The mixing is done by the
Renderer
(RendererHandle
), and the audio playback is handled by theBackend
. - Parameter
- A parameter (used in
crate::Sound
) that implements tweening the underlying value. - Record
Mixer - A mixer for recording audio.
- Renderer
Handle - Wraps
Renderer
so it can be shared between threads. - Resampler
- Resamples audio from one sample rate to another.
- Sound
- Audio data stored in memory. This type can be cheaply cloned, as the audio data is shared between all clones.
- Sound
Handle - Wraps a
Sound
so it can be returned to the user afterplay
. - Stream
Settings - Wrapper around
cpal
’s stream settings.
Enums§
- Change
- Specifies what change to make to a
crate::Sound
. Used withCommand
. - Device
- Specifies what device
cpal
should use. - Easing
- Specifies what easing function to use.
- KaError
- KittyAudio’s error type.
- Playback
Rate - Specifies how quickly the sound is played.
Traits§
- Renderer
- The audio renderer trait. Can be used to make custom audio renderers.
- Tweenable
- A trait for types that can be used in a
Parameter
.
Functions§
- device_
names - Returns all device names available on the system.
- interpolate_
frame - This is the 4-point, 3rd-order Hermite interpolation x-form algorithm from “Polynomial Interpolators for High-Quality Resampling of Oversampled Audio” by Olli Niemitalo, p. 43: http://yehar.com/blog/wp-content/uploads/2009/08/deip.pdf