@onjmin/dtm 2.1.11 → 2.1.13

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.
@@ -525,34 +525,36 @@
525
525
  };
526
526
 
527
527
  // src/pitch-curve.ts
528
- var STEP_GLIDE_MS = 15;
529
- var PORTAMENTO_MS = 70;
528
+ var STEP_GLIDE_RATIO = 0.35;
529
+ var PORTAMENTO_RATIO = 0.8;
530
+ var MAX_STEP_GLIDE_MS = 120;
531
+ var MAX_PORTAMENTO_MS = 400;
530
532
  var MIN_GLIDE_MS = 4;
533
+ var MAX_GLIDE_SPAN_RATIO = 0.9;
531
534
  var unitsToHz = (units) => 440 * 2 ** ((units - 2139) / 372);
532
535
  var smoothstep = (u) => u * u * (3 - 2 * u);
533
- var toKeyframes = (segments) => {
534
- const kf = [];
535
- let prevAtMs = 0;
536
- for (const seg of segments) {
537
- const atMs = seg.atSec * 1e3;
538
- const glideMs = Math.max(
539
- MIN_GLIDE_MS,
540
- Math.min(
541
- seg.portamento ? PORTAMENTO_MS : STEP_GLIDE_MS,
542
- (atMs - prevAtMs) * 0.5
543
- )
544
- );
545
- kf.push({
546
- hz: unitsToHz(seg.pitch),
547
- startMs: Math.max(0, atMs - glideMs / 2),
548
- glideMs
549
- });
550
- prevAtMs = atMs;
551
- }
552
- return kf;
536
+ var glideMsForSegments = (segments, totalMs) => segments.map((seg, i2) => {
537
+ const atMs = seg.atSec * 1e3;
538
+ const prevMs = i2 === 0 ? 0 : segments[i2 - 1].atSec * 1e3;
539
+ const nextMs = i2 + 1 < segments.length ? segments[i2 + 1].atSec * 1e3 : totalMs ?? atMs + (atMs - prevMs);
540
+ const span = Math.max(0, Math.min(atMs - prevMs, nextMs - atMs));
541
+ const ratio = seg.portamento ? PORTAMENTO_RATIO : STEP_GLIDE_RATIO;
542
+ const cap = seg.portamento ? MAX_PORTAMENTO_MS : MAX_STEP_GLIDE_MS;
543
+ return Math.min(
544
+ Math.max(MIN_GLIDE_MS, Math.min(span * ratio, cap)),
545
+ span * MAX_GLIDE_SPAN_RATIO
546
+ );
547
+ });
548
+ var toKeyframes = (segments, totalMs) => {
549
+ const glides = glideMsForSegments(segments, totalMs);
550
+ return segments.map((seg, i2) => ({
551
+ hz: unitsToHz(seg.pitch),
552
+ startMs: Math.max(0, seg.atSec * 1e3 - glides[i2] / 2),
553
+ glideMs: glides[i2]
554
+ }));
553
555
  };
554
- var pitchCurveFor = (baseHz, segments, preMs, vibrato) => {
555
- const kf = segments?.length ? toKeyframes(segments) : null;
556
+ var pitchCurveFor = (baseHz, segments, preMs, vibrato, totalMs) => {
557
+ const kf = segments?.length ? toKeyframes(segments, totalMs) : null;
556
558
  if (!kf && !vibrato) return baseHz;
557
559
  return (tMs) => {
558
560
  const sinceOnset = tMs - preMs;
@@ -627,7 +629,13 @@
627
629
  const targetHz = unitsToFreq(pitch);
628
630
  const audio = worldline.renderNote({
629
631
  pcm: spliced.pcm,
630
- pitch: pitchCurveFor(targetHz, pitchSegments, spliced.preMs, !!vibrato),
632
+ pitch: pitchCurveFor(
633
+ targetHz,
634
+ pitchSegments,
635
+ spliced.preMs,
636
+ !!vibrato,
637
+ durationMs
638
+ ),
631
639
  durationMs,
632
640
  preMs: spliced.preMs,
633
641
  consonantMs: spliced.consonantMs,
@@ -661,7 +669,13 @@
661
669
  if (worldline) {
662
670
  const audio = worldline.renderNote({
663
671
  pcm,
664
- pitch: pitchCurveFor(targetHz, pitchSegments, lead.preMs, !!vibrato),
672
+ pitch: pitchCurveFor(
673
+ targetHz,
674
+ pitchSegments,
675
+ lead.preMs,
676
+ !!vibrato,
677
+ durationMs
678
+ ),
665
679
  durationMs,
666
680
  ...lead,
667
681
  gender,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "onjmin",
3
3
  "license": "MIT",
4
4
  "name": "@onjmin/dtm",
5
- "version": "2.1.11",
5
+ "version": "2.1.13",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {
@@ -45,6 +45,7 @@
45
45
  "@biomejs/biome": "2.2.3",
46
46
  "@hono/node-server": "1.19.5",
47
47
  "@types/node": "26.1.1",
48
+ "@xmldom/xmldom": "0.9.12",
48
49
  "esbuild": "0.28.1",
49
50
  "hono": "4.10.1",
50
51
  "rimraf": "6.0.1",
@@ -62,7 +63,7 @@
62
63
  "dev": "rimraf dist && tsup && biome format src --write && tsx demo/server.ts",
63
64
  "build": "rimraf dist && tsup && biome format src --write",
64
65
  "check": "biome check src --write",
65
- "test": "tsx scripts/check-compose.ts && tsx scripts/check-registers.ts && tsx scripts/check-tracks.ts",
66
+ "test": "tsx scripts/check-version.ts && tsx scripts/check-compose.ts && tsx scripts/check-registers.ts && tsx scripts/check-tracks.ts && tsx scripts/check-lyrics-fade.ts && tsx scripts/check-pitch-glide.ts && tsx scripts/check-ust.ts && tsx scripts/check-musicxml.ts && tsx scripts/check-backing-audio.ts",
66
67
  "patch": "pnpm version patch",
67
68
  "minor": "pnpm version minor",
68
69
  "major": "pnpm version major",