Skip to main content

nexcore_audio/
lib.rs

1// Copyright (c) 2026 Matthew Campion, PharmD; NexVigilant
2// All Rights Reserved. See LICENSE file for details.
3
4//! # NexCore Audio — OS Audio Subsystem
5//!
6//! Pure-Rust audio primitives for the NexCore operating system. Provides
7//! sample formats, device abstraction, streaming, mixing, and codec support.
8//!
9//! ## Architecture
10//!
11//! ```text
12//! ┌─────────────────────────────────────────┐
13//! │            Application Layer              │
14//! │  play_sound() │ record() │ set_volume()  │
15//! ├─────────────────────────────────────────┤
16//! │              Mixer (Σ)                   │
17//! │  Source combination │ Volume │ Pan │ Solo │
18//! ├─────────────────────────────────────────┤
19//! │           Stream Engine (σ)              │
20//! │  Playback/Capture │ Ring Buffer │ State  │
21//! ├─────────────────────────────────────────┤
22//! │           Codec Layer (μ)                │
23//! │  S16↔F32 │ Resample │ Channel Remap     │
24//! ├─────────────────────────────────────────┤
25//! │          Device Layer (∃)                │
26//! │  Discovery │ Capabilities │ Hot-plug     │
27//! ├─────────────────────────────────────────┤
28//! │          Platform (PAL)                  │
29//! │  ALSA │ PulseAudio │ PipeWire │ CoreAudio│
30//! └─────────────────────────────────────────┘
31//! ```
32//!
33//! ## Primitive Grounding
34//!
35//! | Component | Primitives | Role |
36//! |-----------|-----------|------|
37//! | Sample types | N + ν | Numeric audio representation |
38//! | Ring buffer | σ + ∂ + N | Bounded sequential data |
39//! | Device model | ∃ + ς + Σ | Device existence & state |
40//! | Streams | σ + ς + ∂ | Stateful bounded flow |
41//! | Mixer | Σ + N + ∂ | Source combination with clipping |
42//! | Codecs | μ + Σ + N | Format mapping between variants |
43
44#![forbid(unsafe_code)]
45#![warn(missing_docs)]
46#![cfg_attr(
47    not(test),
48    deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)
49)]
50
51pub mod buffer;
52pub mod codec;
53pub mod composites;
54pub mod device;
55pub mod error;
56pub mod mixer;
57pub mod prelude;
58pub mod sample;
59pub mod stream;
60
61// Re-export main types
62pub use buffer::AudioBuffer;
63pub use codec::{CodecId, ConversionSpec, ResampleQuality};
64pub use device::{AudioDevice, DeviceCapabilities, DeviceId, DeviceState, DeviceType};
65pub use error::AudioError;
66pub use mixer::{Mixer, MixerSource};
67pub use sample::{AudioSpec, ChannelLayout, SampleFormat, SampleRate};
68pub use stream::{AudioStream, StreamDirection, StreamId, StreamState};