yodel.analysis module

This module provides classes for audio signal analysis such as spectral analysis.

class yodel.analysis.DFT(size)

Bases: builtins.object

The Discrete Fourier Transform allows to convert a time-domain signal into a frequency-domain spectrum.

Warning:
It should not be used in practice for computational reasons, and should only be used for testing purposes. Instead, prefer using the FFT.
Reference:
“Digital Signal Processing, a practical guide for engineers and scientists”, Steven W. Smith
__init__(size)

Initialize the Discrete Fourier Transform.

Parameters:size – length of the DFT (should only be a power of 2)
forward(real_signal, real_spec, imag_spec)

Compute the complex spectrum of a given real time-domain signal

Parameters:
  • real_signal – real time-domain input signal
  • real_spec – real-part of the output complex spectrum
  • imag_spec – imaginary-part of the output complex spectrum
inverse(real_spec, imag_spec, real_signal)

Compute the real time-domain signal of a given complex spectrum

Parameters:
  • real_spec – real-part of the complex spectrum
  • imag_spec – imaginary-part of the complex spectrum
  • real_signal – real time-domain output signal
class yodel.analysis.FFT(size)

Bases: builtins.object

The Fast Fourier Transform is a faster algorithm for performing the DFT. It allows converting a time-domain signal into a frequency-domain spectrum.

Reference:
“Digital Signal Processing, a practical guide for engineers and scientists”, Steven W. Smith
__init__(size)

Initialize the Fast Fourier Transform.

Parameters:size – length of the FFT (should only be a power of 2)
forward(real_signal, real_spec, imag_spec)

Compute the complex spectrum of a given real time-domain signal

Parameters:
  • real_signal – real time-domain input signal
  • real_spec – real-part of the output complex spectrum
  • imag_spec – imaginary-part of the output complex spectrum
inverse(real_spec, imag_spec, real_signal)

Compute the real time-domain signal of a given complex spectrum

Parameters:
  • real_spec – real-part of the complex spectrum
  • imag_spec – imaginary-part of the complex spectrum
  • real_signal – real time-domain output signal
class yodel.analysis.Window(size)

Bases: builtins.object

An analysis window function allows to reduce unwanted frequencies when performing spectrum analysis.

__init__(size)

Initialize the analysis window. By default, a flat window is applied. Use one of the provided methods to make it Hanning or Hamming.

Parameters:size – length of the analysis window
blackman(size)

Make a Blackman analysis window.

Parameters:size – length of the analysis window
hamming(size)

Make a Hamming analysis window.

Parameters:size – length of the analysis window
hanning(size)

Make a Hanning analysis window.

Parameters:size – length of the analysis window
process(input_signal, output_signal)

Perform windowing on an input signal.

Parameters:
  • input_signal – input signal to be windowed
  • output_signal – resulting windowed signal
rectangular(size)

Make a rectangular (flat) window. This type of window does not have any affect when applied on an input signal.

Parameters:size – length of the analysis window