k-l-lambda commited on
Commit
e1e6e90
·
1 Parent(s): 3e25fd2

upgraded verovio to 6.2.0

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. app.py +13 -1
  3. web/score-player.js +12 -2
  4. web/vendor/verovio.bundle.js +2 -2
.gitignore CHANGED
@@ -14,4 +14,5 @@ __pycache__/
14
  .DS_Store
15
 
16
  *.local
 
17
  *.bak-*
 
14
  .DS_Store
15
 
16
  *.local
17
+ *.local.*
18
  *.bak-*
app.py CHANGED
@@ -393,8 +393,20 @@ SHEET_PLACEHOLDER = '''
393
 
394
 
395
  # Static-file URL prefix Gradio serves allowed_paths under (verified at 6.18.0).
 
 
 
 
 
 
396
  def _file_url (path):
397
- return '/gradio_api/file=' + path
 
 
 
 
 
 
398
 
399
 
400
  def build_head ():
 
393
 
394
 
395
  # Static-file URL prefix Gradio serves allowed_paths under (verified at 6.18.0).
396
+ # For real files we append a `?v=<mtime>` cache-buster so a redeploy that changes
397
+ # a vendored bundle / player script is picked up immediately instead of being
398
+ # served from the browser (or a CDN/proxy) cache under the same URL. Directories
399
+ # (soundfont, fluid) are passed through unchanged — the caller concatenates a
400
+ # trailing '/' + subpath, which a query string would corrupt; their individual
401
+ # assets are content-addressed / rarely change anyway.
402
  def _file_url (path):
403
+ url = '/gradio_api/file=' + path
404
+ try:
405
+ if os.path.isfile(path):
406
+ url += '?v=%d' % int(os.path.getmtime(path))
407
+ except OSError:
408
+ pass
409
+ return url
410
 
411
 
412
  def build_head ():
web/score-player.js CHANGED
@@ -421,11 +421,21 @@
421
  updateHighlights(time);
422
  }
423
 
 
 
 
 
 
 
 
 
 
 
424
  function updateHighlights (time) {
425
  if (!state.toolkit) return;
426
  try {
427
  const res = state.toolkit.getElementsAtTime(time);
428
- const now = new Set(res.notes || []);
429
  state.highlighted.forEach(function (id) {
430
  if (!now.has(id)) { const el = document.getElementById(id); if (el) el.classList.remove('ls-hl'); }
431
  });
@@ -435,7 +445,7 @@
435
  state.highlighted = now;
436
  // move the playback cursor to the first currently-sounding note
437
  const ids = res.notes || [];
438
- if (ids.length) updateCursor(ids[0]);
439
  } catch (e) { /* ignore */ }
440
  }
441
 
 
421
  updateHighlights(time);
422
  }
423
 
424
+ // When a score has repeats, verovio unfolds the MEI <expansion> for MIDI and
425
+ // the time-map, minting a fresh id with a "-rendN" suffix (N >= 2) for every
426
+ // note replayed on a later pass. The rendered SVG, however, only draws each
427
+ // notated note once (the un-suffixed id). So on the 2nd+ pass the time-map id
428
+ // has no element in the DOM and the highlight/cursor would vanish. Strip the
429
+ // suffix to map every replay back onto the single drawn note — the cursor
430
+ // re-walks the same bars on each pass. (Mirrors lilylet-live-editor's
431
+ // normalizeRepeatId in Player.svelte.)
432
+ function normalizeRepeatId (id) { return id.replace(/-rend\d+$/, ''); }
433
+
434
  function updateHighlights (time) {
435
  if (!state.toolkit) return;
436
  try {
437
  const res = state.toolkit.getElementsAtTime(time);
438
+ const now = new Set((res.notes || []).map(normalizeRepeatId));
439
  state.highlighted.forEach(function (id) {
440
  if (!now.has(id)) { const el = document.getElementById(id); if (el) el.classList.remove('ls-hl'); }
441
  });
 
445
  state.highlighted = now;
446
  // move the playback cursor to the first currently-sounding note
447
  const ids = res.notes || [];
448
+ if (ids.length) updateCursor(normalizeRepeatId(ids[0]));
449
  } catch (e) { /* ignore */ }
450
  }
451
 
web/vendor/verovio.bundle.js CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5c9210b71d6ac6d8b63b6cb4e4764a36fec17b73179d1465a4e9bf1cb9f848af
3
- size 7652579
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e73b4ed1a1cbdde990aa671b5b886c50114609ad5bfa6ec201ab86ca40ce9a4
3
+ size 8608639