Skip to content

matteospanio/torchfx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

296 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

TorchFX

GPU-Accelerated Audio DSP with PyTorch

License: GPL v3 arXiv PyPI version PyPI - Status codecov Ask DeepWiki

Documentation | Getting Started | API Reference | Blog


TorchFX is a modern Python library for high-performance digital signal processing in audio, leveraging PyTorch and GPU acceleration. Built for researchers, engineers, and developers who need fast, flexible, and differentiable audio processing.

✨ Key Features

  • ⚑ GPU Acceleration - Built on PyTorch for high-performance audio processing on CUDA-enabled devices
  • πŸ”— Composable Pipelines - Chain filters with the pipe operator (|) for sequential processing
  • βž• Parallel Processing - Combine filters with the add operator (+) for parallel filter combination
  • 🧠 PyTorch Native - All filters are torch.nn.Module subclasses, enabling gradient-based optimization
  • 🎯 Simple & Intuitive - Clean, object-oriented API designed for ease of use
  • βš™οΈ Highly Extensible - Create custom filters and effects by extending base classes
  • πŸ“Š Performance Optimized - Substantial performance gains over SciPy for long and multichannel signals

πŸš€ Quick Start

Installation

pip install torchfx

Or install from source:

git clone https://github.com/matteospanio/torchfx
cd torchfx
pip install -e .

Basic Example

import torch
from torchfx import Wave
from torchfx.filter import LoButterworth, ParametricEQ

# Load audio
wave = Wave.from_file("audio.wav")

# Create filters
lowpass = LoButterworth(cutoff=5000, order=4, fs=wave.fs)
eq = ParametricEQ(frequency=1000, q=2.0, gain=3.0, fs=wave.fs)

# Sequential processing with pipe operator (|)
processed = wave | lowpass | eq

# Parallel processing with add operator (+)
stereo_enhancer = lowpass + eq
enhanced = wave | stereo_enhancer

# Save result
processed.save("output.wav")

πŸ“š Documentation

πŸ› οΈ Development

We welcome contributions from everyone! Please read our Contributing Guide to get started.

πŸ“– Citation

If you use TorchFX in your research, please cite our paper:

@conference{Spanio2025torchfx,
	author = {Spanio, Matteo and RodΓ , Antonio},
	title = {TORCHFX: A MODERN APPROACH TO AUDIO DSP WITH PYTORCH AND GPU ACCELERATION},
	year = {2025},
	journal = {Proceedings of the International Conference on Digital Audio Effects, DAFx},
	pages = {390 – 395},
	url = {https://www.scopus.com/inward/record.uri?eid=2-s2.0-105028935688&partnerID=40&md5=552e54afc1a074cbd1b7e8ed4ad1c010},
	type = {Conference paper},
}

License

This project is licensed under the terms of the GNU General Public License v3.0. See the LICENSE file for details.

Third-Party Acknowledgments

This project uses the following third-party libraries:

  • PyTorch – BSD-style license
  • NumPy – BSD 3-Clause License
  • SoundFile – BSD 3-Clause License

Their respective license texts are included in the licenses/ directory.

About

A GPU accelerated and torch based audio DSP library

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors