Mathematical utilities

Provide mathematical functions set up to process data from Audio objects.

Created on Tue May 5 00:34:36 2020

@author: João Vitor Gutkoski Paes

ossom.utils.maths.apply_channelwise[source]

Apply func on each column of an audio data array.

Parameters:
  • auddata (np.ndarray) – Audio data as numpy array.
  • func (callable) – The function to apply on each channel. Must receive data as a 1d array.
Returns:

chwise – Output of func for each channel as an array.

Return type:

np.ndarray

ossom.utils.maths.max_abs[source]

Maximum of the absolute values of the input array, for each channel (column).

See apply_channelwise for more info

Parameters:auddata (np.ndarray) – Input array of audio data.
Returns:ma – Columnwise max of abs of arr.
Return type:np.ndarray
ossom.utils.maths.rms[source]

Root of the mean of the squared values of input array, for each channel.

See apply_channelwise for more info.

Parameters:auddata (np.ndarray) – Input array of audio data.
Returns:rms – Columnwise sqrt of mean of arr**2.
Return type:np.ndarray
ossom.utils.maths.dB[source]

Decibel level of input array, for each channel.

See apply_channelwise and rms for more info.

Parameters:
  • auddata (np.ndarray) – Input array of audio data.
  • power (bool, optional) – If True, assumes a power signal, which need not to be squared. The default is False.
  • ref (float, optional) – The decibel reference. The default is 1.0.
Returns:

Channelwise audio levels, in decibel.

Return type:

_np.ndarray

ossom.utils.maths.noise[source]

Generate random noise for audio data.

Parameters:
  • level (float) – Level of audio.
  • samplerate (int) – Sample rate.
  • tlen (float) – Total time length.
  • nchannels (int) – Total number of channels.
Returns:

The complete noise data.

Return type:

_np.ndarray