|
--- |
|
license: cc-by-sa-4.0 |
|
language: |
|
- en |
|
tags: |
|
- MIDI |
|
- Monster |
|
- Piano |
|
- Representations |
|
pretty_name: monsterpiano |
|
size_categories: |
|
- 100K<n<1M |
|
dataset_info: |
|
features: |
|
- name: midi_hash |
|
dtype: string |
|
- name: midi_score |
|
sequence: int64 |
|
- name: midi_signature |
|
sequence: |
|
sequence: int64 |
|
splits: |
|
- name: train |
|
num_bytes: 30593499836 |
|
num_examples: 580204 |
|
download_size: 4082220299 |
|
dataset_size: 30593499836 |
|
configs: |
|
- config_name: default |
|
data_files: |
|
- split: train |
|
path: data/train-* |
|
--- |
|
|
|
# Monster Piano |
|
|
|
## 580204 solo Piano MIDI scores representations from [Monster MIDI dataset](https://huggingface.co/datasets/projectlosangeles/Monster-MIDI-Dataset) |
|
|
|
![Monster-Piano-Logo.jpg](https://cdn-uploads.huggingface.co/production/uploads/5f57ea2d3f32f12a3c0692e6/b0Skg7NBSHipbTIFVXvc4.jpeg) |
|
|
|
*** |
|
|
|
## Installation and use |
|
|
|
*** |
|
|
|
### Load dataset |
|
|
|
```python |
|
#=================================================================== |
|
|
|
from datasets import load_dataset |
|
|
|
#=================================================================== |
|
|
|
monster_piano = load_dataset('asigalov61/Monster-Piano') |
|
|
|
dataset_split = 'train' |
|
dataset_entry_index = 0 |
|
|
|
dataset_entry = monster_piano[dataset_split][dataset_entry_index] |
|
|
|
midi_hash = dataset_entry['midi_hash'] |
|
midi_score = dataset_entry['midi_score'] |
|
midi_signature = dataset_entry['midi_signature'] |
|
|
|
print(midi_hash) |
|
print(midi_score[:15]) |
|
print(midi_signature[:4]) |
|
``` |
|
|
|
*** |
|
|
|
### Decode score to MIDI |
|
|
|
```python |
|
#=================================================================== |
|
# !git clone --depth 1 https://github.com/asigalov61/tegridy-tools |
|
#=================================================================== |
|
|
|
import TMIDIX |
|
|
|
#=================================================================== |
|
|
|
def decode_to_ms_MIDI_score(midi_score): |
|
|
|
score = [] |
|
|
|
time = 0 |
|
|
|
for m in midi_score: |
|
|
|
if 0 <= m < 128: |
|
time += m * 32 |
|
|
|
elif 128 < m < 256: |
|
dur = (m-128) * 32 |
|
|
|
elif 256 < m < 384: |
|
pitch = (m-256) |
|
|
|
elif 384 < m < 512: |
|
vel = (m-384) |
|
|
|
score.append(['note', time, dur, 0, pitch, vel, 0]) |
|
|
|
return score |
|
|
|
#=================================================================== |
|
|
|
ms_MIDI_score = decode_to_ms_MIDI_score(midi_score) |
|
|
|
#=================================================================== |
|
|
|
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(ms_MIDI_score, |
|
output_signature = midi_hash, |
|
output_file_name = midi_hash, |
|
track_name='Project Los Angeles' |
|
) |
|
``` |
|
|
|
*** |
|
|
|
### Calculate MIDI score signature |
|
|
|
```python |
|
#=================================================================== |
|
# !git clone --depth 1 https://github.com/asigalov61/tegridy-tools |
|
#=================================================================== |
|
|
|
from collections import Counter |
|
import TMIDIX |
|
|
|
#=================================================================== |
|
|
|
def get_score_signature(midi_score): |
|
|
|
score = [] |
|
|
|
time = 0 |
|
pt = 0 |
|
|
|
for m in midi_score: |
|
|
|
if 0 <= m < 128: |
|
time = m |
|
|
|
elif 256 < m < 384: |
|
pitch = (m-256) |
|
|
|
if time == pt: |
|
score.append([0, pitch]) |
|
else: |
|
score.append([time, pitch]) |
|
|
|
pt = time |
|
|
|
chords = [] |
|
cho = [] |
|
|
|
for s in score: |
|
if s[0] == 0: |
|
cho.append(s[1]) |
|
|
|
else: |
|
if cho: |
|
chords.append(cho) |
|
|
|
cho = [s[1]] |
|
|
|
pitches_chords = [] |
|
|
|
for c in chords: |
|
|
|
if len(c) > 1: |
|
|
|
tones_chord = sorted(set([p % 12 for p in c])) |
|
|
|
while tones_chord not in TMIDIX.ALL_CHORDS_SORTED: |
|
tones_chord = tones_chord[:-1] |
|
|
|
pitches_chords.append(TMIDIX.ALL_CHORDS_SORTED.index(tones_chord)+128) |
|
|
|
else: |
|
pitches_chords.append(c[0]) |
|
|
|
return list(Counter(pitches_chords).most_common()) |
|
``` |
|
|
|
*** |
|
|
|
### Project Los Angeles |
|
### Tegridy Code 2024 |