iracema.segmentation.onsets

Note onset detection methods.

iracema.segmentation.onsets.cnn_model(audio, instrument='clarinet', smooth_odf=True, odf_threshold=0.328, display_plot=False, return_odf_data=False)[source]

Extract the note onsets using the CNN method.

Parameters
  • audio (ir.Audio) – Audio file to be processed.

  • instrument (string) – Name of the instrument (currently trained only for clarinet).

  • smooth_odf (bool) – If true, the final ODF will be smoothed by convolving it with a hanning window of length 5.

  • odf_threshold (float) – Minimum threshold for the peak picking in the ODF curve.

  • display_plot (bool) – Whether of not to plot the results

  • return_odf_data (bool) – Whether or not to return the odf data

iracema.segmentation.onsets.adaptative_rms(audio, short_window=512, long_window=4096, hop=512, alpha=0.1, min_time=None, odf_threshold=0.2, display_plot=False, display_plot_rms=False, return_odf_data=False)[source]

Extract the note onsets using the adaptative RMS method.

Parameters
  • audio (Audio) – Audio time series.

  • short_window (int) – Length of the short term window for the calculation of the RMS.

  • long_window (int) – Length of the long term window for the calculation of the RMS.

  • hop (int) – Length of the hop for the sliding window.

  • alpha (float) – Reduction factor for the long term RMS curve.

  • display_plot_rms (bool) – Whether of not to plot the RMS curves used to calculate the ODF.

  • min_time (float) – Minimum time (in seconds) between successive onsets.

  • odf_threshold (float) – Ratio of the ODF maxima to be defined as a minimum threshold for the peak picking.

  • display_plot (bool) – Whether of not to plot the results.

  • return_odf_data (bool) – Whether or not to return the odf data.

Returns

  • onsets (PointList) – List of onsets.

  • odf_data (TimeSeries) – Time series containing the onset detection function obtained. This will only be returned if the argument return_odf_data has been set to True.

iracema.segmentation.onsets.rms_derivative(audio, window=1024, hop=512, min_time=None, odf_threshold=0.2, display_plot=False, return_odf_data=False)[source]

Extract note onsets from the audio time-series using its rms. The RMS will be calculated if it’s not passed as an argument. The argument min_time can be used to specify the minimum distance (in seconds) between two adjacent onsets.

Parameters
  • audio (Audio) – Audio object

  • window (int) – Window length for computing the RMS.

  • hop (int) – Hop length for computing the RMS.

  • min_time (float, optional) – Minimum time (in seconds) between successive onsets.

  • odf_threshold (float) – Minimum threshold for the peak picking in the ODF curve.

  • display_plot (bool) – Whether of not to plot the results

  • return_odf_data (bool) – Whether or not to return the odf data

Returns

  • onsets (list) – List of onset points.

  • odf_data (TimeSeries) – Time series containing the onset detection function obtained. This will only be returned if the argument return_odf_data has been set to True.

iracema.segmentation.onsets.pitch_variation(audio, window, hop, minf0=120, maxf0=4000, smooth_pitch=True, min_time=None, odf_threshold=0.04, display_plot=False, return_odf_data=False)[source]

Extract note onsets from the audio time-series using its pitch. The argument min_time can be used to specify the minimum distance (in seconds) between two adjacent onsets.

Parameters
  • audio (Audio) – Audio object

  • window (int) – Window length for computing the pitch.

  • hop (int) – Hop length for computing the pitch.

  • minf0 (int) – Minimum frequency for the pitch detection.

  • maxf0 (int) – Maximum frequency for the pitch detection.

  • smooth_pitch (bool) – Whether or not the pitch curve should be smoothed.

  • min_time (float) – Minimum time (in seconds) between successive onsets.

  • odf_threshold (float) – Minimum threshold for the peak picking in the ODF curve

  • display_plot (bool) – Whether of not to plot the results

  • return_odf_data (bool) – Whether or not to return the odf data

Returns

  • onsets (list) – List of onset points.

  • odf_data (TimeSeries) – Time series containing the onset detection function obtained. This will only be returned if the argument return_odf_data has been set to True.

iracema.segmentation.onsets.extract_from_odf(audio, odf, min_time=None, odf_threshold=0.2, odf_threshold_criteria='absolute', display_plot=False, **parameters)[source]

Generic method to extract onsets from an ODF (onset detection function).

Parameters
  • audio (Audio) – Audio time series.

  • odf (function) – Reference to the ODF.

  • min_time (float) – Minimum time (in seconds) between successive onsets.

  • odf_threshold (float) – Minimum ODF threshold for a peak to be considered as an onset.

  • odf_threshold_criteria (string ['absolute', 'relative_to_max']) – Specifies how the argument odf_threshold will be used: if 'absolute' its value will be used directly as the threshold; else, if 'relative_to_max', its value will be used to calculate the threshold, relative to the maximum value in the ODF curve, e.g.: odf_threshold``==``0.2 set the threshold to 20% of the maximum value of the ODF curve.

  • display_plot (bool) – Whether or not to plot the results.

Returns

  • onsets (PointList) – List of onsets.

  • odf_data (TimeSeries) – Time series containing the onset detection function obtained.