Downloading the database#
JTD is now integrated within the latest version of mirdata
, and this is the recommended way to work with the database annotations moving forwards. To install mirdata
, run the following code (best inside a virtualenv
):
pip install git+https://github.com/mir-dataset-loaders/mirdata.git
Now, you can download the dataset and access the annotations simply by running the following lines of Python code:
import mirdata
jtd = mirdata.initialize('jtd')
jtd.download()
Next, we show how the metadata for a single performance can be loaded:
# Choose a random multitrack
multi_track = jtd.choice_multitrack()
# Access properties of the performance
name = multi_track.name
tempo = multi_track.tempo
time_signature = multi_track.time_signature
print(name, tempo, time_signature)
The final example loads MIDI from a single piano track into the pretty-midi
library (a common Python package for working with MIDI data) and plots a “piano roll” representation.
import seaborn as sns
from pretty_midi import PrettyMIDI
# Access the piano MIDI
piano = multi_track.piano # alternatively, .bass, .drums
midi = piano.midi
# Unpack the MIDI attributes from the mirdata representation
pitches = midi.pitches.astype(int)
starts, ends = midi.intervals[:, 0], midi.intervals[:, 1]
velocities = midi.confidence.astype(int)
all_data = zip(starts, ends, velocities, pitches)
# Convert to pretty_midi format
pm_notes = [
Note(start=s, end=e, pitch=p, velocity=v)
for (s, e, p, v) in all_data
]
instrument = Instrument(program=0)
instrument.notes = pm_notes
# Compute the piano roll with the default frames-per-second and display
piano_roll = instrument.get_piano_roll(fs=100)
sns.heatmap(piano_roll)
Further examples can be found in the mirdata
documentation.
Although it is not recommended, to download the raw database annotations without mirdata
, navigate to Releases and download the most recent .zip
file.