Expand description
§Ez-Audi
A lightweight Linux/WASM compatible audio library based on cpal
§Features (as of now):
- Read and play LPcm WAVE (.wav) files
- Apply modifiers to the samples for Volume, Looping, etc..
- Control over the raw audio samples
- Get audio file metadata
§Supports (as of now):
- Linux
- LPcm WAVE files
- WASM (See
Usage in WASM environment) (Windows is has not been tested yet)
§Get started
use ez_audi::audio_files::WavAudio;
use ez_audi::public_traits::*;
let wav_audio = WavAudio::build_from_path("test_assets/u8-stereo-lpcm.wav").unwrap();
// Creates an audio player, keep it in scope to keep the audio playing
let player = wav_audio.play_on_default_output(false).unwrap();
std::thread::sleep(std::time::Duration::from_secs(2));§Usage in WASM environment:
Whilst ez-audi is fairly easy to use in WASM, there are some surprises:
- Playback needs to be started/resumed inside a user gesture (button click, etc.). Playback does not start automatically.
- You most likely want to get files (or their data at least) from your website through GET requests. I would recomend using the
Cursorstruct from std to turn aVecof bytes into a reader. Whilst the functions for building struct from files/paths still exists, they are useless in WASM. - Note that, like in all other enviroments, you need to keep your SamplesPlayer in memory for playback.
§What is left to do:
- Pretty much everything, don’t use this in any serious projects unless you enjoy relying on unstable, buggy code
- The documentation is also very much lacking
Re-exports§
pub use samples_player::SamplesPlayer;pub use samples_player::modifiers;
Modules§
- audio_
files - Functions and structs for dealing with audio files and their audio_codecs
- public_
traits - A collection of most of the traits you need to work with this library, note that the traits are also present in the modules where they are relevent
- samples
- Functions and structs for closely working with samples
- samples_
player - Contains all the types of sample players, use SamplesPlayer for speed and ExactSamplesPlayer for control
Structs§
- Device
- An abstraction over cpal::Device, represents a physical output device
- Stream
- An audio stream, stops the stream when dropped
Enums§
- Play
Error - The error type used allthrought the ez_audi crate