maad.util.add_dB

maad.util.add_dB(*argv, axis=0)[source]

Computes an addition on decibel values.

Parameters:
*argvndarray-like of floats

Arrays containing the sound waveform in dB

axisinteger, optional, default is 0

if addition of multiple arrays, select the axis on which the sum is done

Returns:
e_sumndarray-like of floats

Array containing the sum of the dB values

Examples

Example with an audio file

>>> w, fs = maad.sound.load('../data/cold_forest_daylight.wav') 
>>> Sxx_power,tn,fn,_ = maad.sound.spectrogram(w,fs)
>>> L = maad.spl.power2dBSPL(Sxx_power,gain=42)
>>> L_sum = maad.util.add_dB(L, axis=1)  
>>> fig_kwargs = {'figtitle':'Spectrum (PSD)',
                  'xlabel':'Frequency [Hz]',
                  'ylabel':'Power [dB]',
                  }
>>> fig, ax = maad.util.plot1d(fn, L_sum.transpose(), **fig_kwargs)

Example with single values

>>> L1 = 90 # 90dB
>>> maad.util.add_dB(L1,L1)
    93.01029995663981

Example with arrays

>>> L1 = [90,80,70]
>>> maad.util.add_dB(L1,L1,axis=1)
    array([90.45322979, 90.45322979])
>>> maad.util.add_dB(L1,L1,axis=0)
    array([93.01029996, 83.01029996, 73.01029996])