pytimbre.timbre_features.metrics.temporal.TemporalMetrics

class pytimbre.timbre_features.metrics.temporal.TemporalMetrics

Bases: object

This class contains all the elements from the Waveform object that are representations of the waveform or the waveform’s envelope.

__init__()

This function creates the class and instantiates it with the waveform object. It will calculate the various envelopes based on the waveform’s time series of data.

Parameters:

wfm (Waveform) – the audio waveform

Methods

__init__()

This function creates the class and instantiates it with the waveform object.

calculate_effective_duration()

calculate_log_attack()

This calculates the various global attributes.

calculate_modulation()

Calculate the frequency/amplitude modulations of the signal.

calculate_temporal_centroid()

from_waveform(wfm)

get_features()

This function calculates the various features within the global time analysis and stores the results in the class object.

instantaneous_temporal_features()

This function will calculate the instantaneous features within the temporal analysis.

Attributes

a_duration

amplitude_modulation

attack

attack_slope

The attack slope is defined as the average temporal slope of the energy during the attack segment.

auto_correlation

centroid_threshold

coefficient_count

The number of coefficients to generate for the available data

corrected_a_duration

cutoff_frequency

decrease

decrease_slope

The temporal decrease is a measure of the rate of decrease of the signal energy.

effective_duration

The effective duration is a measure intended to reflect the perceived duration of the signal.

effective_duration_threshold

frequency_modulation

hop_size_samples

hop_size_seconds

log_attack

The log-attack-time is simply defined as LAT = log_10(t[-1]-t[0])

normal_signal_envelope

release

sample_rate

signal_envelope

temporal_centroid

The temporal centroid is the center of gravity of the energy envelope.

waveform

window_size_samples

window_size_seconds

zero_crossing_rate

property a_duration

” -20220329 - SCC - Fixed code. Was flipping polairty of every signal and couldn’t find right zero crossing.

property attack_slope

The attack slope is defined as the average temporal slope of the energy during the attack segment. We compute the local slopes of the energy corresponding to each effort w_i. We then compute a weighted average of the slopes. The weights are chosen in order to emphasize slope values in the middle of the attack (the weights are the values of a Gaussian function centered around the threshold = 50% and with a standard-deviation of 0.5).

calculate_log_attack()

This calculates the various global attributes.

In some cases the calculation of the attack did not return an array, so the error is trapped for when a single values is returned rather than an array.

20230318 - FSM - According to the paper on the Timbre Toolbox, the thresholds were to be estimated on the maximum value of the energy envelope, not the values at the start and end of the attack. This was addressed in the determination of the value of the threshold.

calculate_modulation()

Calculate the frequency/amplitude modulations of the signal. This can be accomplished with either a Fourier or Hilbert method.

property coefficient_count

The number of coefficients to generate for the available data

property decrease_slope

The temporal decrease is a measure of the rate of decrease of the signal energy. It distinguishes non-sustained (e.g. percussive, pizzicato) sounds from sustained sounds. Its calculation is based on a decreasing exponential model of the energy envelope starting from it maximum.

property effective_duration

The effective duration is a measure intended to reflect the perceived duration of the signal. It distinguishes percussive sounds from sustained sounds but depends on the event duration. It is approximated by the time the energy envelop is above a given threshold. After many empirical tests, we have set this threshold to 40%

get_features()

This function calculates the various features within the global time analysis and stores the results in the class object. At the end, a dictionary of the values is available and returned to the calling function.

Returns:

features – The dictionary containing the various values calculated within this method.

Return type:

dict()

Remarks

2024-Sept-10 - FSM Adjusted the function to take in the boolean on whether the temporal features were calculated and adjusted the creation of the data dictionary that is returned.

instantaneous_temporal_features()

This function will calculate the instantaneous features within the temporal analysis. This includes the auto-correlation and the zero crossing rate.

property log_attack

The log-attack-time is simply defined as LAT = log_10(t[-1]-t[0])

property temporal_centroid

The temporal centroid is the center of gravity of the energy envelope. It distinguishes percussive from sustained sounds. It has been proven to be a perceptually important descriptor (Peeters et al., 2000).