Audio Mastering

Introduction

Audio mastering is the process of preparing and transferring recorded audio from a source. In recent years digital  master  have invested too much to mastering works. Here I optimize the mastering program online to automatically finish the mastering work.( the reference work in this link)  The mastering work is composed of four stages: reference code,  target code, imitating target to reference, and compressor the result of audio signal.

Building up Reference for Target

The reference function is to analyze which parts of the reference signal should be fetched out, or to be imitated by my target signal, and all the information of  specific segments of the reference signal would be stored and averaged into a segment signal in 4496 length, which is easily applied in FFT  and would be acted as a FIR filter for modulate the target signal.

The code decomposes the reference signal to mid and side channel respectively, picks up the specific segments depending on whether their RMS bigger than average RMS of the whole signal, and builds up the corresponding spectrum for reference mid and side in 4496 length.

Building up Target in Spectrum

Building up the target is similar to the above, but for “referenceMatchingRms” from reference function, which can point out where the target signals should be modulated 

Imitating Function of Target and Reference

This function synthesizes the target and reference in frequency domain. It uses the division method of target and reference as the FIR filter, then it builds up the FIR filter so as to modulate the target in mid and side channels to reference.

However its original code that the command “smooth” can not be converted to C language and its order is 4496 which is very long reducing the efficiency of filter. So I optimize it as short order with envelope Matlab command and simplify the system impulse response by retaining the middle part of it and discarding the rest so it increases the speed of code and is flexible in different platform. Like the below figure

Compressor 

The final part of program is the compressor because the range of signals value is always bigger than min one to positive one, which can not be accepted by codec. So I directly use compressor to compress the signals out from the above program.

Extension

This program imitates the reference by averaging the specific part of signals, so it can be extended to machine learning to mark learned portion of signals.

Here is my code, the “runscript” is for the test.