<div align="center">

<img src="assets/amp.svg" width="160px">

# amp

<i> Automatic Mastering Pipeline </i>

</div>

## Usage 

Install
```
python -m venv env
source env/bin/activate
pip install -e .
```

Run mastering pipeline on an audio file. 
```
python scripts/run.py --version 0 path/to/audio
```

## Pipelines

**v0**: Basic equalization and brickwall limiting, minimnally adaptive (no ML).

This model implements the most basic automatic mastering system. 
We start by cutting sub frequencies below 20 Hz with a 10th order filter. 
Then we apply an adaptive low shelf gain. The gain is dynamically set between +/- 6 dB 
to reach a start energy of -28 dB in the 100 Hz octave band. This has the effect of 
boosting the bass in recordings will little bass, and reducing the bass in overly bassy recordings. 
Next, we apply a fixed high shelf filter at 10 kHz with a boost of 5 dB. This is not adaptive as most recordings 
benefit from a high frequency boost to improve clarity. 
Before further processing is applied soft clipping (tanh) is used to ensure that no peaks exceed the limits after filtering. 
Next, we peak normalize the signal and apply a gain of 4 dB afterwards which will push peaks beyond the range of 1. 
This is followed by a brickwall (lookahead) limiter that will 


**v1**: Tag-based equalization and compression predictions.

Unlike **v0**, which uses the same strategy to process each song, **v1** will adapt its behavior based 
both on the input audio and the user-provided tags. This is achieved by extracting text embeddings from the 
tags and then using a small neural net to map tags to a target frequency profile and compression factor. 
Using these values as targets, we then apply equalization and brickwall limiting to match the targets. 