A python library for plotting note distributions in different tonal spaces.
The library contains the following files
functions.py
,reader.py
,modified_music_xml.py
,parser.py
static.py
In order to use pitchplots you need a running Python 3 environment and the following libraries:
- matplotlib
- pandas
- numpy
to install these libraries, you can do the following command in the prompt:
python3 -m pip install matplotlib>=3.0.1 pandas>=0.23.4 numpy>=1.15.3
or if you're using the Anaconda prompt
pip install matplotlib>=3.0.1 pandas>=0.23.4 numpy>=1.15.3
Or you can use the requirements.txt file in the github. Dont' forget to set the path to the one of the requirements file.
python3 -m pip install -r requirements.txt
You can install the pitchplots package on pypi with pip using the following command in the prompt:
python3 -m pip install pitchplots
or if you're using the Anaconda prompt
pip install pitchplots
Pitchplots has currently three plotting functions
tonnetz
uses a.csv
file or a pandas DataFrame of a piece of music to do a hexagonal 2D representation ("Tonnetz").circle
uses a csv file or a pandas DataFrame of a piece of music to represent the notes by fifth or chromatic.line
uses a csv file or a pandas DataFrame of a piece of music to represent the notes by fifth or chromatic on a line, the unrolled equivalent to the circle function.
Two animation functions
tonnetz_animation
plot the same graphs as thetonnetz
function but is animated.circle_animation
plot the same graphs as thecircle
function but is animated.
and one function to parse (compressed) MusicXML files and uncompressed xml files
xml_to_csv
uses a.mxl
or.xml
file and parses it into a.csv
file using the TensorFlow Magentamusicxml_parser.py
.
Pitchplots plots note distributions from MusicXML files (.xml
or .mxl
). You can either specify your own file or use the test file data_example.mxl
. contained in the package.
The first step is to parse the file into a note list representation that is stored in a pandas DataFrame where each line corresponds to a note or a rest.
import pitchplots.parser as ppp
# If no filepath is specified, will automatically charge data_example.mxl
df_data_example = ppp.xml_to_csv(save_csv=True)
To use your own file, add filepath=
with the location of your file in the parameters of the function xml_to_csv
.
In order to plot the notes of a piece, import the pitchplots.static
module and use one of its plotting functions. They take as input the output of the parser, i.e. either a DataFrame object:
import pitchplots.static as pps
pps.tonnetz(df_data_example)
or a CSV file:
import pitchplots.static as pps
pps.tonnetz('csv/data_example.csv')
In both cases the output should look like the following image (of course, the note distribution depends on the piece you are plotting):
Or if you want to plot a line:
import pitchplots.static as pps
pps.line(df_data_example)
or a CSV file:
import pitchplots.static as pps
pps.line('csv/data_example.csv')
In both cases the output should look like the following image (of course, the note distribution depends on the piece you are plotting):
Or if you want to plot a circle:
import pitchplots.static as pps
pps.circle(df_data_example)
or a CSV file:
import pitchplots.static as pps
pps.circle('csv/data_example.csv')
In both cases the output should look like the following image (of course, the note distribution depends on the piece you are plotting):
see the following files for more informations about the functions parser, line, circle, tonnetz, circle_animation and tonnetz_animation.
parser documentation line documentation circle documentation tonnetz documentation
- Fabian C. Moss
- Timothy Loayza
- Martin Rohrmeier
If you use pitchplots in academic publications, please cite the library as
Moss, Fabian C.; Loayza, Timothy & Rohrmeier Martin. (2019). pitchplots (Version 1.4.2). Zenodo. http://doi.org/10.5281/zenodo.3265393
The modified_musicxml_parser.py file is taken from the TensorFlow Magenta project and has been modified. See the modifications and the Magenta License.
Pitchplots is licensed under the MIT License - see the LICENSE file for details