9.1 KiB
9.1 KiB
@suaveplan/audio-core - Universal audio data model and processing primitives: paged AudioDocument, non-destructive PlanEngine, block-level ProcessPipeline, and typed OpRegistry. Zero browser or Node dependencies.
Universal audio data model and processing primitives. Provides a paged AudioDocument, a non-destructive PlanEngine, a block-level ProcessPipeline, and a typed OpRegistry — all with zero browser or Node.js dependencies.
Documentation tree
- analysis —
AnalysisOpis the operator contract every@suaveplan/audio-analysis-*package implements: spectrum, beat-tracking,…- analysis-op —
AnalysisOpis the operator contract every@suaveplan/audio-analysis-*package implements: spectrum, beat-tracking,…
- analysis-op —
- document —
AudioDocumentis the primary paged audio document model in@suaveplan/audio-core. It represents a multi-channel aud…- document —
AudioDocumentis the primary paged audio document model in@suaveplan/audio-core. It represents a multi-channel aud…
- document —
- error-codes — This module centralises every error code, metadata description, and severity level that the
@suaveplan/audio-corepac…- error-codes — This module centralises every error code, metadata description, and severity level that the
@suaveplan/audio-corepac…
- error-codes — This module centralises every error code, metadata description, and severity level that the
- page — This module provides the low-level building blocks for memory-efficient audio storage and retrieval inside an `AudioDoc…
- page — This module provides the low-level building blocks for memory-efficient audio storage and retrieval inside an `AudioDoc…
- plan-engine — The
PlanEngineclass is the central coordinator for turning anAudioDocumentedit list into an executable audio pla… - segment — The segment helpers provide low-level geometric operations on
Segmentobjects. A segment represents a contiguous mapp… - block-processor —
BlockProcessordefines the standard lifecycle contract for audio processors that operate on fixed-size blocks of mult… - process-pipeline —
ProcessPipelineexecutes a chain of audio editing operations on blocks of multi-channel PCM data. It bridges the decl… - registry —
OpRegistryis the central, in-memory catalog for all audio operations in@suaveplan/audio-core. It maps unique stri…- crop —
registerCropadds thecropoperation to anOpRegistry, making it available to the planning engine. The crop opera… - dither —
registerDitherinstalls theditherprocessing operation into anOpRegistry. Dithering adds a small amount of pseu… - fade —
registerFadeadds thefadeoperation to anOpRegistry. Fade applies a linear amplitude ramp across an entire proc… - gain —
registerGaininstalls thegainoperation into anOpRegistry. It is the simplest block-level processor: every samp… - insert —
registerInsertadds theinsertoperation to anOpRegistry. Insert is a planning-stage edit that introduces silenc… - mix —
registerMixinstalls themixoperation into anOpRegistry. The mix processor adds a scaled copy of the input sign… - normalize —
registerNormalizeadds thenormalizeoperation to anOpRegistry. Normalization scans an entire processing block t… - pad —
registerPadinstalls thepadoperation into anOpRegistry. Pad is a planning function that extends the total time… - pan —
registerPanadds thepanoperation to anOpRegistry. Pan is a block-level processor that adjusts the relative lou… - remove —
registerRemoveinstalls theremoveoperation into anOpRegistry. Remove is a planning function that deletes sampl… - repeat —
registerRepeatadds therepeatoperation to anOpRegistry. Repeat is a planning function that duplicates the enti… - resample —
registerResampleinstalls theresampleoperation into anOpRegistry. Resample is a planning function that changes… - reverse —
registerReverseadds thereverseoperation to anOpRegistry. Reverse is a planning function that flips the order… - speed —
registerSpeedinstalls thespeedoperation into anOpRegistry. Speed is a planning function that changes playback… - stretch —
registerStretchadds thestretchoperation to anOpRegistry. Stretch is a planning function that changes the dura… - transform —
registerTransforminstalls thetransformoperation into anOpRegistry. Transform is a block-level processor that… - trim —
registerTriminstalls thetrimoperation into anOpRegistry. Trim is a planning function that shortens the audio… - op-registry —
OpRegistryis the central, in-memory catalog for all audio operations in@suaveplan/audio-core. It maps unique stri…
- crop —
- render — The render module bridges the compiled plan produced by
PlanEngineand the paged sample storage of anAudioDocument…- render — The render module bridges the compiled plan produced by
PlanEngineand the paged sample storage of anAudioDocument…
- render — The render module bridges the compiled plan produced by
- stats — This module computes standard audio statistics across paged channel data. By scanning every sample in every page, it pr…
- stats — This module computes standard audio statistics across paged channel data. By scanning every sample in every page, it pr…
- stream — This module adapts the
@suaveplan/audio-coreprocessing pipeline to the Web Streams standard. It exports a factory fu…- stream — This module adapts the
@suaveplan/audio-coreprocessing pipeline to the Web Streams standard. It exports a factory fu…
- stream — This module adapts the
- telemetry — The telemetry module is the single OpenTelemetry integration point for
@suaveplan/audio-core. It exposes thin, lazy h…- telemetry — The telemetry module is the single OpenTelemetry integration point for
@suaveplan/audio-core. It exposes thin, lazy h…
- telemetry — The telemetry module is the single OpenTelemetry integration point for
Install
bun add @suaveplan/audio-core
Quick start
import { AudioDocument, OpRegistry, PlanEngine } from "@suaveplan/audio-core";
const doc = new AudioDocument({
sampleRate: 48000,
channels: 2,
sourceLength: 48000,
pages: [
{
startSample: 0,
channelData: [new Float32Array(48000), new Float32Array(48000)],
},
],
edits: [],
});
// Apply a non-destructive trim edit
doc.run({ type: "trim", opts: { start: 1000, end: 47000 } });
// Compile the plan
const registry = OpRegistry.createWithDefaults();
const engine = new PlanEngine(registry);
const plan = engine.compile(doc, true);
// Stream the result
for await (const block of doc.stream()) {
// block is Float32Array[] — one per channel
}
Modules
src/document/document.md—AudioDocumentclass and JSON round-tripsrc/page/page.md— Page primitives:walkPages,copyPages,readPages, allocation poolsrc/plan/plan-engine.md—PlanEnginefor compiling and resolving editssrc/plan/segment.md— Segment overlap, merge, and split helperssrc/process/process-pipeline.md—ProcessPipelinefor block-level DSPsrc/process/block-processor.md—BlockProcessorinterface andNoopBlockProcessorsrc/registry/op-registry.md—OpRegistryfor registering plan and process opssrc/registry/built-in/— Built-in operations: trim, crop, speed, stretch, reverse, insert, remove, repeat, pad, resample, gain, normalize, fade, pan, mix, dither, transformsrc/render/render.md—renderBlockfor copying source segments into output bufferssrc/stats/stats.md—computeStatsfor peak, RMS, and DC offsetsrc/stream/stream.md—createPlanTransformStreamfor downstream transformssrc/error-codes.md— Error codes andAudioErrorclass