Package: dasp-pytorch
daspDifferentiable audio signal processors in PyTorchIncludes reverberation, distortion, dynamic range processing, equalization, stereo processing.Enables virtual analog modeling, blind parameter estimation, automated DSP, and style transfer.Batching with operation on both CPU and GPU accelerators for fast training and reduced bottlenecks.Open source and free to use for academic and commercial applications under Apache 2.0 license.Installationgit clone https://github.com/csteinmetz1/dasp-pytorch
cd dasp-pytorch
pip install -e .Note: Coming to PyPi soon to enablepip install dasp-pytorch.Examplesdasp-pytorchis a Python library for constructing differentiable audio signal processors using PyTorch.
These differentiable processors can be used standalone or within the computation graph of neural networks.
We provide purely functional interfaces for all processors that enables ease-of-use and portability across projects.
Unless oterhwise stated, all effect functions expect 3-dim tensors with shape(batch_size, num_channels, num_samples)as input and output.
Using an effect in your computation graph is as simple as calling the function with the input tensor as argument.QuickstartHere is a minimal example to demonstrate reverse engineering the drive value of a simple distortion effect using gradient descent.importtorchimporttorchaudioimportdasp_pytorch# Load audiox,sr=torchaudio.load("audio/short_riff.wav")# create batch dim# (batch_size, n_channels, n_samples)x=x.unsqueeze(0)# apply some distortion with 16 dB drivedrive=torch.tensor([16.0])y=dasp_pytorch.functional.distortion(x,drive)# create a parameter to optimizerdrive_hat=torch.nn.Parameter(torch.tensor(0.0))optimizer=torch.optim.Adam([drive_hat],lr=0.01)# optimize the parametern_iters=2500forninrange(n_iters):# apply distortion with the estimated parametery_hat=dasp_pytorch.functional.distortion(x,drive_hat)# compute distance between estimate and targetloss=torch.nn.functional.mse_loss(y_hat,y)# optimizeoptimizer.zero_grad()loss.backward()optimizer.step()print(f"step:{n+1}/{n_iters}, loss:{loss.item():.3f}, drive:{drive_hat.item():.3f}")For the remaining examples we will use theGuitarSetdataset.
You can download the data using the following commands:mkdirdata
wgethttps://zenodo.org/records/3371780/files/audio_mono-mic.zip
unzipaudio_mono-mic.zip
rmaudio_mono-mic.zipMore examplesVirtual Analog ModelingAutomatic EqualizationAudio Production Style TransferAudio ProcessorsAudio ProcessorFunctional InterfaceGaingain()Distortiondistortion()Parametric Equalizerparametric_eq()Dynamic range compressorcompressor()Dynamic range expanderexpander()Reverberationnoise_shaped_reverberation()Stereo Widenerstereo_widener()Stereo Pannerstereo_panner()Stereo Busstereo_bus()CitationsIf you use this library consider citing these papers:Differnetiable parametric EQ and dynamic range compressor@article{steinmetz2022style,title={Style transfer of audio effects with differentiable signal processing},author={Steinmetz, Christian J and Bryan, Nicholas J and Reiss, Joshua D},journal={arXiv preprint arXiv:2207.08759},year={2022}}Differentiable artificial reveberation with frequency-band noise shaping@inproceedings{steinmetz2021filtered,title={Filtered noise shaping for time domain room impulseresponse estimation from reverberant speech},author={Steinmetz, Christian J and Ithapu, Vamsi Krishna and Calamia, Paul},booktitle={WASPAA},year={2021},organization={IEEE}}Differnetiable IIR filters@inproceedings{nercessian2020neural,title={Neural parametric equalizer matching using differentiable biquads},author={Nercessian, Shahan},booktitle={DAFx},year={2020}}@inproceedings{colonel2022direct,title={Direct design of biquad filter cascades with deep learningby sampling random polynomials},author={Colonel, Joseph T and Steinmetz, Christian J andMichelen, Marcus and Reiss, Joshua D},booktitle={ICASSP},year={2022},organization={IEEE}AcknowledgementsSupported by the EPSRC UKRI Centre for Doctoral Training in Artificial Intelligence and Music (EP/S022694/1).