Pair distances among Fourier series

Distances between Fourier songs can be calculated indicated the frequencies and the amplitude, the available metrics can be found in distance.py module.

Distance between two songs is calculated with:

foucluster.distance.pair_distance(freq_x, features_x, freq_y, features_y, frames=None, distance_metric='l2_norm')[source]

Distance between song x (with frequencies and features) and song y is calculated.

Parameters:
  • freq_x (numpy.array) – frequencies of the song x.
  • features_x (numpy.array) – features (fourier amplitude) of song x.
  • freq_y (numpy.array) – frequencies of the song y.
  • features_y (numpy.array) – features (fourier amplitude) of song y.
  • frames – number of frames to calculate distances. If None, only one frame is considered
  • distance_metric (str) –

    name of the metric to use. Options are:

    • ’positive’: positive_error.
    • ’hellinger’: hellinger.
    • ’l2_norm’: l2_norm.
    • ’integrate’: integrate.
Returns:

distance in float.

For a distance of all the songs from a folder, in JSON format (just the output from foucluster.transform.transform_folder,

foucluster.distance.distance_matrix(fourier_folder: str, multiprocess: bool = False, frames: int = 1, distance_metric: str = 'l2_norm')[source]

A distance matrix with all the songs of a folder can be calculated.

Parameters:
  • fourier_folder
  • frames (int) –
  • distance_metric (str) –
  • multiprocess (bool) –
  • distance_metric
Returns: