Modalis API¶
Modalis: Basics of Modality¶
The module modalis focuses on the fundamental elements of modality in a melody. Its defines a Melodie class for getting :
- The Dominant : It is based on :
** The most present frequency (Todo). ** The most probable frequency.
-
class
music22.modalis.
melodia
(file_path, transpose='No', freqref=300)[source]¶ Create the melodia object.
Paramètres: path to a list of frequencies (f0) in a .txt file. (A) – -
All attributes from music22.core.f0file.
-
clean_freqs
¶ numpy.ndarray
The list of frequencies without Zeros neither NaNs.
-
pdf
¶ numpy.ndarray
The Probability Density Function on the range 0-500 Hz.
-
xpeaks, xpeaks
numpy.ndarray
the Peaks of the PDF and their values.
-
ordredpeaks
¶ pandas.core.frame.DataFrame
The Peaks ordered by their probability.
-
dominante
¶ numpy.float64
the dominant frequency.
-
intervals
¶ pandas.core.series.Series
the list of intervals in the choosen Unit (default is savarts).
-
scale
¶ list
the Scale from the Dominant, compared to reference epimoric intervals.
Example
>>> import music22.modalis >>> file = '/Users/anas/AUDIO/Barraq/P1.wav' >>> Barraq = music22.modalis.melodia(file) Instance created with the txt file : P1.wav Instance created with the txt file : P1.txt The detected tonic is 167.696 Hz. >>> Barraq.file.basename 'P1.txt' >>> Barraq.freqs array([ nan, nan, nan, ..., nan, nan, nan]) >>> Barraq.clean_freqs array([ 155.564, 157.372, 160.123, ..., 159.201, 158.284, 156.466]) >>> Barraq.tonique 167.696 >>> Barraq.pdf array([ 1.55304474e-33, 5.65209492e-33, 2.03065388e-32, 7.20217980e-32, 2.52170476e-31, 8.71620406e-31, [...] 8.53621504e-26, 2.80105445e-26, 9.07308675e-27, 2.90111852e-27, 9.15698236e-28]) >>> Barraq.pdf_show <bound method melodia.pdf_show of <music22.modalis.melodia object at 0x102a32910>> >>> Barraq.ordredpeaks xpeaks ypeaks 1 243.486974 0.012244 0 201.402806 0.007772 3 324.649299 0.003007 2 278.557114 0.002709 4 375.751503 0.000785
-
get_scale
(reference='tonic')[source]¶ Get the scale of the melody.
Paramètres: reference (float) – the reference frequencies to calculate the scale. It could be the _tonic_ (self.tonique) or the _domin_ (self.dominante) Retourne: self.intervals – the intervals in the the choosen linear Unit. self.scale (): The scale compared to reference intervals. Type retourné: list
-
get_tonique
(percent=0.5, method='pdf')[source]¶ Get the tonic of a melody.
Paramètres: - percent (float) – the percentage of the last considered frequencies.
- method (str) – The method to be used for the analysis : “pdf” or “mode”.
Retourne: tonic – The detected tonic.
Type retourné: float
-
pdf_show
()[source] Show the pdf.
-
-
class
music22.modalis.
melodies
(path, transpose='No', freqref=300)[source]¶ This class defines a set of melodia-a and compares them.
-
music22.modalis.
transmode
(freqlist, freqref=300)[source]¶ Transpose all the frequencies by setting the _mode_ on a given reference frequency.
Paramètres: - freqlist (numpy.array) – A list of frequencies to be transposed.
- freqref (int) – The frequency reference to be transposed to. Default = 300.
Retourne: transfreq – a list of the transposed frequencies.
Type retourné: numpy.array