Analysis Objects

class pytta.Analysis(anType, nthOct, minBand, maxBand, data, dataLabel=None, error=None, errorLabel='Error', comment='No comments.', xLabel=None, yLabel=None, title=None)[source]

Objects belonging to the Analysis class holds fractional octave band data.

It does conveniently the operations linearly between Analyses of the type ‘Level’. Therefore those operations do not occur with values in dB scale.

Available Analysis’ types below.

For more information see each parameter/attribute/method specific documentation.

  • anType (), (string):
    Type of the Analysis. May be:
    • ‘RT’ for ‘Reverberation time’ Analysis in [s];

    • ‘C’ for ‘Clarity’ in dB;

    • ‘D’ for ‘Definition’ in %;

    • ‘G’ for ‘Strength factor’ in dB;

    • ‘L’ for any ‘Level’ Analysis in dB (e.g: SPL);

    • ‘mixed’ for any combination between the types above.

  • nthOct, (int):

    The number of fractions per octave;

  • minBand, (int | float):

    The exact or approximated start frequency;

  • maxBand, (int | float):

    The exact or approximated stop frequency;

  • data, (list | numpy array):

    The data with the exact number of bands between the specified minimum (minBand) and maximum band (maxBand);

  • dataLabel (‘’), (string):

    Label for plots;

  • error, (list | numpy array):

    The error with the exact number of bands between the specified minimum (minBand) and maximum band (maxBand);

  • errorLabel (‘’), (string):

    Label for plots;

  • comment (‘No comments.’), (string):

    Some comment about the object.

  • xLabel (None), (string):

    x axis plot label;

  • yLabel (None), (string):

    y axis plot label;

  • title (None), (string):

    plot title.

  • bands (NumPy array):

    The bands central frequencies.

  • minBand, (int | float):

    When a new limit is set data is automatic adjusted.

  • maxBand, (int | float):

    When a new limit is set data is automatic adjusted.

  • plot_bars():

    Generates a bar plot.

property anType

Type of the Analysis.

May be:
  • ‘RT’ for ‘Reverberation time’ Analysis in [s];

  • ‘C’ for ‘Clarity’ in dB;

  • ‘D’ for ‘Definition’ in %;

  • ‘G’ for ‘Strength factor’ in dB;

  • ‘L’ for any ‘Level’ Analysis in dB (e.g: SPL);

  • ‘mixed’ for any combination between the types above.

string.

property nthOct

octave band fraction.

Could be 1, 3, 6…

int.

property minBand

minimum octave fraction band.

When a new limit is set data is automatic adjusted.

float.

property maxBand

maximum octave fraction band.

When a new limit is set data is automatic adjusted.

float.

property data

Fractional octave bands data.

data must be a list or NumPy ndarray with the same number of elements than bands between the specified minimum (minBand) and maximum band (maxBand).

NumPy ndarray.

property error

error per octave fraction band.

The error must be a list or NumPy ndarray with same number of elements as bands between the specified minimum (minBand) and maximum bands (maxBand);

Shown as +-error.

NumPy ndarray.

property dataLabel

Label of the data.

Used for plot purposes.

str.

property errorLabel

Label of the error information.

Used for plot purposes.

str.

property bands

The octave fraction bands central frequencies.

list with the fractional octave bands of this Analysis.

plot(**kwargs)[source]

Plot the analysis data in fractinal octave bands.

  • dataLabel (‘Analysis type [unit]’), (str):

    legend label for the current data

  • errorLabel (‘Error’), (str):

    legend label for the current data error

  • xLabel (‘Time [s]’), (str):

    x axis label.

  • yLabel (‘Amplitude’), (str):

    y axis label.

  • yLim (), (list):

    inferior and superior limits.

    >>> yLim = [-100, 100]
    
  • title (), (str):

    plot title

  • decimalSep (‘,’), (str):

    may be dot or comma.

    >>> decimalSep = ',' # in Brazil
    
  • barWidth (0.75), float:

    width of the bars from one fractional octave band. 0 < barWidth < 1.

  • errorStyle (‘standard’), str:

    error curve style. May be ‘laza’ or None/’standard’.

  • forceZeroCentering (‘False’), bool:

    force centered bars at Y zero.

matplotlib.figure.Figure object.

plot_bars(dataLabel: Optional[str] = None, errorLabel: Optional[str] = None, xLabel: Optional[str] = None, yLabel: Optional[str] = None, yLim: Optional[list] = None, xLim: Optional[list] = None, title: Optional[str] = None, decimalSep: str = ',', barWidth: float = 0.75, errorStyle: Optional[str] = None, forceZeroCentering: bool = False, overlapBars: bool = False, color: Optional[list] = None)[source]

Plot the analysis data in fractinal octave bands.

  • dataLabel (‘Analysis type [unit]’), (str):

    legend label for the current data

  • errorLabel (‘Error’), (str):

    legend label for the current data error

  • xLabel (‘Time [s]’), (str):

    x axis label.

  • yLabel (‘Amplitude’), (str):

    y axis label.

  • yLim (), (list):

    inferior and superior limits.

    >>> yLim = [-100, 100]
    
  • xLim (), (list):

    bands limits.

    >>> xLim = [100, 10000]
    
  • title (), (str):

    plot title

  • decimalSep (‘,’), (str):

    may be dot or comma.

    >>> decimalSep = ',' # in Brazil
    
  • barWidth (0.75), float:

    width of the bars from one fractional octave band. 0 < barWidth < 1.

  • errorStyle (‘standard’), str:

    error curve style. May be ‘laza’ or None/’standard’.

  • forceZeroCentering (‘False’), bool:

    force centered bars at Y zero.

  • overlapBars (‘False’), bool:

    overlap bars. No side by side bars of different data.

  • color (None), list:

    list containing the color of each Analysis.

matplotlib.figure.Figure object.

class pytta.RoomAnalysis(ir: SignalObj, nthOct: int = 1, minFreq: float = 20.0, maxFreq: float = 20000.0, *args, plotLundeby: bool = False, bypassLundeby: bool = False, suppressWarnings: bool = True, ircut: Optional[float] = None, **kwargs)[source]

Room monoaural acoustical parameters for quality analysis.

Provides interface to estimate several room parameters based on the energy distribution of the impulse response. Calculations compliant to ISO 3382-1 to obtain room acoustic parameters.

It has an implementation of Lundeby et al. [1] algorithm to estimate the correction factor for the cumulative integral, as suggested by the ISO 3382-1.

This class receives an one channel SignalObj or ImpulsiveResponse and calculate all the room acoustic parameters.

Available room parameters: D50, C80, Ts, STearly, STlate, EDT, T20, T30.

  • signalArray (ndarray | list), (NumPy array):

    signal at specified domain. For ‘freq’ domain only half of the spectra must be provided. The total numSamples should also be provided.

  • ir (), (SignalObj):

    Monaural room impulse response signal.

  • nthOct (1), (int):

    Number of bands per octave. The default is 1.

  • minFreq (20), (float):

    Central frequency of the first band. The default is 2e1.

  • maxFreq (20000) (float):

    Central frequency of the last band. The default is 2e4.

  • *args() (Tuple):

    See Analysis class.

  • bypassLundeby (false), (bool):

    Bypass Lundeby calculation, or not. The default is False.

  • suppressWarnings (false), (bool):

    Supress Lundeby warnings. The default is True.

  • ircut (None), (float):

    Cut the IR and throw away the silence tail. The default is None.

  • **kwargs (), (Dict):

    See Analysis.

  • parameters (), (Tuple):

