Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen2 rolls #2

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 12 additions & 12 deletions .github/workflows/update-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: update-data

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

workflow_dispatch:

#schedule:
# - cron: "0 0 1 * *" # Runs at 00:00 UTC on the first of every month
# - cron: "0 0 1 * *" # Runs at 00:00 UTC on the first of every month

jobs:
build:
Expand All @@ -23,33 +23,33 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: 3.9

- name: install pipenv
run: |
pip install --user pipenv
USER_BASE=`python -m site --user-base`
export PATH=$USER_BASE/bin:$PATH

- name: install Python dependencies
run: pipenv install

- name: clone roll-wrangler repo
run: |
git clone https://github.com/pianoroll/roll-wrangler.git

- name: move roll-wrangler files to expected locations
run: |
mv ./roll-wrangler/midi/note/*.mid midi/note/.
mv ./roll-wrangler/midi/exp/*.mid midi/exp/.
mv ./roll-wrangler/txt/*.txt input/txt/.

- name: run the data generation script
run: pipenv run python build-pianolatron-files.py

- name: commit the new/updated output files to the repo
uses: EndBug/[email protected]
with:
add: '["output/json/*.json","output/midi/*.mid","midi/exp/*.mid","midi/note/*.mid","output/catalog.json"]'
message: 'Automatic update'
add: '["output/json/*.json","output/midi/exp/*.mod","output/midi/note/*.mid","midi/exp/*.mid","midi/note/*.mid","output/catalog.json"]'
message: "Automatic update"
author_name: GitHub Actions
author_email: [email protected]
73 changes: 40 additions & 33 deletions build-pianolatron-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Welte-Mignon red roll (T-100)": "welte-red",
"Welte-Mignon red roll (T-100).": "welte-red",
"Welte-Mignon red roll (T-100)..": "welte-red",
"Scale: 88n": "88-note",
"Scale: 88n.": "88-note",
"Scale: 65n.": "65-note",
"88n": "88-note",
Expand Down Expand Up @@ -120,7 +121,13 @@ def get_value_by_xpaths(xpaths):

if roll_type == "NA" or type_note == "standard":
for note in xml_tree.xpath("(x:note)", namespaces=NS):
if note is not None and note.text in ROLL_TYPES:
if (
note is not None
and note.text in ROLL_TYPES
# Most rolls of any type are marked as "88n", so don't let this
# setting overwrite a more specific roll type note.
and (ROLL_TYPES[note.text] != "88-note" or roll_type == "NA")
):
roll_type = ROLL_TYPES[note.text]

metadata = {
Expand Down Expand Up @@ -211,13 +218,13 @@ def get_value_by_xpaths(xpaths):
# Derive the value for the IIIF info.json file URL, which is eventually
# used to display the roll image in a viewer such as OpenSeadragon
image_id = re.search(
r"^.*?<label>(?:display image|jp2|Image 1)<\/label>.*?<file id=\"([^\.]*)\.jp2",
r"^.*?<label>(?:display image|jp2|[Ii]mage 1)<\/label>.*?<file id=\"([^\.]*)\.jp2",
xml_data,
re.MULTILINE | re.DOTALL,
).group(1)
metadata[
"image_url"
] = f"https://stacks.stanford.edu/image/iiif/{image_id.split('_')[0]}/{image_id}/info.json"
metadata["image_url"] = (
f"https://stacks.stanford.edu/image/iiif/{image_id.split('_')[0]}/{image_id}/info.json"
)

return metadata

Expand Down Expand Up @@ -249,7 +256,7 @@ def merge_midi_velocities(roll_data, hole_data, druid, roll_type):
output file for use when highlighting the note holes in the roll when it is
displayed in the Pianolatron app."""

midi_filepath = Path(f"output/midi/{druid}.mid")
midi_filepath = Path(f"output/midi/exp/{druid}.mid")

if not midi_filepath.exists():
logging.info(
Expand Down Expand Up @@ -342,7 +349,17 @@ def get_hole_report_data(druid, analysis_source_dir):
if key in roll_keys:
roll_data[key] = value.replace("px", "").strip()

while (line := _fh.readline()) and line != "@@END: HOLES\n":
# Out-of-spec holes are marked as "BAD" in a special section of the
# @ATON .txt hole data file, but are still interpreted as control or
# note holes when generating the MIDI file for the roll. So it seems
# best to include their data in the output JSON file so that they'll be
# highlighted properly in the player.
# NOTE that this parsing procedure assumes the BADHOLES section always
# follows the end of the HOLES section, and that the hole data file
# always has a BADHOLES section even when no bad holes have been
# detected on the roll.

while (line := _fh.readline()) and line != "@@END: BADHOLES\n":
if line == "@@BEGIN: HOLE\n":
hole = {}
if match := re.match(r"^@([^@\s]+):\s+(.*)", line):
Expand All @@ -355,8 +372,10 @@ def get_hole_report_data(druid, analysis_source_dir):
assert hole["NOTE_ATTACK"] == hole["ORIGIN_ROW"]
del hole["NOTE_ATTACK"]
if hole["ORIGIN_ROW"] >= hole["OFF_TIME"]:
logging.info(f"WARNING: invalid note duration: {hole}")
hole_data.append(hole)
# logging.info(f"WARNING: invalid note duration: {hole}")
dropped_holes += 1
else:
hole_data.append(hole)
else:
assert "OFF_TIME" not in hole
dropped_holes += 1
Expand Down Expand Up @@ -586,15 +605,10 @@ def main():
action="store_true",
help="Always download XML files, overwriting files in input/xml/",
)
argparser.add_argument(
"--use-exp-midi",
action="store_true",
help="Use expressionized MIDI for output .mid files (default is to use note MIDI)",
)
argparser.add_argument(
"--midi-source-dir",
default=MIDI_DIR,
help="Folder containg note (DIR/note/DRUID_note.mid) or expressionized (DIR/exp/DRUID_exp.mid) MIDI files",
help="Folder containg note (DIR/note/DRUID_note.mid) and expression (DIR/exp/DRUID_exp.mid) MIDI files",
)
argparser.add_argument(
"--analysis-source-dir",
Expand Down Expand Up @@ -636,24 +650,17 @@ def main():
logging.info(f"Unable to get metadata for DRUID {druid}, skipping")
continue

if (
not args.use_exp_midi
and Path(f"{args.midi_source_dir}/note/{druid}_note.mid").exists()
) or (
args.use_exp_midi
and not Path(f"{args.midi_source_dir}/exp/{druid}_exp.mid").exists()
):
copy(
Path(f"{args.midi_source_dir}/note/{druid}_note.mid"),
Path(f"output/midi/{druid}.mid"),
)
note_midi = MidiFile(Path(f"output/midi/{druid}.mid"))
metadata["NOTE_MIDI_TPQ"] = note_midi.ticks_per_beat
elif Path(f"{args.midi_source_dir}/exp/{druid}_exp.mid").exists():
copy(
Path(f"{args.midi_source_dir}/exp/{druid}_exp.mid"),
Path(f"output/midi/{druid}.mid"),
)
copy(
Path(f"{args.midi_source_dir}/note/{druid}_note.mid"),
Path(f"output/midi/note/{druid}.mid"),
)
note_midi = MidiFile(Path(f"output/midi/note/{druid}.mid"))
metadata["NOTE_MIDI_TPQ"] = note_midi.ticks_per_beat

copy(
Path(f"{args.midi_source_dir}/exp/{druid}_exp.mid"),
Path(f"output/midi/exp/{druid}.mid"),
)

if WRITE_TEMPO_MAPS:
metadata["tempoMap"] = build_tempo_map_from_midi(druid)
Expand Down
17 changes: 17 additions & 0 deletions input/druids/gen2_88_note_druids.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bv720gq2633
bx696fq3697
cn498vz4750
ff220ct4404
fz108ts9393
gp583km0927
kh288bx3828
ky144fd6229
nr538vy9112
ns724rz6542
ny190nz5753
ph633tr8751
tn472jy2817
wb438xf5756
wt920yb3768
xn815zk7379
xn861tf7013
Binary file modified midi/exp/bh573cc4821_exp.mid
Binary file not shown.
Binary file modified midi/exp/bp752qs6053_exp.mid
Binary file not shown.
Binary file modified midi/exp/br324td1538_exp.mid
Binary file not shown.
Binary file modified midi/exp/br351xc9456_exp.mid
Binary file not shown.
Binary file added midi/exp/bv720gq2633_exp.mid
Binary file not shown.
Binary file added midi/exp/bx696fq3697_exp.mid
Binary file not shown.
Binary file modified midi/exp/ch984dr4932_exp.mid
Binary file not shown.
Binary file added midi/exp/cn498vz4750_exp.mid
Binary file not shown.
Binary file modified midi/exp/cw746gb6753_exp.mid
Binary file not shown.
Binary file modified midi/exp/cy287wz7683_exp.mid
Binary file not shown.
Binary file modified midi/exp/dk418xy4378_exp.mid
Binary file not shown.
Binary file modified midi/exp/dv468zh8208_exp.mid
Binary file not shown.
Binary file added midi/exp/ff220ct4404_exp.mid
Binary file not shown.
Binary file added midi/exp/fz108ts9393_exp.mid
Binary file not shown.
Binary file modified midi/exp/gn803sk7089_exp.mid
Binary file not shown.
Binary file added midi/exp/gp583km0927_exp.mid
Binary file not shown.
Binary file modified midi/exp/gv741wj6162_exp.mid
Binary file not shown.
Binary file modified midi/exp/hb523vs3190_exp.mid
Binary file not shown.
Binary file modified midi/exp/hh361xy4933_exp.mid
Binary file not shown.
Binary file modified midi/exp/hj502vv5162_exp.mid
Binary file not shown.
Binary file modified midi/exp/ht999gf1829_exp.mid
Binary file not shown.
Binary file modified midi/exp/jg489yw0942_exp.mid
Binary file not shown.
Binary file modified midi/exp/jp202jq5812_exp.mid
Binary file not shown.
Binary file modified midi/exp/jv485mx5227_exp.mid
Binary file not shown.
Binary file modified midi/exp/jy320zw1102_exp.mid
Binary file not shown.
Binary file added midi/exp/kh288bx3828_exp.mid
Binary file not shown.
Binary file modified midi/exp/km927sd2616_exp.mid
Binary file not shown.
Binary file added midi/exp/ky144fd6229_exp.mid
Binary file not shown.
Binary file modified midi/exp/kz454tt7354_exp.mid
Binary file not shown.
Binary file modified midi/exp/ms604gp1206_exp.mid
Binary file not shown.
Binary file modified midi/exp/mw139zj5450_exp.mid
Binary file not shown.
Binary file added midi/exp/nr538vy9112_exp.mid
Binary file not shown.
Binary file added midi/exp/ns724rz6542_exp.mid
Binary file not shown.
Binary file modified midi/exp/nw222vm1898_exp.mid
Binary file not shown.
Binary file added midi/exp/ny190nz5753_exp.mid
Binary file not shown.
Binary file modified midi/exp/ny606dc0992_exp.mid
Binary file not shown.
Binary file added midi/exp/ph633tr8751_exp.mid
Binary file not shown.
Binary file modified midi/exp/ps866sb0637_exp.mid
Binary file not shown.
Binary file modified midi/exp/pz594dj8436_exp.mid
Binary file not shown.
Binary file modified midi/exp/qd454gb9111_exp.mid
Binary file not shown.
Binary file modified midi/exp/qf152xr6941_exp.mid
Binary file not shown.
Binary file modified midi/exp/qh464nj1973_exp.mid
Binary file not shown.
Binary file modified midi/exp/qj765hb3428_exp.mid
Binary file not shown.
Binary file modified midi/exp/rh357hg0211_exp.mid
Binary file not shown.
Binary file modified midi/exp/rs892mq5364_exp.mid
Binary file not shown.
Binary file modified midi/exp/rx870zt5437_exp.mid
Binary file not shown.
Binary file modified midi/exp/sb388kg1678_exp.mid
Binary file not shown.
Binary file modified midi/exp/sm344xv2220_exp.mid
Binary file not shown.
Binary file modified midi/exp/sz948zd1422_exp.mid
Binary file not shown.
Binary file modified midi/exp/tc493dq4498_exp.mid
Binary file not shown.
Binary file modified midi/exp/tn412mq0486_exp.mid
Binary file not shown.
Binary file added midi/exp/tn472jy2817_exp.mid
Binary file not shown.
Binary file modified midi/exp/tp613xb9088_exp.mid
Binary file not shown.
Binary file modified midi/exp/vc908xz3554_exp.mid
Binary file not shown.
Binary file modified midi/exp/vc943nk4921_exp.mid
Binary file not shown.
Binary file modified midi/exp/vk572hg6636_exp.mid
Binary file not shown.
Binary file modified midi/exp/vq862qw5039_exp.mid
Binary file not shown.
Binary file modified midi/exp/vr247rd6766_exp.mid
Binary file not shown.
Binary file modified midi/exp/vz386xg9451_exp.mid
Binary file not shown.
Binary file added midi/exp/wb438xf5756_exp.mid
Binary file not shown.
Binary file modified midi/exp/wq696jd1149_exp.mid
Binary file not shown.
Binary file added midi/exp/wt920yb3768_exp.mid
Binary file not shown.
Binary file modified midi/exp/wx138dx1211_exp.mid
Binary file not shown.
Binary file modified midi/exp/xn196fs1128_exp.mid
Binary file not shown.
Binary file added midi/exp/xn815zk7379_exp.mid
Binary file not shown.
Binary file added midi/exp/xn861tf7013_exp.mid
Binary file not shown.
Binary file modified midi/exp/xy736dn5214_exp.mid
Binary file not shown.
Binary file modified midi/exp/xz373zg4809_exp.mid
Binary file not shown.
Binary file modified midi/exp/zk199jz1564_exp.mid
Binary file not shown.
Binary file modified midi/exp/zm791gz4425_exp.mid
Binary file not shown.
Binary file modified midi/exp/zx785pg9042_exp.mid
Binary file not shown.
Binary file modified midi/exp/zy618kz1670_exp.mid
Binary file not shown.
Binary file modified midi/note/bp752qs6053_note.mid
Binary file not shown.
Binary file modified midi/note/br351xc9456_note.mid
Binary file not shown.
Binary file added midi/note/bv720gq2633_note.mid
Binary file not shown.
Binary file added midi/note/bx696fq3697_note.mid
Binary file not shown.
Binary file modified midi/note/ch984dr4932_note.mid
Binary file not shown.
Binary file added midi/note/cn498vz4750_note.mid
Binary file not shown.
Binary file modified midi/note/cw746gb6753_note.mid
Binary file not shown.
Binary file modified midi/note/cy287wz7683_note.mid
Binary file not shown.
Binary file modified midi/note/dk418xy4378_note.mid
Binary file not shown.
Binary file modified midi/note/dv468zh8208_note.mid
Binary file not shown.
Binary file added midi/note/ff220ct4404_note.mid
Binary file not shown.
Binary file added midi/note/fz108ts9393_note.mid
Binary file not shown.
Binary file modified midi/note/gn803sk7089_note.mid
Binary file not shown.
Binary file added midi/note/gp583km0927_note.mid
Binary file not shown.
Binary file modified midi/note/gv741wj6162_note.mid
Binary file not shown.
Binary file modified midi/note/hb523vs3190_note.mid
Binary file not shown.
Binary file modified midi/note/ht999gf1829_note.mid
Binary file not shown.
Binary file modified midi/note/jg489yw0942_note.mid
Binary file not shown.
Binary file modified midi/note/jp202jq5812_note.mid
Binary file not shown.
Binary file modified midi/note/jv485mx5227_note.mid
Binary file not shown.
Binary file modified midi/note/jy320zw1102_note.mid
Binary file not shown.
Binary file added midi/note/kh288bx3828_note.mid
Binary file not shown.
Binary file modified midi/note/km927sd2616_note.mid
Binary file not shown.
Binary file added midi/note/ky144fd6229_note.mid
Binary file not shown.
Binary file modified midi/note/kz454tt7354_note.mid
Binary file not shown.
Binary file modified midi/note/ms604gp1206_note.mid
Binary file not shown.
Binary file modified midi/note/mw139zj5450_note.mid
Binary file not shown.
Binary file added midi/note/nr538vy9112_note.mid
Binary file not shown.
Binary file added midi/note/ns724rz6542_note.mid
Binary file not shown.
Binary file modified midi/note/nw222vm1898_note.mid
Binary file not shown.
Binary file added midi/note/ny190nz5753_note.mid
Binary file not shown.
Binary file added midi/note/ph633tr8751_note.mid
Binary file not shown.
Binary file modified midi/note/ps866sb0637_note.mid
Binary file not shown.
Binary file modified midi/note/pz594dj8436_note.mid
Binary file not shown.
Binary file modified midi/note/qd454gb9111_note.mid
Binary file not shown.
Binary file modified midi/note/qf152xr6941_note.mid
Binary file not shown.
Binary file modified midi/note/qh464nj1973_note.mid
Binary file not shown.
Binary file modified midi/note/qj765hb3428_note.mid
Binary file not shown.
Binary file modified midi/note/rh357hg0211_note.mid
Binary file not shown.
Binary file modified midi/note/rs892mq5364_note.mid
Binary file not shown.
Binary file modified midi/note/rx870zt5437_note.mid
Binary file not shown.
Binary file modified midi/note/sb388kg1678_note.mid
Binary file not shown.
Binary file modified midi/note/sm344xv2220_note.mid
Binary file not shown.
Binary file modified midi/note/sz948zd1422_note.mid
Binary file not shown.
Binary file modified midi/note/tc493dq4498_note.mid
Binary file not shown.
Binary file modified midi/note/tn412mq0486_note.mid
Binary file not shown.
Binary file added midi/note/tn472jy2817_note.mid
Binary file not shown.
Binary file modified midi/note/tp613xb9088_note.mid
Binary file not shown.
Binary file modified midi/note/vc908xz3554_note.mid
Binary file not shown.
Binary file modified midi/note/vc943nk4921_note.mid
Binary file not shown.
Binary file modified midi/note/vk572hg6636_note.mid
Binary file not shown.
Binary file modified midi/note/vq862qw5039_note.mid
Binary file not shown.
Binary file modified midi/note/vr247rd6766_note.mid
Binary file not shown.
Binary file modified midi/note/vz386xg9451_note.mid
Binary file not shown.
Binary file added midi/note/wb438xf5756_note.mid
Binary file not shown.
Binary file modified midi/note/wq696jd1149_note.mid
Binary file not shown.
Binary file added midi/note/wt920yb3768_note.mid
Binary file not shown.
Binary file modified midi/note/wx138dx1211_note.mid
Binary file not shown.
Binary file modified midi/note/xn196fs1128_note.mid
Binary file not shown.
Binary file added midi/note/xn815zk7379_note.mid
Binary file not shown.
Binary file added midi/note/xn861tf7013_note.mid
Binary file not shown.
Binary file modified midi/note/xy736dn5214_note.mid
Binary file not shown.
Binary file modified midi/note/xz373zg4809_note.mid
Binary file not shown.
Binary file modified midi/note/zk199jz1564_note.mid
Binary file not shown.
Binary file modified midi/note/zm791gz4425_note.mid
Binary file not shown.
Binary file modified midi/note/zx785pg9042_note.mid
Binary file not shown.
Binary file modified midi/note/zy618kz1670_note.mid
Binary file not shown.
Loading
Loading