System Message: WARNING/2 (/Users/anas/python/music22/docs/source/scale.rst, line 2)

Field list ends without a blank line; unexpected unindent.

Scale : Analyse the scale of a melody.

This module provides function to analyse the scale of a melody.

  • Evaluate the PDF of the frequencies
  • Get Peaks of the main frequencies
  • Plots the PDF and the Peaks
  • Gives the scale and compare intervals to reference epimoric intervals

Estimate the pdf of the freqs using a Kernel Density Estimation.

The estimation is done on the frequencies (0,500).

Paramètres:freqs (numpy.ndarray) – A list of frequencies in Hz.
Retourne:pdf – the pdf function of freqs.
Type retourné:scipy.stats.kde.gaussian_kde
>>> from music22 import diastema,scale
>>> import matplotlib.pyplot as plt
>>> file_path = "/Users/anas/AUDIO/Barraq/txt/P0.txt"
>>> freqs = numpy.loadtxt(file_path)
>>> freqs = music22.core.clean_list(freqs)
>>> pdf = music22.scale.kde(freqs)
>>> plt.plot(pdf)
music22.scale.order_peaks(xpeaks, ypeaks)[source]

Orders the peaks following their probability

  • xpeaks (numpy.array) – list of peaks (Hz.)
  • ypeaks (numpy.array) – probability of the peaks

ordredpeaks – a table with ordered frequencies

Type retourné:


music22.scale.pdf_show(pdf, xpeaks, ypeaks, label='pdf')[source]

Plot the PDF and the peaks of the frequencies.

  • pdf (numpy.ndarray) – the PDF of the frequencies given by kde()
  • xpeaks (numpy.ndarray) – frequencies of the peaks, given by peaks()
  • ypeaks (numpy.ndarray) – pdf values of the peaks, given by peaks()
  • label (str) – label to give to the figure (optional)
Returns :
A plot

Get the peaks of the estimated Probability Density Function.

The estimation is done on the frequencies (0,500).

Paramètres:pdf (numpy.array) – the probability of the frequencies in the range 0-500 Hz.
Retourne:xpeaks – the peaks frequencies. ypeaks (numpy.array) : the probability of the peaks.
Type retourné:numpy.array

Set the bw_method for gaussian.kde.

Args :
bw_method (str or scalar) : ‘scott’ (default), ‘silvermann’
music22.scale.set_xrange(min, max)[source]

Set the limits of x for plots and pdfs.

Args :
xmin (int): x-minimum xmax (int): x-maximum