List of parameters names. return tuple(self._params.keys())

  • rms (), (np.ndarray):

    Effective IR amplitude by frequency band.

  • SPL (), (np.ndarray):

    Equivalent IR level by frequency band.

  • D50 (), (np.ndarray):

    Room Definition by frequency band.

  • C80 (), (np.ndarray):

    Room Clarity by frequency band.

  • Ts (), (np.ndarray):

    Central Time by frequency band.

  • STearly (), (np.ndarray):

    Early energy distribution by frequency band.

  • STlate (), (np.ndarray):

    Late energy distribution by frequency band.

  • EDT (), (np.ndarray):

    Early Decay Time by frequency band.

  • T20 (), (np.ndarray):

    Reverberation time with 20 dB decay, by frequency band.

  • T30 (), (np.ndarray):

    Reverberation time with 30 dB decay, by frequency band.

  • plot_param(name [str], **kwargs):

    Plot a chart with the parameter passed in as name.

  • plot_rms(label [str], **kwargs):

    Plot a chart for the impulse response’s rms by frequency bands.

  • plot_SPL(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s SPL by frequency bands.

  • plot_C80(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s C80 by frequency bands.

  • plot_D50(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s D50 by frequency bands.

  • plot_T20(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s T20 by frequency bands.

  • plot_T30(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s T30 by frequency bands.

  • plot_Ts(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s Ts by frequency bands.

  • plot_EDT(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s EDT by frequency bands.

  • plot_STearly(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s STearly by frequency bands.

  • plot_STlate(label [str], yaxis [str], **kwargs):

    Plot a chart for the impulse response’s STlate by frequency bands.

For further information on methods see its specific documentation.

Authors:

João Vitor Gutkoski Paes, joao.paes@eac.ufsm.br Matheus Lazarin, matheus.lazarin@eac.ufsm.br Rinaldi Petrolli, rinaldi.petrolli@eac.ufsm.br

static estimate_energy_parameters(ir: SignalObj, bands: ndarray, plotLundeby: bool = False, bypassLundeby: bool = False, suppressWarnings: bool = False, **kwargs)[source]

Estimate the Impulse Response energy parameters.

Parameters:
  • bypassLundeby (bool) – Whether to bypass calculation of Lundeby IR improvements or not. The default is False.

  • suppressWarnings (bool) – If supress warnings about IR quality and the bypassing of Lundeby calculations. The default is False.

Returns:

params – A dict with parameters by name.

Return type:

Dict[str, np.ndarray]

property parameters

List of parameters names.

property rms

Effective IR amplitude by frequency band.

property SPL

Equivalent IR level by frequency band.

property D50

Room Definition by frequency band.

property C80

Effective IR amplitude, by frequency band.

property Ts

Central Time by frequency band.

property STearly

Early energy distribution by frequency band.

property STlate

Late energy distribution by frequency band.

property EDT

Early Decay Time by frequency band.

property T20

Reverberation time with 20 dB decay, by frequency band.

property T30

Reverberation time with 30 dB decay, by frequency band.

plot_param(name: str, **kwargs)[source]

Plot a chart with the parameter passed in as name.

Parameters:
  • name (str) – Room parameter name, e.g. ‘T20’ | ‘C80’ | ‘SPL’, etc.

  • kwargs (Dict) – All kwargs accepted by Analysis.plot_bar.

Returns:

f – The figure of the plot chart.

Return type:

matplotlib.Figure

plot_rms(label='RMS', **kwargs)[source]

Plot a chart for the impulse response’s rms by frequency bands.

plot_SPL(label='SPL', yaxis='Level [dB]', **kwargs)[source]

Plot a chart for the impulse response’s SPL by frequency bands.

plot_C80(label='C80', yaxis='Clarity [dB]', **kwargs)[source]

Plot a chart for the impulse response’s C80 by frequency bands.

plot_D50(label='D50', yaxis='Definition [%]', **kwargs)[source]

Plot a chart for the impulse response’s D50 by frequency bands.

plot_T20(label='T20', yaxis='Reverberation time [s]', **kwargs)[source]

Plot a chart for the impulse response’s T20 by frequency bands.

plot_T30(label='T30', yaxis='Reverberation time [s]', **kwargs)[source]

Plot a chart for the impulse response’s T30 by frequency bands.

plot_Ts(label='Ts', yaxis='Central time [s]', **kwargs)[source]

Plot a chart for the impulse response’s Ts by frequency bands.

plot_EDT(label='EDT', yaxis='Early Decay Time [s]', **kwargs)[source]

Plot a chart for the impulse response’s EDT by frequency bands.

plot_STearly(label='STearly', yaxis='Early reflection level [dB]', **kwargs)[source]

Plot a chart for the impulse response’s STearly by frequency bands.

plot_STlate(label='STlate', yaxis='Late reflection level [dB]', **kwargs)[source]

Plot a chart for the impulse response’s STlate by frequency bands.