Skip to content

nyckmaia/mix-toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mix Toolbox

A MATLAB toolbox for automatic mixing of musical audio files, developed as part of a master's thesis in Music and Technology at the State University of Campinas (UNICAMP), Brazil.

Overview

Mix Toolbox provides automated audio mixing capabilities that consider sound balance, human acoustic perception, spectral balance, and amplitude dynamics. The toolbox implements a computational model for automatic mixing specifically designed for pop and commercial music production.

The algorithms are based on psychoacoustic principles and adhere to the ISO 226:2003 standard for equal-loudness contours, ensuring perceptually meaningful audio processing.

Academic Reference: This toolbox accompanies the master's dissertation "A Computational Model for Automatic Mixing for Pop Music" ("Um modelo computacional de mixagem automática para música comercial"), available at DOI: 10.47749/T/UNICAMP.2018.1080251.

Features

  • Multi-track Audio Import - Batch loading of WAV files with automatic validation
  • Loudness Analysis - Integrated loudness measurement with configurable analysis windows
  • Spectral Analysis - 1/3 octave band analysis following ISO 226:2003 (29 bands, 20Hz-20kHz)
  • Automatic Volume Balancing - Intelligent gain adjustment based on spectral comparison with reference signals
  • Dynamic Range Compression - Per-track compression with automatic threshold and ratio calculation
  • Resonant Frequency Detection - Identification and attenuation of problematic frequencies (50Hz-2kHz)
  • Parametric and Graphic EQ - Spectral correction using multi-band equalization
  • Loudness-Aware Processing - Analysis focused on perceptually relevant audio sections
  • Visualization Tools - Spectrum plotting and comparison utilities
  • Audio Export - High-quality WAV file output (48kHz, 24-bit)

Requirements

MATLAB Version

  • MATLAB R2017b or later recommended

Required Toolboxes

  • Audio Toolbox - For audio I/O, loudness measurement, and equalization
  • DSP System Toolbox - For colored noise generation and signal processing
  • Signal Processing Toolbox - For filtering and spectral analysis

Audio Specifications

Parameter Value
Sample Rate 48,000 Hz
Bit Depth 24-bit
Format WAV (mono or stereo)

Installation

  1. Clone the repository:
git clone https://github.com/nyckmaia/mix-toolbox.git
  1. Add the toolbox to your MATLAB path:
addpath(genpath('path/to/mix-toolbox'));
  1. Verify installation:
help mix.Contents

Quick Start

Basic Usage

% 1. Load audio tracks from a folder
tracks = mix.multi_audioread();  % Opens folder selection dialog

% 2. Create initial mix
initial_mix = mix.sum(tracks);

% 3. Analyze loudness and spectrum
for i = 1:length(tracks)
    tracks(i).fft();  % Compute spectrum in loudest section
end

% 4. Run the complete automatic mixing pipeline
run('main.m');

Running the Full Pipeline

The main.m script executes the complete automatic mixing workflow:

  1. Loads all WAV files from a selected folder
  2. Generates a pink noise reference signal
  3. Analyzes the spectrum of each track
  4. Calculates and applies volume adjustments
  5. Applies dynamic range compression
  6. Detects and removes resonant frequencies
  7. Applies spectral EQ correction
  8. Exports the final mixed audio

Project Structure

mix-toolbox/
├── +mix/                    # Main package directory
│   ├── @Constant/           # Global constants (sample rates, ISO bands)
│   ├── @Defined/            # Configuration parameters
│   ├── @track/              # Track object class
│   ├── Contents.m           # Package documentation
│   │
│   │ # Audio I/O
│   ├── multi_audioread.m    # Batch audio file loading
│   ├── stereo2mono.m        # Stereo to mono conversion
│   │
│   │ # Signal Analysis
│   ├── loudness.m           # Integrated loudness measurement
│   ├── loud_spectrum.m      # FFT of loudest audio section
│   ├── fft.m                # 1/3 octave band analysis
│   ├── simple_fft.m         # Basic FFT computation
│   ├── find_resonant_frequencies.m  # Resonance detection
│   │
│   │ # Mixing Functions
│   ├── sum.m                # Multi-track summing
│   ├── mix.m                # Generic signal mixing
│   ├── gain.m               # Gain adjustment (dB)
│   ├── norm.m               # Signal normalization
│   │
│   │ # Amplitude Conversion
│   ├── amp2dbfs.m           # Amplitude to dBFS
│   ├── dbfs2amp.m           # dBFS to amplitude
│   │
│   │ # Equalization
│   ├── parametric_eq.m      # Parametric EQ processing
│   ├── apply_eq.m           # Apply EQ to tracks
│   ├── track_eq.m           # Calculate EQ gains per track
│   ├── track_reso_freqs.m   # Find resonances per track
│   │
│   │ # Visualization
│   ├── plot.m               # Spectrum plotting
│   └── plot_tracks.m        # Multi-track spectrum overlay
│
├── aux_scripts/             # Test and utility scripts
│   ├── parametric_eq_test.m # Parametric EQ demonstration
│   ├── simple_eq_test.m     # Graphic EQ demonstration
│   └── plot_temp_mix.m      # Intermediate mix visualization
│
├── main.m                   # Main workflow script
├── LICENSE
└── README.md

