@dsebastien/music-notation 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tab/index.js CHANGED
@@ -422,6 +422,8 @@ var SIGN = "(##|bb|#|b|♯|♭)?";
422
422
  var syllableLetter = (syllable) => SYLLABLE_LETTER[plain2(syllable)];
423
423
  var AFTER_ROOT = /^(?:$|[0-9/(+°øΔ^-]|m|M|a(?:dd|ug|lt)|sus|dim)/;
424
424
  var QUALITY_WORD = /^(?:[0-9(+°øΔ^]|m|M|a(?:dd|ug|lt)|sus|dim)/;
425
+ var WORD_QUALITY = /^(?:major|minor)$/i;
426
+ var joinsAsQuality = (word) => QUALITY_WORD.test(word) && !WORD_QUALITY.test(word);
425
427
  var reads = (letters) => midiOf(letters) !== null || /^[A-G]/.test(letters) && parseChord(letters) !== null;
426
428
  function rootToken(token, naming, h, solfegeLine = false) {
427
429
  const b = naming === "german" ? /^B(?![#♯b♭x])(.*)$/.exec(token) : null;
@@ -492,7 +494,7 @@ function read(text, naming, options, changes) {
492
494
  let out = text.normalize("NFC").replace(new RegExp(`(^|[\\s,/|])${SYLLABLE}\\s+(dièse|diese|bémol|bemol)(?=$|[\\s,|])`, "g"), (_, before, syllable, sign) => `${before}${syllable}${/^d/.test(sign) ? "#" : "b"}`);
493
495
  if (options.chord) {
494
496
  const joined = new RegExp(`^\\s*${SYLLABLE}${SIGN}\\s+(\\S+)\\s*$`).exec(out);
495
- if (joined && QUALITY_WORD.test(joined[3])) {
497
+ if (joined && joinsAsQuality(joined[3])) {
496
498
  const word = `${joined[1]}${joined[2] ?? ""}${joined[3]}`;
497
499
  const letters = rootToken(word, naming, h) ?? letterPiece(word, naming, h);
498
500
  if (letters !== word) {
@@ -505,7 +507,7 @@ function read(text, naming, options, changes) {
505
507
  for (let i = 0;i + 2 < words.length; i += 2) {
506
508
  const head = words[i];
507
509
  const next = words[i + 2];
508
- if (!syllableOnly(head) || !QUALITY_WORD.test(next))
510
+ if (!syllableOnly(head) || !joinsAsQuality(next))
509
511
  continue;
510
512
  if (naming !== "solfege" && reads(head))
511
513
  continue;
@@ -2244,7 +2246,11 @@ function renderTab(language, source, host, options) {
2244
2246
  staveProfile: "Default",
2245
2247
  resources: colorsOf(el)
2246
2248
  },
2247
- player: { playerMode: at.PlayerMode.Disabled, enableUserInteraction: true }
2249
+ player: {
2250
+ playerMode: at.PlayerMode.Disabled,
2251
+ enableUserInteraction: true,
2252
+ scrollMode: at.ScrollMode.Off
2253
+ }
2248
2254
  };
2249
2255
  const current = new at.AlphaTabApi(surface, settings);
2250
2256
  api = current;
@@ -2378,6 +2384,11 @@ function soundfontPlayer(alphaTab, api) {
2378
2384
  stopped = true;
2379
2385
  clearTimeout(timer);
2380
2386
  player.stop();
2387
+ },
2388
+ setVolume(next) {
2389
+ if (stopped || !Number.isFinite(next))
2390
+ return;
2391
+ current.masterVolume = Math.min(1, Math.max(0, next));
2381
2392
  }
2382
2393
  };
2383
2394
  }
@@ -2438,18 +2449,19 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
2438
2449
  play(events, options) {
2439
2450
  let handle = null;
2440
2451
  let stopped = false;
2452
+ let volume = options.volume;
2441
2453
  start().then((ok) => {
2442
2454
  if (stopped)
2443
2455
  return;
2444
2456
  try {
2445
2457
  if (ok) {
2446
- handle = inner.play(events, options);
2458
+ handle = inner.play(events, { ...options, volume });
2447
2459
  return;
2448
2460
  }
2449
2461
  } catch {}
2450
2462
  if (!fallback)
2451
2463
  return;
2452
- handle = fallback.play(events, options);
2464
+ handle = fallback.play(events, { ...options, volume });
2453
2465
  if (!fallback.reportsStart)
2454
2466
  options.onStart?.();
2455
2467
  });
@@ -2457,6 +2469,10 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
2457
2469
  stop() {
2458
2470
  stopped = true;
2459
2471
  handle?.stop();
2472
+ },
2473
+ setVolume(next) {
2474
+ volume = next;
2475
+ handle?.setVolume?.(next);
2460
2476
  }
2461
2477
  };
2462
2478
  },
@@ -2501,5 +2517,5 @@ export {
2501
2517
  textTabToAlphaTex
2502
2518
  };
2503
2519
 
2504
- //# debugId=793BC5718CFFD45C64756E2164756E21
2520
+ //# debugId=BC271816D895D2D864756E2164756E21
2505
2521
  //# sourceMappingURL=index.js.map