Saturation Detection

Saturation is a form of distortion that happens when the peaks of the waveform are squashed generating new harmonics. There are several types of saturation. The saturation produced by analog devices, such as tape recorders or tube amplifiers is traditionally considered to produce a warm, pleasant sound. However, the saturation produced by digital clipping is generally considered to be musically displeasing.

The amount of saturation that can be considered acceptable is subjective and depends on factors such as the music genre. However, in most cases, too much saturation may degrade the audio quality and can be considered an audio problem.

A real saturated signal

We will use a heavily saturated audio clip to detect saturated regions:

from IPython.display import Audio
from essentia.standard import MonoLoader, SaturationDetector, FrameGenerator
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = (12, 9)
sr = 44100

audio_file = "../../../test/audio/recorded/distorted.wav"
audio = MonoLoader(filename=audio_file, sampleRate=sr)()

time = np.arange(len(audio)) / sr
plt.plot(time, audio)
plt.title("Saturated audio")
Text(0.5, 1.0, 'Saturated audio')

Note how the signal is heavily squashed close to the [-1, 1] areas.

Now let’s listen to it:

Audio(audio, rate=sr)