Core Functions Reference

Audio I/O

Function Description
mix.multi_audioread() Load all WAV files from a folder into track objects
mix.stereo2mono(signal) Convert stereo signal to mono by averaging channels

Signal Analysis

Function Description
mix.loudness(signal, fs) Compute integrated loudness (LUFS) with windowed analysis
mix.loud_spectrum(signal, fs) Compute FFT of the loudest section of a signal
mix.fft(signal, fs) Analyze signal in 1/3 octave bands (ISO 226:2003)
mix.find_resonant_frequencies(signal, fs) Detect resonant frequencies and their Q factors

Mixing and Gain

Function Description
mix.sum(tracks) Sum multiple track objects into stereo output
mix.mix(sig1, sig2, ...) Mix variable number of signals
mix.gain(signal, dB) Apply gain in decibels with clipping detection
mix.norm(signal) Normalize signal to [-1, +1] range

Equalization

Function Description
mix.parametric_eq(signal, fs, bands) Apply multi-band parametric EQ
mix.apply_eq(tracks, gains) Apply graphic EQ to all tracks
mix.track_eq(tracks, reference) Calculate per-band EQ gains for each track

Visualization

Function Description
mix.plot(frequencies, amplitudes) Plot 1/3 octave spectrum
mix.plot_tracks(tracks, reference) Overlay all track spectrums with reference

Track Object Methods

The mix.track class provides the following methods:

track.fft()                      % Compute spectrum
track.apply_volume(dB)           % Apply volume adjustment
track.apply_compressor(ratio)    % Apply dynamic compression
track.remove_undesired_frequencies()  % Remove resonances + highpass
track.bounce(filename)           % Export to WAV file
track.play()                     % Playback audio
track.stop()                     % Stop playback

The Automatic Mixing Algorithm

The mixing algorithm follows a multi-stage processing pipeline:

Stage 1: Analysis

  • Load tracks and compute integrated loudness
  • Generate pink noise reference signal
  • Extract 1/3 octave spectrum from the loudest section of each track

Stage 2: Volume Balancing

  • Calculate initial volume from reference-to-track spectral ratio
  • Adjust for maximum spectral peak differences
  • Apply volume corrections to achieve balanced levels

Stage 3: Dynamic Processing

  • Calculate RMS and peak values for each track
  • Determine compression ratio (peak/RMS)
  • Apply per-track dynamic range compression

Stage 4: Spectral Correction

  • Calculate spectral contribution of each track to the mix
  • Detect and attenuate resonant frequencies (50Hz-2kHz)
  • Apply highpass filtering where appropriate
  • Compute EQ gains to match reference spectrum
  • Apply final graphic EQ correction

The mathematical formulations for each processing stage are detailed in the accompanying thesis.

Configuration

Key parameters can be adjusted in +mix/@Defined/Defined.m:

fs = 48000;              % Sample rate (Hz)
bit = 24;                % Bit depth
mix_loud_duration = 10;  % Loudness window for mix (seconds)
track_loud_duration = 5; % Loudness window for tracks (seconds)
reso_min = 50;           % Minimum resonance search frequency (Hz)
reso_max = 2000;         % Maximum resonance search frequency (Hz)
reso_step = 2;           % Frequency step for resonance search (Hz)
reso_threshold = 6;      % Resonance detection threshold (dB)
max_spectral_dist = 6;   % Maximum spectral distortion (dB)
highpass_slope = 6;      % Highpass filter slope (dB/octave)
percentile = 0.90;       % Percentile for band weight calculation

Citation

If you use Mix Toolbox in your research, please cite:

@mastersthesis{maia2018mixagem,
  author  = {Maia, Nycholas},
  title   = {Um modelo computacional de mixagem automática para música comercial},
  school  = {Universidade Estadual de Campinas, Instituto de Artes},
  year    = {2018},
  type    = {Master's Thesis},
  doi     = {10.47749/T/UNICAMP.2018.1080251},
  url     = {https://doi.org/10.47749/T/UNICAMP.2018.1080251}
}

Author

Nycholas Maia Interdisciplinary Nucleus for Sound Communication (NICS) State University of Campinas (UNICAMP) Email: nyckmaia@gmail.com

License

This project is licensed under the terms specified in the LICENSE file.

About

Mix Toolbox

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages