A Pythonic audio processing library wrapping libsox
Project description
cysox
A Pythonic audio processing library which uses cython to wrap libsox.
Features
- Simple API: Convert, analyze, and play audio with one-liners
- Typed Effects: 28 effect classes with IDE autocomplete and validation
- High Performance: Direct C bindings through Cython
- Zero Configuration: Auto-initialization, no manual setup required
- Cross-Platform: macOS, Linux (Windows placeholder)
Installation
Note that cysox only works on macOS and Linux.
pip install cysox
Command Line Interface
# Show version
cysox --version
# Get audio file info
cysox info audio.wav
# Convert audio files
cysox convert input.wav output.mp3
cysox convert input.wav output.wav --rate 48000 --channels 1
# Play audio
cysox play audio.wav
# Concatenate files
cysox concat intro.wav main.wav outro.wav -o full.wav
Quick Start
import cysox
from cysox import fx
# Get audio file info
info = cysox.info('audio.wav')
print(f"Duration: {info['duration']:.2f}s, Sample rate: {info['sample_rate']} Hz")
# Convert with effects
cysox.convert('input.wav', 'output.mp3', effects=[
fx.Normalize(),
fx.Reverb(reverberance=60),
fx.Fade(fade_in=0.5, fade_out=1.0),
])
# Play audio (macOS/Linux)
cysox.play('audio.wav')
# Play with effects
cysox.play('audio.wav', effects=[fx.Volume(db=-6)])
Core Functions
cysox.info(path) -> dict
Get audio file metadata:
info = cysox.info('audio.wav')
# Returns: {
# 'path': 'audio.wav',
# 'format': 'wav',
# 'duration': 11.5,
# 'sample_rate': 44100,
# 'channels': 2,
# 'bits_per_sample': 16,
# 'samples': 507150,
# 'encoding': 'signed-integer',
# }
cysox.convert(input, output, effects=[], **options)
Convert audio files with optional effects and format options:
# Simple format conversion
cysox.convert('input.wav', 'output.mp3')
# With effects
cysox.convert('input.wav', 'output.wav', effects=[
fx.Volume(db=3),
fx.Bass(gain=5),
fx.Reverb(),
])
# With format options
cysox.convert('input.wav', 'output.wav',
sample_rate=48000,
channels=1,
bits=24,
)
cysox.stream(path, chunk_size=8192) -> Iterator[memoryview]
Stream audio samples for processing:
import numpy as np
for chunk in cysox.stream('large.wav', chunk_size=8192):
arr = np.frombuffer(chunk, dtype=np.int32)
process(arr)
cysox.play(path, effects=[])
Play audio to the default audio device:
cysox.play('audio.wav')
cysox.play('audio.wav', effects=[fx.Volume(db=-6), fx.Reverb()])
cysox.concat(inputs, output)
Concatenate multiple audio files:
cysox.concat(['intro.wav', 'main.wav', 'outro.wav'], 'full.wav')
All input files must have the same sample rate and channel count.
Effects Module
The cysox.fx module provides 28 typed effect classes:
Volume & Dynamics
fx.Volume(db=3) # Adjust volume in dB
fx.Gain(db=6) # Apply gain
fx.Normalize(level=-3) # Normalize to target level
Equalization
fx.Bass(gain=5, frequency=100) # Boost/cut bass
fx.Treble(gain=-2, frequency=3000) # Boost/cut treble
fx.Equalizer(frequency=1000, width=1.0, gain=3)
Filters
fx.HighPass(frequency=200) # Remove low frequencies
fx.LowPass(frequency=8000) # Remove high frequencies
fx.BandPass(frequency=1000, width=100)
fx.BandReject(frequency=60, width=10) # Notch filter
Spatial & Reverb
fx.Reverb(reverberance=50, room_scale=100)
fx.Echo(gain_in=0.8, gain_out=0.9, delays=[100], decays=[0.5])
fx.Chorus()
fx.Flanger()
Time-Based
fx.Trim(start=1.0, end=5.0) # Extract portion
fx.Pad(before=0.5, after=1.0) # Add silence
fx.Speed(factor=1.5) # Change speed (affects pitch)
fx.Tempo(factor=1.5) # Change tempo (preserves pitch)
fx.Pitch(cents=100) # Shift pitch (preserves tempo)
fx.Reverse() # Reverse audio
fx.Fade(fade_in=0.5, fade_out=1.0) # Fade in/out
fx.Repeat(count=3) # Repeat audio
Conversion
fx.Rate(sample_rate=48000) # Resample
fx.Channels(channels=1) # Change channel count
fx.Remix(out_spec=[[1, 2]]) # Custom channel mixing
fx.Dither() # Add dither
Composite Effects
Create reusable effect combinations:
from cysox.fx import CompositeEffect, HighPass, LowPass, Reverb, Volume
class TelephoneEffect(CompositeEffect):
"""Simulate telephone audio quality."""
@property
def effects(self):
return [
HighPass(frequency=300),
LowPass(frequency=3400),
Volume(db=-3),
]
# Use like any other effect
cysox.convert('input.wav', 'output.wav', effects=[TelephoneEffect()])
Low-Level API
For advanced use cases, access the full libsox bindings:
from cysox import sox
# Manual initialization (high-level API handles this automatically)
sox.init()
# Open files
input_fmt = sox.Format('input.wav')
output_fmt = sox.Format('output.wav', signal=input_fmt.signal, mode='w')
# Build effects chain
chain = sox.EffectsChain(input_fmt.encoding, output_fmt.encoding)
e = sox.Effect(sox.find_effect("input"))
e.set_options([input_fmt])
chain.add_effect(e, input_fmt.signal, input_fmt.signal)
e = sox.Effect(sox.find_effect("vol"))
e.set_options(["3dB"])
chain.add_effect(e, input_fmt.signal, input_fmt.signal)
e = sox.Effect(sox.find_effect("output"))
e.set_options([output_fmt])
chain.add_effect(e, input_fmt.signal, input_fmt.signal)
# Process
chain.flow_effects()
# Cleanup
input_fmt.close()
output_fmt.close()
sox.quit()
Building from Source
macOS
brew install sox libsndfile mad libpng flac lame mpg123 libogg opus opusfile libvorbis
make
make test
Linux
sudo apt-get install libsox-dev libsndfile1-dev pkg-config
make
make test
Status
Comprehensive test suite covering all functionality. All libsox C examples ported to Python (effects chains, waveform analysis, trim, concatenation, format conversion).
Known Issues
- Memory I/O: libsox memory I/O functions have platform issues (tests skipped)
- Init/Quit Cycles: Use high-level API to avoid init/quit issues (handled automatically)
See KNOWN_LIMITATIONS.md for details.
Platform Support
- macOS: Full support
- Linux: Full support
- Windows: Placeholder (contributions welcome)
Building Documentation
pip install sphinx furo myst-parser
make docs
make docs-serve # http://localhost:8000
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 cysox-0.1.6.tar.gz.
File metadata
- Download URL: cysox-0.1.6.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c431f7d0cf0ecc78914555d9c7c9f557c6039f8cc050c4a13c83177ff9276dfd
|
|
| MD5 |
c4e4db05a7c9fe0788e42bda3b059270
|
|
| BLAKE2b-256 |
c719dae0abf3e3c94a013ceecff814b6ce7876a7aeda012761c3c18fe3244562
|
File details
Details for the file cysox-0.1.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cysox-0.1.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 763.3 kB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bcb0ba35a0acd7d0c0b4a98f30c44c2d1699a2c1bb8f55b8d3046b8cccfc081
|
|
| MD5 |
5f3419dd2f0d9df3db55f99ac7662e18
|
|
| BLAKE2b-256 |
b146ebc1c25b968241c6a728eadc38b733e548620f2ebf03910f99b5804e344d
|
File details
Details for the file cysox-0.1.6-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: cysox-0.1.6-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 740.5 kB
- Tags: CPython 3.14, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60ff0cddca46e021fa079f097badf5a359f2cf5dd9fb9574715d688a7181c95c
|
|
| MD5 |
56763c61a3cf5334d832c173e34327b1
|
|
| BLAKE2b-256 |
4dfb191eb48ca1c4ecb3833b32a0fbd8254c5e0f5c175c8c5178a3623020b74c
|
File details
Details for the file cysox-0.1.6-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: cysox-0.1.6-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac22ff45aa320ccf2711d0bba638be1f0ebd651ec49506d4bf27d566d70440de
|
|
| MD5 |
9870c5b921c4e1739495c09e61e03989
|
|
| BLAKE2b-256 |
d691eefb0d2841b8886b1463288fe43884b6c9a38c923649ca8fb662e4dec189
|
File details
Details for the file cysox-0.1.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cysox-0.1.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 761.3 kB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07fdbe96a9ed99d2ea864f8ef38624c08a77a1d616212cd249dce76d56fc19a8
|
|
| MD5 |
abd8bd4719739a4fc0a4982aabf7961c
|
|
| BLAKE2b-256 |
c30c89572ab1dc40952864337934abf29b15b2e53e369ea8cd371b2f78d2ecde
|
File details
Details for the file cysox-0.1.6-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: cysox-0.1.6-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 736.8 kB
- Tags: CPython 3.13, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
356a5c64ea526f63fe4bbffe4e33ae61a86de75329a15227c9c4fe1a8641c354
|
|
| MD5 |
9001cc322a007a8c9e42442feb5f45bd
|
|
| BLAKE2b-256 |
b869d29e9fd91b3aff251eedb3982176fc78cf754052e5f3dc024dba907055e1
|
File details
Details for the file cysox-0.1.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: cysox-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29aff5acd42a5bb154f667dcbb3c08c8a2fbaf56f1a55af3fa6942c4cde1c7b1
|
|
| MD5 |
a0c2835eb6a02815b905c95a29b65a75
|
|
| BLAKE2b-256 |
327b92dfa22fcc47a52a93ac4dcd881171cf15264966acf7fd67c6571dcb0a1c
|
File details
Details for the file cysox-0.1.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cysox-0.1.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 761.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b1d44e8c1e1b680d43936919ddc1754a23924b02b9b9809b22ccf81627d55fb
|
|
| MD5 |
0583919369df559a091c42ca8a44522c
|
|
| BLAKE2b-256 |
67d360180bfbd0c0dad5c4decfdac7efd28cb15eec745c69870f878f65ca869f
|
File details
Details for the file cysox-0.1.6-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: cysox-0.1.6-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 736.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
712bbe063f0228f8d13cd0bc1f27c5c9d85f0e11179ed526194aea63b8b3b18d
|
|
| MD5 |
cabd7c5cc64e17b906d55d1ac1b56e54
|
|
| BLAKE2b-256 |
9fb1a54983a3b27030dcd272c312597c00072f9ae98d17ab0fb2859d2c1e5570
|
File details
Details for the file cysox-0.1.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: cysox-0.1.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7df815b45715cb4887d86373b43e69ab356863634aa588d1f24cd33d71cb6f8e
|
|
| MD5 |
6bbd53292dfc8f481aebfe9c865dbc29
|
|
| BLAKE2b-256 |
581bc01ef3eee185c1c3f16f3e4d547e374be2494b20f661400597d29bae1577
|
File details
Details for the file cysox-0.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cysox-0.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 768.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de1026338e210b06b409d0b2aa720adac3ce63a1131ee823c45687210d903116
|
|
| MD5 |
fe845c68bbc20565e2b5f94830437cb0
|
|
| BLAKE2b-256 |
e075213688baf4fa79de00eacf954d26bc5b2f3e20071b8db792c4ca42eb388e
|
File details
Details for the file cysox-0.1.6-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: cysox-0.1.6-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 748.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7bfae6dfea387159987e35acdfd402e1c496f56f7112897b44e0f9e8ce481e2
|
|
| MD5 |
ac8290fdb69e238c3587db8210caa14f
|
|
| BLAKE2b-256 |
564106c720efdf3644f6e5d9a467cd803ac9a1fa195e83730e34ed39fbf0b486
|
File details
Details for the file cysox-0.1.6-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: cysox-0.1.6-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53e3d12d2812b19c6ee63d5e87dce15bd74b3abfd6e73f3fd29046cb3c39d898
|
|
| MD5 |
6dc16c19a50892a7f493319ca93df907
|
|
| BLAKE2b-256 |
b787fbb21a65c67afbab8740b0f791e9c533d454a6f60b9c60a17d725e1d80b5
|
File details
Details for the file cysox-0.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cysox-0.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 764.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66c839437b451ac771a8928506a66185cac9f17217a37fee92e311bc43d7d449
|
|
| MD5 |
eaf1dfd96af2c14334bbd594c9ff9399
|
|
| BLAKE2b-256 |
c1d3d60155913fb4039054f6dd7d87e7c53ae5bd38e23df8f5a49fe238c91477
|
File details
Details for the file cysox-0.1.6-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: cysox-0.1.6-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 746.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5f76e26cd8f34a5ccfef711a7e07bdac05146417ed2ad3b054d0a34e6eaa35a
|
|
| MD5 |
bd7a5478b410f6dc4c0553bd36a08e26
|
|
| BLAKE2b-256 |
ee2526bdf120e73903b6929b576735530f226dc72b23c3879f51d2773a94a9d0
|
File details
Details for the file cysox-0.1.6-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: cysox-0.1.6-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6531122b570479d0722895200dd1d066d29f4839fda251b6f8e594c0b22d3f3e
|
|
| MD5 |
4653cfb1186753c2034604454d82b64c
|
|
| BLAKE2b-256 |
c69d1be89756787af53be9728da85e73fc1c5e39e3ed634bfe528d5d8b604959
|
File details
Details for the file cysox-0.1.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cysox-0.1.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 764.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4cdc14be821f776b1569e59294043e3a487ce0fdd148c6cd98bed884237a9fa
|
|
| MD5 |
098e2ff8ef711668ee6096b10b7f7f09
|
|
| BLAKE2b-256 |
67f9ef649746ca689e0d10c33003b3b69066b3226718f601950d101bc8772888
|
File details
Details for the file cysox-0.1.6-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: cysox-0.1.6-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 746.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb6752219cdba0049283be258434dd5896c68313a5e8cf7d5cd4b03d74c37e4b
|
|
| MD5 |
c242c13591711f92d0182d6a7ad5ac43
|
|
| BLAKE2b-256 |
226971fc1c45a294eb4f999f96ec30ad10383844509806ba117e6d530b6d0489
|
File details
Details for the file cysox-0.1.6-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: cysox-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dafcbb1f087a3d280d65dee249ca68939143292859c212badbf5b681a2bde7d
|
|
| MD5 |
4df7c5f1e4f5b5bfa668167dcf787513
|
|
| BLAKE2b-256 |
2fe174065b7477c3856d743d4ea75defd6dbf093a4e5960d1874696f99fac6ff
|