A low-overhead and adaptable audio playback library for Rust

Overview

Awedio   Docs Passing Latest Version

A low-overhead and adaptable audio playback library for Rust.

Examples

Play a single sound file:

let (mut manager, backend) = awedio::start()?;
manager.play(awedio::sounds::open_file("test.wav")?);
# Ok::<(), Box<dyn std::error::Error>>(())

Play a sound with adjustable volume controllable after playback has started:

use awedio::Sound;
let (mut manager, backend) = awedio::start()?;
let (sound, mut controller) = awedio::sounds::SineWav::new(400.0)
    .with_adjustable_volume_of(0.25)
    .pausable()
    .controllable();
manager.play(Box::new(sound));
std::thread::sleep(std::time::Duration::from_millis(100));
controller.set_volume(0.5);
std::thread::sleep(std::time::Duration::from_millis(100));
controller.set_paused(true);
# Ok::<(), Box<dyn std::error::Error>>(())

Design Goals

  • Usable in low resource environments such as the esp32 microcontroller. Currently does require std.
  • Very low overhead. For example, a Wav file with i16 samples with the same same sample rate as the output device will have samples sent to the backend unchanged.
  • Only pay the performance cost of features if they are needed. For example pausability, volume adjustment, or controlling a sound after playback has started are all added to a Sound only as needed. This is done by wrapping types that implement [Sound] similar to Iterator in the standard library.
  • Samples are i16 for simplicity at least for now (if this prevents you from using this library please let me know your use case)

API Overview

  • Sound trait - Provides samples of a sound to be played. Has functions to modify sounds with wrappers.
  • Manager - Play Sounds to a backend.
  • SoundList - A sequence of Sounds to play one after the other.

Current backends

  • cpal - For popular environments such as Linux, Windows, Mac OS, Android... Enabled by the cpal feature (on by default).
  • esp32 - For esp32 microcontrollers using esp-idf. Implemented in its own crate.

Backends are implemented by pulling samples from the Renderer.

Cargo Features

  • async: Enable async features that depend on tokio-sync
  • cpal: Enable the cpal backend.
  • wav: Enable Wav file decoding using Hound
  • mp3: Enable mp3 file decoding using rmp3

By default all features are enabled. Depending libraries should disable default features.

Motivation

Built for creating activities for 10 Buttons, a screen-less tablet for kids. Purposefully kept generic to be usable in other contexts.

Alternatives and Inspiration

Thanks to the following audio playback libraries which inspired and were a reference for this library:

  • Rodio
    • Very popular crate for audio playback with Rust.
    • Tightly coupled to cpal.
    • Has a Sink which is similar to SoundList::new().pausable().with_adjustable_volume().controllable()...
    • mp3 libraries did not work for me on embedded.
    • Default mixer converts everything to an f32.
    • Uses the standard Iterator trait for its Source/Sound.
  • Kira
    • Has very nice API for tweening and effects.
    • Sound trait requires a left/right track instead of supporting 1 or N tracks.
    • Samples are all f32.
    • Uses symphonia for audio format parsing and has several internal buffers requiring more memory.
    • All samples are resampled based on the timestamp and sample rate.

License

This project is licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You might also like...
DSP real time audio synthesis, effect algorithms and utilities for Rust

synfx-dsp synfx-dsp DSP real time audio synthesis, effect algorithms and utilities for Rust Most of the algorithms and implementations in this library

An open-source and fully-featured Digital Audio Workstation, made by musicians, for musicians
An open-source and fully-featured Digital Audio Workstation, made by musicians, for musicians

Meadowlark An open-source and fully-featured Digital Audio Workstation, made by musicians, for musicians. *Current design mockup, not a functioning pr

An experimental audio visualizer combining fractals and particle simulations.
An experimental audio visualizer combining fractals and particle simulations.

fractal_sugar About the project fractal_sugar is an experimental audio visualizer combining fractals and particle simulations. It is cross-platform, w

Rust - Augmented Audio Libraries
Rust - Augmented Audio Libraries

Augmented Audio Libraries In this repository I'll push some experiments trying to use Rust for audio programming. Goals Goal 1: Learn & have fun This

CLI Rust Audio Visualizer
CLI Rust Audio Visualizer

crav Console-based Rust Audio Visualizer It can run in the terminal but also has a 3D accelerated backend implemented in wgpu. demo compatibility The

MVC audio plugin framework for rust

__ __ | |--.---.-.-----.-----.-----.| |.--.--.-----. | _ | _ |__ --| -__| _ || || | | _ | |

simple-eq is a crate that implements a simple audio equalizer in Rust.

simple-eq A Simple Audio Equalizer simple-eq is a crate that implements a simple audio equalizer in Rust. It supports a maximum of 32 filter bands. Us

A simple GUI audio player written in Rust with egui. Inspired by foobar2000.

Music Player A simple GUI music player inspired by foobar2000 written in Rust using egui. The goal of this project is to learn about making gui/ nativ

Rust Audio Player Daemon

Rust Audio Player Daemon Cause mpd was annoying What rapd trys to do Rapd is not a spotify client, or an advanced music player. Its an audio/music dae

Owner
10 Buttons
Making a programmable button tablet for kids!
10 Buttons
Flutter crossplatform audio playback library powered by golang beep & oto

Rowdy Pure Rust based Dart/Flutter audio playback library Installation $ flutter pub add rowdy Configuration You'll need the Rust toolchain installed

Kingkor Roy Tirtho 3 Aug 31, 2022
A tool that switch default audio playback device on windows.

AudioSwitch A tool built by Rust that can switch default audio playback device on windows. How to use specify which device you want to use Execute it

null 2 Aug 28, 2022
A low-level windowing system geared towards making audio plugin UIs.

baseview A low-level windowing system geared towards making audio plugin UIs. baseview abstracts the platform-specific windowing APIs (winapi, cocoa,

null 155 Dec 30, 2022
Symphonia is a pure Rust audio decoding and media demuxing library supporting AAC, FLAC, MP3, MP4, OGG, Vorbis, and WAV.

Pure Rust multimedia format demuxing, tag reading, and audio decoding library

Philip Deljanov 1k Jan 2, 2023
A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.

OptiVorbis A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without alter

OptiVorbis 27 Jan 3, 2023
Cross-platform audio I/O library in pure Rust

CPAL - Cross-Platform Audio Library Low-level library for audio input and output in pure Rust. This library currently supports the following: Enumerat

null 1.8k Jan 8, 2023
Rust bindings for the soloud audio engine library

soloud-rs A crossplatform Rust bindings for the soloud audio engine library. Supported formats: wav, mp3, ogg, flac. The library also comes with a spe

Mohammed Alyousef 38 Dec 8, 2022
TinyAudio is a cross-platform audio output library

TinyAudio TinyAudio is a cross-platform audio output library. Its main goal to provide unified access to a default sound output device of your operati

Dmitry Stepanov 39 Apr 4, 2023
Implements the free and open audio codec Opus in Rust.

opus-native Overview Implements the free and open audio codec Opus in Rust. Status This crate is under heavy development. Most functionality is not wo

Nils Hasenbanck 9 Nov 28, 2022
Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio

iced baseplug examples Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio WIP (The GUI knobs do nothing curr

Billy Messenger 10 Sep 12, 2022