maad.sound.gain
- maad.sound.gain(s, gain_db=0)[source]
Amply amplification or attenuation to the audio signal.
- Parameters:
- snp.ndarray
Mono audio signal as NumPy array.
- gain_dbfloat, optional
Gain value to amplify (positive values), or attenuate (negative values) the signal in dB.
- Returns:
- s_outnp.ndarray
Amplified or attenuated audio signal.
See also
sound.normalize
,sound.trim
Examples
>>> import numpy as np >>> from maad import sound
Amplify the signal by 3 dB
>>> s, fs = sound.load('../data/spinetail.wav') >>> s_out = sound.gain(s, gain_db=3) >>> print('Signal amplified by:', 20*np.log10((s_out.max()/s.max())), 'dB') Signal amplified by: 3 dB
Attenuate the signal by 3 dB
>>> s, fs = sound.load('../data/spinetail.wav') >>> s_out = sound.gain(s, gain_db=-3) >>> print('Signal amplified by:', 20*np.log10((s_out.max()/s.max())), 'dB') Signal amplified by: -3 dB