pytimbre.spectral.timbral_model.timbral_util.return_loop¶
- pytimbre.spectral.timbral_model.timbral_util.return_loop(onset_loc, envelope, function_time_thresh, hist_threshold, hist_time_samples, nperseg=512)¶
This function is used by the calculate_onsets method. This looks backwards in time from the attack time and attempts to find the exact onset point by identifying the point backwards in time where the envelope no longer falls. This function includes a hyteresis to account for small deviations in the attack due to the envelope calculation.
Function looks 10ms (function_time_thresh) backwards from the onset time (onset_loc), looking for any sample lower than the current sample. This repeats, starting at the minimum value until no smaller value is found. Then the function looks backwards over 200ms, checking if the increase is greater than 10% of the full envelope’s dynamic range.
onset_loc: The onset location estimated by librosa (converted to time domain index) envelope: Envelope of the audio file function_time_thresh: Time threshold for looking backwards in time. Set in the timbral_hardness code
to be the number of samples that equates to 10ms
- hist_threshold: Level threshold to check over 200ms if the peak is small enough to continue looking
backwards in time.
hist_time_samples: Number of samples to look back after finding the minimum value over 10ms, set to 200ms.