shuyi_sound/lib.rs
1//! Decoded sound: [`Pcm`] holds samples, a [`Source`] yields them in bounded
2//! chunks, optional adapters make a source of a file's bytes, and [`mix::Mixer`]
3//! adds up what is playing. It knows nothing else of the engine, reads no file and
4//! opens no device.
5//!
6//! - [`pcm`]: holds [`Pcm`], its [`PcmFormat`], the [`Limits`] on what a decoder may
7//! produce, and sample width conversions.
8//! - [`source`]: has the [`Source`] trait, [`PcmSource`], [`SharedSource`] and
9//! [`read_all`].
10//! - [`mix`]: the integer [`Mixer`](mix::Mixer), its [`queue`](mix::queue) from
11//! another thread, and the [`stream`](mix::stream) feed from a worker.
12//! - [`error`]: what can go wrong, [`Error`].
13//! - `wav` (feature `wav`): `WavSource`, over the `hound` crate.
14//! - `vorbis` (feature `vorbis`): `VorbisSource`, over the `lewton` crate, with
15//! a file's comments and page positions.
16//!
17//! Without features the crate is `no_std` with `alloc`. Samples are whole
18//! numbers from end to end, the mix's too; the one float is a float WAV's own
19//! sample on its way in.
20//!
21//! A malformed file gives an [`Error`], never a panic. The decoding libraries
22//! are behind a guard that turns their panics into errors where the target can
23//! unwind, which `wasm32-unknown-unknown` can't.
24
25#![cfg_attr(not(any(feature = "std", test)), no_std)]
26#![cfg_attr(not(test), deny(clippy::float_arithmetic))]
27
28extern crate alloc;
29
30pub mod error;
31pub mod mix;
32pub mod pcm;
33pub mod source;
34
35#[cfg(any(feature = "wav", feature = "vorbis"))]
36mod guard;
37#[cfg(feature = "vorbis")]
38pub mod vorbis;
39#[cfg(feature = "wav")]
40pub mod wav;
41
42pub use error::Error;
43pub use pcm::{Channels, Limits, Pcm, PcmFormat};
44pub use source::{PcmSource, SharedSource, Source, read_all};