forked from erwald/midihum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (46 loc) · 2.12 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from pathlib import Path
import click
from find_duplicate_midi_files import find_duplicate_midi_files
from midi_scraper import scrape_midi_data
from prepare_midi import prepare_midi_data
from rachel_tabular import RachelTabular
import time_displacer
@click.group()
def rachel():
"""Rachel is a tool for humanizing (that is, determining velocity values of notes for) MIDI files."""
@rachel.command()
@click.argument("source_dir")
@click.argument("destination_dir")
def prepare(source_dir: str, destination_dir: str):
"""Convert MIDI data in SOURCE_DIR to DataFrame and store in DESTINATION_DIR."""
assert source_dir != destination_dir, (source_dir, destination_dir)
prepare_midi_data(Path(source_dir), Path(destination_dir))
@rachel.command()
@click.argument("destination_dir")
def scrape_midi(destination_dir: str):
"""Download all e-Piano Competition MIDI files and store in DESTINATION_DIR."""
scrape_midi_data(Path(destination_dir))
@rachel.command()
@click.argument("target_dir")
def find_midi_duplicates(target_dir: str):
"""Searches target dir for duplicate MIDI files and prints out a list of them. Warning: this is kinda slow."""
find_duplicate_midi_files(Path(target_dir))
@rachel.command()
@click.argument("source")
@click.argument("destination")
@click.option("--rescale/--no-rescale", default=True, help="Normalises and scales velocities as a final step.")
def humanize(source: str, destination: str, rescale: bool):
"""Humanize MIDI file at SOURCE, writing to DESTINATION."""
assert source != destination, (source, destination)
tabular = RachelTabular(predict_only=True)
tabular.humanize(Path(source), Path(destination), rescale=rescale)
@rachel.command()
@click.argument("source")
@click.argument("destination")
def time_displace(source: str, destination: str):
"""Displace (jitter) note events of MIDI file at SOURCE, writing to DESTINATION."""
assert source != destination, (source, destination)
# time_displacer.displace(Path(source), Path(destination))
raise NotImplementedError("needs refactoring")
if __name__ == "__main__":
rachel() # pylint: disable=no-value-for-parameter