<jupyter_start><jupyter_text>Creating Piano Rolls from MusicXML or MIDI files<jupyter_code>import partitura as pt
import os
import matplotlib.pyplot as plt
path_to_musicxml = os.path.join("..","introduction","example_data","Chopin_op10_no3.musicxml")
part = pt.load_musicxml(path_to_musicxml)
piano_roll = pt.utils.music.compute_pianoroll(part)
piano_roll
%matplotlib inline
plt.imshow(piano_roll.todense(), aspect = "auto")<jupyter_output><empty_output><jupyter_text>possible modifications:- pitch margins- time margins- note encodings (onset only, fixed level, exponential/linear decay...)- offset encodings (how do you know that two consecutive notes are two notes instead of 1 long one?)- time unit and its sample rate Exercise: draw the piano roll of the performance MIDI file (example_file/filename.mid) to a piano roll with time unit in seconds, with 4 samples per second, where only the onsets are encoding (single pixel width per note)!hint: check https://github.com/CPJKU/partitura/blob/master/partitura/utils/music.py<jupyter_code># your code here...<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09440879926672777, 'fraction_numerical': 0.00458295142071494, 'mean_word_length': 6.378378378378378, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '584992', 'license': 'MIT', 'n_tokens_mistral': 360, 'n_tokens_neox': 337, 'n_words': 107, 'path': 'alignment/creating_piano_rolls.ipynb', 'repo_name': 'MusicalInformatics/miws2021env', 'size': '1091'}