Digital signal processing

Module contents

DSP

This sub-package provides all dsp algorithms.

Classes

Classes

The main class is simsalabim.dsp.classes.Signal.

class simsalabim.dsp.classes.Signal(data, sampling_rate, comment=None, dtype=<class 'numpy.float64'>)[source]

Bases: object

Class for audio signals. Objects of this class contain data which is directly convertable between time and frequency domain (equally spaced samples and frequency bins).

property comment

Get comment.

property data

Get data.

property dtype

The data type of the audio object. This can be any data type and precision supported by numpy.

property duration

The duration of the signal in seconds.

property n_samples

The number of samples.

property sampling_rate

The sampling rate of the signal.

Utilities

Decibel

Provides
  1. Basic calculations with levels.

simsalabim.dsp.decibel.dbadd(a, b)[source]

Energetic addition of levels.

Parameters
  • a (float) – Single level or sequence of levels.

  • b (float) – Single level or sequence of levels.

Notes

L_{a+b} = 10 \log_{10}{10^{L_b/10}+10^{L_a/10}}

Energetically adds b to a.

simsalabim.dsp.decibel.dbmean(levels, axis=None)[source]

Energetic average of levels.

Parameters

levels (list, nparray) – Sequence of levels.

Notes

L_{mean} = 10 \log_{10}{\frac{1}{n}\sum_{i=0}^n{10^{L/10}}}

simsalabim.dsp.decibel.dbsub(a, b)[source]

Energetically subtract level b from level a.

Parameters
  • a (float) – Level.

  • b (float) – Level.

Notes

L_{a-b} = 10 \log_{10}{10^{L_a/10}-10^{L_b/10}}

Energitally subtract b from a.

simsalabim.dsp.decibel.dbsum(levels, axis=None)[source]

Summation of levels.

Notes

L_{sum} = 10 \log_{10}{\sum_{i=0}^n{10^{L/10}}}

SNR

Provides
  1. WADA (Waveform Amplitude Distribution Analysis) SNR calculation.

simsalabim.dsp.snr.wada_snr(wav)[source]

Direct blind estimation of the SNR of a speech signal.

Parameters

wav (str) – Filename of the wav file.

Notes

The function was adapted from public Matlab code by John Meade and can be found in this gist

References

1

Kim, Chanwoo, and Richard M. Stern. “Robust signal-to-noise ratio estimation based on waveform amplitude distribution analysis.” Ninth Annual Conference of the International Speech Communication Association. 2008.