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
`music22.scale.``kde`(freqs)[source]

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. pdf – the pdf function of freqs. scipy.stats.kde.gaussian_kde
Exemple:
```>>> from music22 import diastema,scale
>>> import matplotlib.pyplot as plt
```
```>>> file_path = "/Users/anas/AUDIO/Barraq/txt/P0.txt"
>>> freqs = music22.core.clean_list(freqs)
>>> pdf = music22.scale.kde(freqs)
>>> plt.plot(pdf)
>>> plt.show()
```
`music22.scale.``order_peaks`(xpeaks, ypeaks)[source]

Orders the peaks following their probability

Paramètres: xpeaks (numpy.array) – list of peaks (Hz.) ypeaks (numpy.array) – probability of the peaks ordredpeaks – a table with ordered frequencies pandas.core.frame.DataFrame
`music22.scale.``pdf_show`(pdf, xpeaks, ypeaks, label='pdf')[source]

Plot the PDF and the peaks of the frequencies.

Paramètres: 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
`music22.scale.``peaks`(pdf)[source]

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. xpeaks – the peaks frequencies. ypeaks (numpy.array) : the probability of the peaks. numpy.array
`music22.scale.``set_bw_method`(method)[source]

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