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. Retourne: pdf – the pdf function of freqs. Type retourné: 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 = numpy.loadtxt(file_path) >>> 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
Retourne: ordredpeaks – a table with ordered frequencies
Type retourné: 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. Retourne: xpeaks – the peaks frequencies. ypeaks (numpy.array) : the probability of the peaks. Type retourné: numpy.array