DiffFx
A PyTorch-based library for differentiable audio effects processing.
Note: Several excellent libraries already exist, such as GRAFX, dasp-pytorch, NablAFx, and torchcomp. Some of my code is inspired by these libraries, and I'm grateful to their developers for implementing several fundamental processors. My core extension will be developing human-interpretable effect processors, where the parameters of each processor can be easily understood by humans.
Overview
DiffFx provides a collection of differentiable audio effects processors that can be integrated into neural network architectures. Most implementations follow methods from books including Audio Effects: Theory, Implementation and Application and DAFX - Digital Audio Effects (Second Edition)
Installation
pip install diffFx-pytorch
or
git clone https://github.com/ytsrt66589/diffFx-pytorch.git
cd diffFx-pytorch
pip install -e .
Quick Start
You can control each processor using either dsp_params or nn_params. dsp_params represents the exact DSP parameters used for each processor, while nn_params contains normalized parameters ranging from 0 to 1 that are internally mapped to the desired DSP parameters by each processor. dsp_params offers precise manual control over each processor, while nn_params provides learnable control for neural networks.
Using DSP Params
import torch
from diffFx_pytorch.processors.dynamics import Compressor
# Create a compressor
compressor = Compressor(sample_rate=44100)
# Process audio with direct DSP parameters
output = compressor(input_audio, dsp_params={
'threshold_db': -20.0,
'ratio': 4.0,
'knee_db': 6.0,
'attack_ms': 5.0,
'release_ms': 50.0,
'makeup_db': 0.0
})
Neural Network Integration
The library supports deep learning integration through normalized parameters:
import torch
import torch.nn as nn
from diffFx_pytorch.processors.dynamics import Compressor
# Create a neural network controller
class CompressorNet(nn.Module):
def __init__(self, input_size, num_params):
super().__init__()
self.net = nn.Sequential(
nn.Linear(input_size, 32),
nn.ReLU(),
nn.Linear(32, num_params),
nn.Sigmoid() # Output in range [0,1]
)
def forward(self, x):
return self.net(x)
# Initialize processor and network
comp = Compressor(sample_rate=44100)
num_params = comp.count_num_parameters()
controller = CompressorNet(input_size=16, num_params=num_params)
# Process audio with predicted parameters
features = torch.randn(batch_size, 16)
norm_params = controller(features)
output = comp(input_audio, nn_params=norm_params)
Examples
Understanding the sound characteristic of each processor
Check examples/processors/notebook to see how each processor affect sound.
Features
Implemented Effects 🎛️
- Utilities
- [] Send
- [] Mid/Side Processing
- Linear Gain
- Gain: playground
- EQ
- ToneStack: playground
- Graphic Equalizer: playground
- Parametric Equalizer: playground
- Dynamics
- Compressor: playground
- Multi-band Compressor: playground
- Limiter: playground
- Multi-band Limiter: playground
- Expander: playground
- [] Multi-band Expander
- Noise Gate: playground
- [] Multi-band Noise Gate
- [] Deesser
- Delay
- Basic Delay: playground
- Feedback Basic Delay: playground
- Slapback Delay: playground
- Ping-pong Delay: playground
- Multi-taps Delay: playground
- Spatial
- Stereo Panning: playground
- Stereo Widener: playground
- Multi-band Stereo Widener: playground
- Stereo Enhancer: playground
- Modulation
- Chorus: playground
- Multi-voice Chorus: playground
- Stereo Chorus: playground
- Flanger: playground
- Feedback Flanger: playground
- Stereo Flanger: playground
- Phaser: playground
- Reverb
- Noise Shape Reverb: playground
- [] Feedback Delay Network (FDN)
- Distortion (Nonlinear)
- TanH: playground
- Hard/Soft/Double-Soft/Cubic/ArcTanh/Rectifier/Exponential Clipper: playground
- Bit Crusher
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. Check the to-do list above for effects that haven't been implemented yet.
Citation
If you use diffFx-pytorch in your research, please cite:
@software{difffx_pytorch,
title = {diffFx-pytorch: Differentiable Audio Effects Processing in PyTorch},
author = {Yen-Tung Yeh},
year = {2024},
url = {https://github.com/ytsrt66589/difffx-pytorch}
}
License
This project is licensed under the Apache License - see the LICENSE file for details.
Metadata
Release files for diffFx-pytorch 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| difffx_pytorch-0.0.5.tar.gz | 59.5 kB | Without provenance | Details for difffx_pytorch-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| difffx_pytorch-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for difffx_pytorch-0.0.5-py3-none-any.whl |
Total release size: 144.9 kB
Release files / difffx_pytorch-0.0.5.tar.gz
| Download URL | difffx_pytorch-0.0.5.tar.gz |
|---|---|
| Size | 59.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
238431cb0dfb74112e9f85b48d7b31cf50e32534ecb72a9266c1756bb36567cd
|
|
BLAKE2b-256 checksum How to use checksums |
25abf9d85d840d2cbeb7799543b9cc3d3251ea1cebcf93260e311cd58d017d16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / difffx_pytorch-0.0.5-py3-none-any.whl
| Download URL | difffx_pytorch-0.0.5-py3-none-any.whl |
|---|---|
| Size | 85.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b22ceb8702525cd1754236e7cc3bbdb154e1f7dce1e7a198eba8cb9c9fa44a75
|
|
BLAKE2b-256 checksum How to use checksums |
f78320767d79f0b36f6bc8ffbcb2ec33d014d0fef3c842f0e619055b9f687a3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Security for diffFx-pytorch 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.