pytimbre.spectral.timbral_model.timbral_util.calculate_attack_time

pytimbre.spectral.timbral_model.timbral_util.calculate_attack_time(envelope_samples, fs, calculate_attack_segment=True, thresh_no=8, normalise=True, m=3, calculation_type='min_effort', gradient_calulation_type='all', return_descriptive_data=False, max_attack_time=-1)

Calculate the attack time from the envelope of a signal.

Required inputs :param envelope_samples: envelope of the audio file, suggested to be calculated with

sample_and_hold_envelope_calculation.

Parameters:

fs – sample rate of the envelope_samples.

Optional inputs :param calculate_attack_segment: If the attack segment of the onset should be calculated before estimating the

attack time. bool, default to True.

Parameters:
  • thresh_no – Number of thresholds used for calculating the minimum effort method. int, default to 8.

  • m – value used for computation of minimum effort thresholds, defaults to 3 as s uggested in the CUIDADO project.

  • calculation_type – method for calculating the attack time, options are ‘min_effort’ or ‘fixed_threshold’, default to ‘min_effort’.

  • gradient_calulation_type – Method for calculating the gradient of the attack, options are ‘all’ for calculating the gradient from the estimated start and end points, or ‘mean’ for calculating the mean gradient between each threshold step in the minimum effort method. Defaults to ‘all’ and will revert to ‘all’ if mean is not available.

  • normalise – Normalise the attack segment. bool, default to True.

:param return_descriptive_data Default to False, if set to True also returns the thresholds for calculating

the min_effort method.

Parameters:

max_attack_time – sets the maximum allowable attack time. Defaults to -1, indicating that there is no maximum attack time. This value should be set in seconds.

Returns:

returns the attack_time, attack_gradient, index of the attack start, and temporal centroid.