audio_samples 1.0.13

A typed audio processing library for Rust that treats audio as a first-class, invariant-preserving object rather than an unstructured numeric buffer.
Documentation
[package]
name = "audio_samples"
version = "1.0.13"
edition = "2024"
authors = ["Jack Geraghty <jgeraghty049@gmail.com>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/jmg049/audio_samples"
repository = "https://github.com/jmg049/audio_samples"
documentation = "https://docs.rs/audio_samples"
description = "A typed audio processing library for Rust that treats audio as a first-class, invariant-preserving object rather than an unstructured numeric buffer."

keywords = ["audio", "dsp", "api"]
categories = ["encoding", "multimedia", "science"]

[package.metadata.docs.rs]
features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]

[lib]
name = "audio_samples"
crate-type = ["rlib"]

[dependencies]
bytemuck = "1.25.0"
ndarray = "0.17"
num-traits = "0.2"
thiserror = "2.0"
miette = "7"
num-complex = "0.4"
i24 = { version = "2.3.4", features = [
    "alloc",
    "num-cast",
    "ndarray",
    "std",
] }

serde = { version = "1.0", features = ["derive"], optional = true }
rand = { version = "0.10.1", optional = true }
wide = { version = "1.5.0", optional = true }
spectrograms = { version = "1.4.2", optional = true }

serde_json = { version = "1.0.150", optional = true }

plotly = { version = "0.14.1", optional = true }
plotly_static = { version = "0.1.0", features = [
    "chromedriver",
    "webdriver_download",
], optional = true }
html_view = { version = "0.2.2", optional = true }
base64 = { version = "0.22", optional = true }

rubato = { version = "3.0.0", optional = true }
rayon = { version = "1.12.0", optional = true }
explainable = { version = "0.1.1", optional = true }
term-maths = { version = "1.0.0", optional = true }
open = { version = "5.3.5", optional = true }

rustfft = { version = "6.2", optional = true }
non-empty-slice = "0.6"
non-empty-iter = "0.3.1"
audioadapter = { version =  "3.0.0",  optional = true }
audioadapter-buffers = { version = "3.0.0", optional = true }

[features]
# Minimal core (no heavy dependencies)
default = ["bare-bones"]

# Coloured caret-underline diagnostic rendering via miette's `fancy` renderer.
# Library consumers get plain `Display` unless they opt in; examples and the
# `educational` module enable this so the pretty output is visible by default.
fancy = ["miette/fancy"]

# Core operation categories
statistics = [] # Basic stats: peak, rms, mean
processing = ["statistics"] # Basic processing: normalize, scale, clip
transforms = ["dep:spectrograms", "dep:rustfft"]
editing = [
    "statistics",
    "random-generation",
] # Time operations: trim, pad, reverse (includes noise)
beat-tracking = ["onset-detection"] # Beat tracking operations
onset-detection = [
    "transforms",
    "peak-picking",
    "processing",
] # Onset detection operations
decomposition = [
    "onset-detection",
] # Audio decomposition operations (requires serialization)
dynamic-range = [] # Dynamic range compression/expansion operations
channels = [] # Channel operations: interleave/deinterleave
iir-filtering = [] # IIR filtering operations
parametric-eq = ["iir-filtering", "channels"] # Parametric equalization operations
peak-picking = [] # Peak picking operations
pitch-analysis = ["transforms"] # Pitch analysis operations
resampling = ["dep:rubato", "dep:rayon", "audioadapter", "audioadapter-buffers"] # Resampling operations
vad = [] # Voice activity detection operations
psychoacoustic = ["transforms"] # Psychoacoustic analysis: band layouts, masking thresholds, SMR
parallel = ["dep:rayon"] # Parallel codec encoding/decoding via rayon (works with psychoacoustic)
opus-codec = ["psychoacoustic", "statistics"] # Opus-inspired codec: SILK (speech) and CELT (music) modes
plotting = ["dep:plotly", "dep:base64", "dep:serde_json", "channels", "transforms", "editing"]
envelopes = [
    "dynamic-range",
    "editing",
    "dep:rustfft"
] # Envelope generation operations
fixed-size-audio = [
] # Support for fixed-size audio buffers (no heap allocation)

full = ["full_no_plotting", "plotting"]

full_no_plotting = [
    "statistics",
    "editing",
    "transforms",
    "channels",
    "resampling",
    "fixed-size-audio",
    "beat-tracking",
    "onset-detection",
    "decomposition",
    "dynamic-range",
    "parametric-eq",
    "peak-picking",
    "pitch-analysis",
    "processing",
    "vad",
    "iir-filtering",
    "envelopes",
    "random-generation",
    "psychoacoustic",
    "parallel",
    "opus-codec",
]

educational = ["dep:explainable", "dep:term-maths", "dep:open", "processing", "fancy"]
bare-bones = [] # No features, just the core API and basic types

# Plotting sub-features (require plotting)
static-plots = ["plotting", "dep:plotly_static", "dep:serde", "i24/serde"]
simd = ["dep:wide"]
random-generation = ["dep:rand"]
python = ["i24/pyo3"]
html_view = ["dep:html_view"]

[dev-dependencies]
approx_eq = "0.1.8"
clap = { version = "4.6.1", features = ["derive"] }
dtmf_tones = "1.0.1"
rand = "0.10.1"
criterion = { version = "0.8.2", features = ["html_reports"] }
proptest = "1.11.0"

[[example]]
name = "errors"
required-features = ["fancy"]

[[example]]
name = "error_diagnostics"
required-features = ["fancy"]

[[example]]
name = "psychoacoustic"
required-features = ["psychoacoustic"]

[[example]]
name = "educational"
required-features = ["educational", "processing"]

[[test]]
name = "codec_quality"
required-features = ["psychoacoustic", "random-generation"]

[[test]]
name = "opus_codec_quality"
required-features = ["opus-codec", "random-generation"]

[[test]]
name = "processing_pipeline"
required-features = ["statistics", "processing", "editing", "transforms"]

[[test]]
name = "channel_pipeline"
required-features = ["channels", "processing", "editing"]

[[test]]
name = "effects_chain"
required-features = ["channels", "iir-filtering", "dynamic-range", "parametric-eq"]

[[test]]
name = "analysis_pipeline"
required-features = ["pitch-analysis", "vad"]