pymixconsole

October 23, 2020 · View on GitHub

Headless multitrack mixing console in Python

Installation

pip install git+https://github.com/csteinmetz1/pymixconsole

Usage

Setup a mixing console with a set of tracks from a multitrack project and apply processing per block. By default, a console will contain n channels and each channel will have a series of default processors:

gain -> polarity inverter -> parametric EQ -> compressor -> gain (fader) -> stereo panner

These are setup in such a way that if you do not modify their settings the signal should pass largely unprocessed. Additionally a console is initialized with two effect busses, one for reverb and one for delay. Finally there is a master bus which sums the output of all the busses and channels and then applies a simple processing chain:

parametric EQ -> compressor

In the example below you can see how to initialize a console and then pass multitrack data into the console and process it block by block to get the output.

Basic processing

One way to apply processing is to create a multidimensional array of shape [samples, tracks/channels], where each channel is a mono stream of audio, which will be processed by the associated channel in the console.

In this example we create an array with 8 channels of audio and then instantiate a default console with 8 channels. Then we iterate over the input data by the block_size and we pass each block to the console's process_block() function, which takes this array, applies each channel processor, and return a stereo mix. We then store this output in our pre-allocated array. We finally save this data to a .wav file with pySoundFile as the end.

import numpy as np
import soundfile as sf
import pymixconsole as pymc

data = np.random.rand(44100,8)   # one second of audio for 8 mono tracks
rate = 44100                     # 44.1 kHz sampling rate
block_size = 512                 # processor block size

# create a mix console with settings that match our audio data
console = pymc.Console(block_size=block_size, sample_rate=rate, num_channels=8)

# array to hold the output of the console (stereo)
out = np.empty(shape=(data.shape[0], 2))

# iterate over each block of data
for i in range(data.shape[0]//block_size):

    start = i * block_size 
    stop  = start + block_size

    out[start:stop,:] = console.process_block(data[start:stop,:])

# save out the processed audio
sf.write("output.wav", out, rate)

Console control

pymixconsole provides a high level of control over how the mix console is set up. By default, a console will include the supplied number of channels, as well as two busses (one for reverb, one for delay) and a master bus which features a compressor and equalizer. By default each channel is created with a pre-gain, polarity inverter, equaliser, compressor, post-gain, and a panner.

There are three levels of processors for each channel: pre-processors, core-processors, and post-processors. The distinction is useful since we want to impose some constraints on how these processors may be randomized in our randomize() method. The simple explanation is that the order of pre and post processors is never shuffled, while core-processors can be.

The defaults were chosen to be a good starting place for basic processing, but the user can customize this completely. For example, we can at any time add an extra processor to a channel as follows. Here we add a second compressor to the third channel's core-processors (zero-indexed), and then change the threshold parameter.

console.channels[2].processors.add(pymc.processors.Compressor(name="second-comp"))
console.channels[2].processor.get("second-comp").parameters.threshold.value = -22.0

Processor API

A number of basic processor units are included which can be included on a channel, bus, or the master bus.

  • Gain
  • Polarity inverter
  • Converter
  • Panner
  • Equaliser
  • Compressor
  • Delay
  • Distortion
  • Reverb

Gain

ParameterMin.Max.DefaultUnitsTypeOptions
gain-80.024.00.0dBfloat

Panner

ParameterMin.Max.DefaultUnitsTypeValues
pan0.01.00.5float
outputs222outputsint
pan_law"-4.5dB"string"linear", "constant_power", "-4.5dB"

Equalizer

ParameterMin.Max.DefaultUnitsTypeValues
low_shelf_gain-24.024.00.0dBfloat
low_shelf_freq20.01000.080.0Hzfloat
first_band_gain-24.024.00.0dBfloat
first_band_freq200.05000.0400.0Hzfloat
first_band_q0.110.00.7float
second_band_gain-24.024.00.0dBfloat
second_band_freq500.06000.01000.0Hzfloat
second_band_q0.110.00.7float
third_band_gain-24.024.00.0dBfloat
third_band_freq2000.010000.05000.0Hzfloat
third_band_q0.110.00.7float
high_shelf_gain-24.024.00.0dBfloat
high_shelf_freq8000.020000.010000.0Hzfloat

Delay

ParameterMin.Max.DefaultUnitsTypeValues
delay0655365000samplesint
feedback0.01.00.3float
dry_mix0.01.00.9float
wet_mix0.01.00.0float

Compressor

ParameterMin.Max.DefaultUnitsTypeValues
threshold-80.00.00.0dBfloat
attack_time0.001500.010.0msfloat
release_time0.01.0100.0msfloat
ratio1.0100.02.0float
makeup_gain-12.024.00.0dBfloat

Algorithmic reverb

ParameterMin.Max.DefaultUnitsTypeValues
room_size0.11.00.5float
damping0.01.01.0float
dry_mix0.01.00.9float
wet_mix0.01.00.1float
stereo_spread010023int

Convolutional reverb

ParameterMin.Max.DefaultUnitsTypeValues
dry_mix0.01.00.9float
wet_mix0.01.00.1float
decay0.01.01.0float
type"-4.5dB"string"sm-room", "md-room", "lg-room", "hall", "plate"

Cite

If you use this in your work please consider citing:

  @article{steinmetz2020mixing,
            title={Automatic multitrack mixing with a differentiable mixing console of neural audio effects},
            author={Steinmetz, Christian J. and Pons, Jordi and Pascual, Santiago and Serrà, Joan},
            journal={arXiv:2010.10291},
            year={2020}}