SonicLab
SonicLab is a modular Python DSP / audio synthesis engine: vectorized oscillators, envelopes, filters, effects, sequencing, optional realtime audio I/O, and MIDI adapters.
Status: Beta. Public APIs may still evolve; see docs/stability.md and CHANGELOG.md.
Features
- Oscillators: sine, square, sawtooth, triangle, PolyBLEP bandlimited variants
- Modulation: ADSR / decay envelopes, modulated oscillators & frequency helpers
- Modifiers: volume, panning, clipping, frequency processors
- Composition:
Chain(serial),WaveAdder(parallel mix) - Noise: white, pink, brownian, blue, grey, velvet, sample-and-hold, Perlin
- Filters: Butterworth utilities, biquad resonant, acid/303-style filter
- Effects: distortion, delay, reverb, compressor
- Sequencing: step sequencers, clock, accent/slide, TB-303 helpers
- Presets:
PresetBuilder/PresetLibrary - I/O (optional):
AudioOutputvia theaudio-ioextra - MIDI (optional): adapters and synth helpers via the
midiextra
Install
From PyPI:
pip install soniclab
Optional extras:
pip install "soniclab[audio-io]" # sounddevice + numba speed path
pip install "soniclab[midi]" # mido + python-rtmidi
pip install "soniclab[speed]" # numba only
pip install "soniclab[examples]" # notebooks / plotting
pip install "soniclab[full]" # audio-io + midi + examples
From a checkout (recommended while developing):
uv sync
# or:
python -m pip install -e ".[dev]"
Notes:
- Base install is the core NumPy/SciPy engine only.
- Realtime device playback needs working system audio drivers plus
audio-io. - MIDI needs local MIDI ports/backends plus the
midiextra.
Minimal example
from soniclab import SineOscillator, __version__
print(__version__)
osc = SineOscillator(frequency=440, amplitude=0.3)
samples = osc.get_samples(44100) # 1 second @ 44.1 kHz, float32
print(samples.shape, samples.dtype)
Chain + stereo pan:
from soniclab import SineOscillator, Chain, Volume, Panner
chain = Chain(
SineOscillator(frequency=440, amplitude=0.4),
Volume(0.8),
Panner(0.25),
)
stereo = chain.get_samples(2048, mode="vectorized") # shape (2048, 2)
PolyBLEP oscillator:
from soniclab import PolyBLEPOscillator, WaveShape
osc = PolyBLEPOscillator(
frequency=110,
amplitude=0.5,
wave_shape=WaveShape.SAWTOOTH_UP,
)
samples = osc.get_samples(1024, mode="vectorized")
Optional audio output:
from soniclab.audio_io import AudioOutput
# See examples/ and soniclab/audio_io for callback-based playback.
Sample generation modes
Most generators support:
| Mode | Behavior |
|---|---|
"vectorized" |
NumPy block rendering (preferred for production) |
"iterator" |
Python sample loop (flexible, slower) |
"auto" |
oscillators: vectorized when n >= 512, else iterator; composers (Chain / WaveAdder) always use vectorized so small realtime buffers stay on the fast path |
For realtime or offline renderers, prefer "vectorized" (or "auto" with buffer sizes ≥ 512).
Documentation
- docs/ — getting started, API overview, recipes, stability policy
- Local preview:
uv run --with mkdocs mkdocs serve - CHANGELOG.md
- CONTRIBUTING.md
- SECURITY.md
Testing
uv run pytest tests -q
uv run ruff check soniclab tests
uv run mypy soniclab
Suggested slices (mirrors soniclab/ layout):
uv run pytest tests/core -q
uv run pytest tests/dsp -q
uv run pytest tests/generators -q
uv run pytest tests/audio_io -q
uv run pytest tests/midi_io -q
uv run pytest tests/utils -q
uv run pytest tests/presets -q
uv run pytest tests/sequencing -q
uv run pytest tests/voices -q
Project layout
soniclab/ # installable package
tests/ # pytest suite (mirrors soniclab/ packages)
examples/ # demos & notebooks (not in sdist)
docs/ # user documentation (MkDocs)
scripts/ # benchmarks & local tooling
Public API
Import the stable surface from the top-level package:
from soniclab import (
SineOscillator,
SquareOscillator,
TriangleOscillator,
SawtoothOscillator,
PolyBLEPOscillator,
ADSREnvelope,
Chain,
WaveAdder,
Volume,
Panner,
Delay,
Reverb,
)
Optional subsystems stay in subpackages so the core install stays light:
from soniclab.audio_io import AudioOutput
from soniclab.midi_io import MIDIInput # requires midi extra
Contributing
- Prefer
uvfor environments (uv sync --group dev). - Keep changes covered by tests under
tests/. - Run
pytest,ruff, andmypybefore opening a PR. - Follow existing module patterns (component descriptor + registry registration).
- See CONTRIBUTING.md for details.
Changelog
See CHANGELOG.md.
License
See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file soniclab-2026.1.2.tar.gz.
File metadata
- Download URL: soniclab-2026.1.2.tar.gz
- Upload date:
- Size: 246.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67876f91c4f65294bc7688cfa87dbb6d33b0de9bb449591ee2a3ce06f9d3caff
|
|
| MD5 |
90fafc5117119fa5c9a23a05a6248f8b
|
|
| BLAKE2b-256 |
a2bc5f5e7a8820c084e2233e2b363231aa2cbee27d98c207576796d1619e233a
|
File details
Details for the file soniclab-2026.1.2-py3-none-any.whl.
File metadata
- Download URL: soniclab-2026.1.2-py3-none-any.whl
- Upload date:
- Size: 199.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f19fb39cb174edf77453ec42573544a3b4594c0670363f5de6c282f2f7cd635
|
|
| MD5 |
45f28bdceb5eac1ebde4ce62ef209d5f
|
|
| BLAKE2b-256 |
ac5573b40351ba9e2519d0637a70b2c9464adaf5c5318e7ebdcea9f5ca5bc229
|