@onjmin/dtm 1.0.6 → 1.0.7

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/index.d.mts CHANGED
@@ -1996,6 +1996,16 @@ declare const drawGrid: (noteLengthSteps?: number) => void;
1996
1996
  * 指定されたノートの配列を描画します。
1997
1997
  */
1998
1998
  declare const drawNotes: (notes: Note[], color?: number[]) => void;
1999
+ /**
2000
+ * ノートの上に歌詞(かな)を重ねて描画します。
2001
+ *
2002
+ * 音節の割り当ては発音側(StreamVoiceTrack の組み立て)と同じ規則で、
2003
+ * startStep 昇順に並べたノートの i 番目へ syllables[i] を対応させます。
2004
+ * 音節が足りないぶんのノートには何も描きません。
2005
+ *
2006
+ * 文字はノート矩形でクリップするため、隣のノートへはみ出しません。
2007
+ */
2008
+ declare const drawNoteLyrics: (notes: Note[], syllables: string[]) => void;
1999
2009
  /**
2000
2010
  * 選択範囲の四角形を描画します。
2001
2011
  */
@@ -2473,4 +2483,4 @@ declare const encodeWavPCM16: (channels: Float32Array[], sampleRate: number) =>
2473
2483
  /** Float32Array のチャンクを1本へ連結する。 */
2474
2484
  declare const concatFloat32: (chunks: Float32Array[]) => Float32Array;
2475
2485
 
2476
- export { type AddNoteOptions, type AnyDrumPattern, type ApplyChordOptions, type ChordPatternType, type ChordPlacement, type ChordPlayerInstance, type ConsumedSyllable, type CoreEventHandlers, type CustomVocalDef, DAW_CSS, DEFAULT_BPM, DEFAULT_GATE, DEFAULT_PAN, DEFAULT_PLAYBACK_VELOCITY, DEFAULT_STEPS_PER_BAR, DEFAULT_VELOCITY, DEFAULT_VOCAL_VOLUME, DRUM_FONT, DRUM_KEYS, DRUM_PATTERNS, type DawInstance, type DawMode, type DawOptions, type DawViewState, type DrumPattern, type DrumPatternDef, type DtmStudio, type DtmStudioEngines, type DtmStudioOptions, type ExportMidiOptions, type FadeScheduleParams, GM_INSTRUMENT_NAMES, INSTRUMENT_PRESETS, type InstrumentPreset, KOE_BASE_URL, KOE_VOICEBANKS, KOE_VOICEBANK_LABELS, KOE_VOICEBANK_TERMS, type KoeVoiceOptions, LinkedList, type LoopConfig, type LoopPoint, type LyricSyllable, type LyricSyncData, type LyricTrack, type LyricsConductor, MAX_VOCAL_VOLUME, MMLCore, type MMLDisplayToken, type MMLNotePlacement, MML_END_MARKER, type MidiExtraction, type MidiNotePlacement, MidiSearchClient, type MidiSearchConfig, type MidiTrackAnalysis, type MmlMeta, type MmlPlayback, type MmlPlayerInstance, type MmlPlayerOptions, type ModeSwitchInstance, type ModeSwitchOptions, type MountChordPlayerOptions, type MountEditorOptions, type MountPlayerOptions, type Note, type NoteData, type NoteRemove, type OctaveUnisonMode, PITCH_MAP, PREWARM_NOTES, type ParseMMLOptions, type ParseMidiFn, type ParsedMML, type PianoRollInstance, type PianoRollOptions, type PicotuneSearchParams, type PicotuneSong, type PitchToken, type PlayChordsOptions, type PlayDrumEvent, type PlayMmlOptions, type PlayNoteEvent, type PlayNoteOptions, type PlayPlacementsOptions, type PlaySingingMmlOptions, type PlaybackCue, type PlaybackState, type PresetSelectInstance, type PresetSelectOptions, type PreviewSoundCallback, type RenderConfig, type Sequencer, type SequencerOptions, type SequencerTrack, type SingingVoices, type SingingVoicesOptions, type StreamPlaybackOptions, type StreamVoiceNote, type StreamVoiceTrack, type Synth, TRACKS_ADVANCED, TRACKS_SIMPLE, type ToolMode, type TrackConfig, VIBRATO_MIN_SEC, VOICE_IMAGES, VOICE_IMAGE_KEY, type VoiceExpression, type VoiceModel, type VoiceRegistry, analyzeMidiTracks, applyHarmonicFilter, applyMonophonic, buildChordPlacements, buildDrumPatternJson, buildNameToKeyMapping, collectPitchTokens, concatFloat32, createAudioContext, createDtmStudio, createKlattVoice, createKoeVoice, createLyricsConductor, createPianoRoll, createSequencer, createSingingVoices, createSynth, createVoiceRegistry, decodeMml, decomposeToMonophonic, drawGrid, drawHeader, drawKeyboard, drawNotes, drawSelectedNotes, drawSelectionRect, encodeMml, encodeWavPCM16, exportMIDI, extractDrumPatternFromNotes, extractMidiDrumPattern, extractMidiPlacements, extractMidiPlacementsByTrack, formatMmlMeta, freqFromPitch, generateRandomPattern, getDrawOffset, getDrumPatternKeys, getGridCanvas, getGridContext, getGridPosition, getHeaderCanvas, getMidiBPM, getRenderConfig, getXY, icon, init, injectStyles, isChordHeavyTrack, isPlausibleMidiTranscription, isValidHttpUrl, koeUrl, mountChordPlayer, mountDAW, mountMmlPlayer, normalizeDrumPatterns, normalizeLyrics, onClick, panToStereo, parseCustomVocals, parseLyrics, parseMML, parseMmlMeta, playChords, playMML, playNote, playPlacements, playSingingMML, resolveDrumPattern, resolveLoopPoint, setBackgroundActive, setDrawOffset, shiftNotes, showLoadingOverlay, stripCustomVocals, stripLyrics, stripMmlMeta, transposeNotes, vocalVolumeToGain };
2486
+ export { type AddNoteOptions, type AnyDrumPattern, type ApplyChordOptions, type ChordPatternType, type ChordPlacement, type ChordPlayerInstance, type ConsumedSyllable, type CoreEventHandlers, type CustomVocalDef, DAW_CSS, DEFAULT_BPM, DEFAULT_GATE, DEFAULT_PAN, DEFAULT_PLAYBACK_VELOCITY, DEFAULT_STEPS_PER_BAR, DEFAULT_VELOCITY, DEFAULT_VOCAL_VOLUME, DRUM_FONT, DRUM_KEYS, DRUM_PATTERNS, type DawInstance, type DawMode, type DawOptions, type DawViewState, type DrumPattern, type DrumPatternDef, type DtmStudio, type DtmStudioEngines, type DtmStudioOptions, type ExportMidiOptions, type FadeScheduleParams, GM_INSTRUMENT_NAMES, INSTRUMENT_PRESETS, type InstrumentPreset, KOE_BASE_URL, KOE_VOICEBANKS, KOE_VOICEBANK_LABELS, KOE_VOICEBANK_TERMS, type KoeVoiceOptions, LinkedList, type LoopConfig, type LoopPoint, type LyricSyllable, type LyricSyncData, type LyricTrack, type LyricsConductor, MAX_VOCAL_VOLUME, MMLCore, type MMLDisplayToken, type MMLNotePlacement, MML_END_MARKER, type MidiExtraction, type MidiNotePlacement, MidiSearchClient, type MidiSearchConfig, type MidiTrackAnalysis, type MmlMeta, type MmlPlayback, type MmlPlayerInstance, type MmlPlayerOptions, type ModeSwitchInstance, type ModeSwitchOptions, type MountChordPlayerOptions, type MountEditorOptions, type MountPlayerOptions, type Note, type NoteData, type NoteRemove, type OctaveUnisonMode, PITCH_MAP, PREWARM_NOTES, type ParseMMLOptions, type ParseMidiFn, type ParsedMML, type PianoRollInstance, type PianoRollOptions, type PicotuneSearchParams, type PicotuneSong, type PitchToken, type PlayChordsOptions, type PlayDrumEvent, type PlayMmlOptions, type PlayNoteEvent, type PlayNoteOptions, type PlayPlacementsOptions, type PlaySingingMmlOptions, type PlaybackCue, type PlaybackState, type PresetSelectInstance, type PresetSelectOptions, type PreviewSoundCallback, type RenderConfig, type Sequencer, type SequencerOptions, type SequencerTrack, type SingingVoices, type SingingVoicesOptions, type StreamPlaybackOptions, type StreamVoiceNote, type StreamVoiceTrack, type Synth, TRACKS_ADVANCED, TRACKS_SIMPLE, type ToolMode, type TrackConfig, VIBRATO_MIN_SEC, VOICE_IMAGES, VOICE_IMAGE_KEY, type VoiceExpression, type VoiceModel, type VoiceRegistry, analyzeMidiTracks, applyHarmonicFilter, applyMonophonic, buildChordPlacements, buildDrumPatternJson, buildNameToKeyMapping, collectPitchTokens, concatFloat32, createAudioContext, createDtmStudio, createKlattVoice, createKoeVoice, createLyricsConductor, createPianoRoll, createSequencer, createSingingVoices, createSynth, createVoiceRegistry, decodeMml, decomposeToMonophonic, drawGrid, drawHeader, drawKeyboard, drawNoteLyrics, drawNotes, drawSelectedNotes, drawSelectionRect, encodeMml, encodeWavPCM16, exportMIDI, extractDrumPatternFromNotes, extractMidiDrumPattern, extractMidiPlacements, extractMidiPlacementsByTrack, formatMmlMeta, freqFromPitch, generateRandomPattern, getDrawOffset, getDrumPatternKeys, getGridCanvas, getGridContext, getGridPosition, getHeaderCanvas, getMidiBPM, getRenderConfig, getXY, icon, init, injectStyles, isChordHeavyTrack, isPlausibleMidiTranscription, isValidHttpUrl, koeUrl, mountChordPlayer, mountDAW, mountMmlPlayer, normalizeDrumPatterns, normalizeLyrics, onClick, panToStereo, parseCustomVocals, parseLyrics, parseMML, parseMmlMeta, playChords, playMML, playNote, playPlacements, playSingingMML, resolveDrumPattern, resolveLoopPoint, setBackgroundActive, setDrawOffset, shiftNotes, showLoadingOverlay, stripCustomVocals, stripLyrics, stripMmlMeta, transposeNotes, vocalVolumeToGain };
package/dist/index.d.ts CHANGED
@@ -1996,6 +1996,16 @@ declare const drawGrid: (noteLengthSteps?: number) => void;
1996
1996
  * 指定されたノートの配列を描画します。
1997
1997
  */
1998
1998
  declare const drawNotes: (notes: Note[], color?: number[]) => void;
1999
+ /**
2000
+ * ノートの上に歌詞(かな)を重ねて描画します。
2001
+ *
2002
+ * 音節の割り当ては発音側(StreamVoiceTrack の組み立て)と同じ規則で、
2003
+ * startStep 昇順に並べたノートの i 番目へ syllables[i] を対応させます。
2004
+ * 音節が足りないぶんのノートには何も描きません。
2005
+ *
2006
+ * 文字はノート矩形でクリップするため、隣のノートへはみ出しません。
2007
+ */
2008
+ declare const drawNoteLyrics: (notes: Note[], syllables: string[]) => void;
1999
2009
  /**
2000
2010
  * 選択範囲の四角形を描画します。
2001
2011
  */
@@ -2473,4 +2483,4 @@ declare const encodeWavPCM16: (channels: Float32Array[], sampleRate: number) =>
2473
2483
  /** Float32Array のチャンクを1本へ連結する。 */
2474
2484
  declare const concatFloat32: (chunks: Float32Array[]) => Float32Array;
2475
2485
 
2476
- export { type AddNoteOptions, type AnyDrumPattern, type ApplyChordOptions, type ChordPatternType, type ChordPlacement, type ChordPlayerInstance, type ConsumedSyllable, type CoreEventHandlers, type CustomVocalDef, DAW_CSS, DEFAULT_BPM, DEFAULT_GATE, DEFAULT_PAN, DEFAULT_PLAYBACK_VELOCITY, DEFAULT_STEPS_PER_BAR, DEFAULT_VELOCITY, DEFAULT_VOCAL_VOLUME, DRUM_FONT, DRUM_KEYS, DRUM_PATTERNS, type DawInstance, type DawMode, type DawOptions, type DawViewState, type DrumPattern, type DrumPatternDef, type DtmStudio, type DtmStudioEngines, type DtmStudioOptions, type ExportMidiOptions, type FadeScheduleParams, GM_INSTRUMENT_NAMES, INSTRUMENT_PRESETS, type InstrumentPreset, KOE_BASE_URL, KOE_VOICEBANKS, KOE_VOICEBANK_LABELS, KOE_VOICEBANK_TERMS, type KoeVoiceOptions, LinkedList, type LoopConfig, type LoopPoint, type LyricSyllable, type LyricSyncData, type LyricTrack, type LyricsConductor, MAX_VOCAL_VOLUME, MMLCore, type MMLDisplayToken, type MMLNotePlacement, MML_END_MARKER, type MidiExtraction, type MidiNotePlacement, MidiSearchClient, type MidiSearchConfig, type MidiTrackAnalysis, type MmlMeta, type MmlPlayback, type MmlPlayerInstance, type MmlPlayerOptions, type ModeSwitchInstance, type ModeSwitchOptions, type MountChordPlayerOptions, type MountEditorOptions, type MountPlayerOptions, type Note, type NoteData, type NoteRemove, type OctaveUnisonMode, PITCH_MAP, PREWARM_NOTES, type ParseMMLOptions, type ParseMidiFn, type ParsedMML, type PianoRollInstance, type PianoRollOptions, type PicotuneSearchParams, type PicotuneSong, type PitchToken, type PlayChordsOptions, type PlayDrumEvent, type PlayMmlOptions, type PlayNoteEvent, type PlayNoteOptions, type PlayPlacementsOptions, type PlaySingingMmlOptions, type PlaybackCue, type PlaybackState, type PresetSelectInstance, type PresetSelectOptions, type PreviewSoundCallback, type RenderConfig, type Sequencer, type SequencerOptions, type SequencerTrack, type SingingVoices, type SingingVoicesOptions, type StreamPlaybackOptions, type StreamVoiceNote, type StreamVoiceTrack, type Synth, TRACKS_ADVANCED, TRACKS_SIMPLE, type ToolMode, type TrackConfig, VIBRATO_MIN_SEC, VOICE_IMAGES, VOICE_IMAGE_KEY, type VoiceExpression, type VoiceModel, type VoiceRegistry, analyzeMidiTracks, applyHarmonicFilter, applyMonophonic, buildChordPlacements, buildDrumPatternJson, buildNameToKeyMapping, collectPitchTokens, concatFloat32, createAudioContext, createDtmStudio, createKlattVoice, createKoeVoice, createLyricsConductor, createPianoRoll, createSequencer, createSingingVoices, createSynth, createVoiceRegistry, decodeMml, decomposeToMonophonic, drawGrid, drawHeader, drawKeyboard, drawNotes, drawSelectedNotes, drawSelectionRect, encodeMml, encodeWavPCM16, exportMIDI, extractDrumPatternFromNotes, extractMidiDrumPattern, extractMidiPlacements, extractMidiPlacementsByTrack, formatMmlMeta, freqFromPitch, generateRandomPattern, getDrawOffset, getDrumPatternKeys, getGridCanvas, getGridContext, getGridPosition, getHeaderCanvas, getMidiBPM, getRenderConfig, getXY, icon, init, injectStyles, isChordHeavyTrack, isPlausibleMidiTranscription, isValidHttpUrl, koeUrl, mountChordPlayer, mountDAW, mountMmlPlayer, normalizeDrumPatterns, normalizeLyrics, onClick, panToStereo, parseCustomVocals, parseLyrics, parseMML, parseMmlMeta, playChords, playMML, playNote, playPlacements, playSingingMML, resolveDrumPattern, resolveLoopPoint, setBackgroundActive, setDrawOffset, shiftNotes, showLoadingOverlay, stripCustomVocals, stripLyrics, stripMmlMeta, transposeNotes, vocalVolumeToGain };
2486
+ export { type AddNoteOptions, type AnyDrumPattern, type ApplyChordOptions, type ChordPatternType, type ChordPlacement, type ChordPlayerInstance, type ConsumedSyllable, type CoreEventHandlers, type CustomVocalDef, DAW_CSS, DEFAULT_BPM, DEFAULT_GATE, DEFAULT_PAN, DEFAULT_PLAYBACK_VELOCITY, DEFAULT_STEPS_PER_BAR, DEFAULT_VELOCITY, DEFAULT_VOCAL_VOLUME, DRUM_FONT, DRUM_KEYS, DRUM_PATTERNS, type DawInstance, type DawMode, type DawOptions, type DawViewState, type DrumPattern, type DrumPatternDef, type DtmStudio, type DtmStudioEngines, type DtmStudioOptions, type ExportMidiOptions, type FadeScheduleParams, GM_INSTRUMENT_NAMES, INSTRUMENT_PRESETS, type InstrumentPreset, KOE_BASE_URL, KOE_VOICEBANKS, KOE_VOICEBANK_LABELS, KOE_VOICEBANK_TERMS, type KoeVoiceOptions, LinkedList, type LoopConfig, type LoopPoint, type LyricSyllable, type LyricSyncData, type LyricTrack, type LyricsConductor, MAX_VOCAL_VOLUME, MMLCore, type MMLDisplayToken, type MMLNotePlacement, MML_END_MARKER, type MidiExtraction, type MidiNotePlacement, MidiSearchClient, type MidiSearchConfig, type MidiTrackAnalysis, type MmlMeta, type MmlPlayback, type MmlPlayerInstance, type MmlPlayerOptions, type ModeSwitchInstance, type ModeSwitchOptions, type MountChordPlayerOptions, type MountEditorOptions, type MountPlayerOptions, type Note, type NoteData, type NoteRemove, type OctaveUnisonMode, PITCH_MAP, PREWARM_NOTES, type ParseMMLOptions, type ParseMidiFn, type ParsedMML, type PianoRollInstance, type PianoRollOptions, type PicotuneSearchParams, type PicotuneSong, type PitchToken, type PlayChordsOptions, type PlayDrumEvent, type PlayMmlOptions, type PlayNoteEvent, type PlayNoteOptions, type PlayPlacementsOptions, type PlaySingingMmlOptions, type PlaybackCue, type PlaybackState, type PresetSelectInstance, type PresetSelectOptions, type PreviewSoundCallback, type RenderConfig, type Sequencer, type SequencerOptions, type SequencerTrack, type SingingVoices, type SingingVoicesOptions, type StreamPlaybackOptions, type StreamVoiceNote, type StreamVoiceTrack, type Synth, TRACKS_ADVANCED, TRACKS_SIMPLE, type ToolMode, type TrackConfig, VIBRATO_MIN_SEC, VOICE_IMAGES, VOICE_IMAGE_KEY, type VoiceExpression, type VoiceModel, type VoiceRegistry, analyzeMidiTracks, applyHarmonicFilter, applyMonophonic, buildChordPlacements, buildDrumPatternJson, buildNameToKeyMapping, collectPitchTokens, concatFloat32, createAudioContext, createDtmStudio, createKlattVoice, createKoeVoice, createLyricsConductor, createPianoRoll, createSequencer, createSingingVoices, createSynth, createVoiceRegistry, decodeMml, decomposeToMonophonic, drawGrid, drawHeader, drawKeyboard, drawNoteLyrics, drawNotes, drawSelectedNotes, drawSelectionRect, encodeMml, encodeWavPCM16, exportMIDI, extractDrumPatternFromNotes, extractMidiDrumPattern, extractMidiPlacements, extractMidiPlacementsByTrack, formatMmlMeta, freqFromPitch, generateRandomPattern, getDrawOffset, getDrumPatternKeys, getGridCanvas, getGridContext, getGridPosition, getHeaderCanvas, getMidiBPM, getRenderConfig, getXY, icon, init, injectStyles, isChordHeavyTrack, isPlausibleMidiTranscription, isValidHttpUrl, koeUrl, mountChordPlayer, mountDAW, mountMmlPlayer, normalizeDrumPatterns, normalizeLyrics, onClick, panToStereo, parseCustomVocals, parseLyrics, parseMML, parseMmlMeta, playChords, playMML, playNote, playPlacements, playSingingMML, resolveDrumPattern, resolveLoopPoint, setBackgroundActive, setDrawOffset, shiftNotes, showLoadingOverlay, stripCustomVocals, stripLyrics, stripMmlMeta, transposeNotes, vocalVolumeToGain };
package/dist/index.js CHANGED
@@ -72,6 +72,7 @@ __export(index_exports, {
72
72
  drawGrid: () => drawGrid,
73
73
  drawHeader: () => drawHeader,
74
74
  drawKeyboard: () => drawKeyboard,
75
+ drawNoteLyrics: () => drawNoteLyrics,
75
76
  drawNotes: () => drawNotes,
76
77
  drawSelectedNotes: () => drawSelectedNotes,
77
78
  drawSelectionRect: () => drawSelectionRect,
@@ -13140,6 +13141,43 @@ var drawNotes = (notes, color = [59, 130, 246, 1]) => {
13140
13141
  g_grid_ctx.fillRect(renderX + 1, renderY + 1, w - 2, h - 2);
13141
13142
  }
13142
13143
  };
13144
+ var drawNoteLyrics = (notes, syllables) => {
13145
+ if (syllables.length === 0) return;
13146
+ const { keyHeight, stepWidth, keyCount, pitchRangeStart } = g_config;
13147
+ if (keyHeight < 10) return;
13148
+ const fontSize = Math.min(12, Math.floor(keyHeight * 0.85));
13149
+ const sorted = [...notes].sort((a, b) => a.startStep - b.startStep);
13150
+ const count = Math.min(sorted.length, syllables.length);
13151
+ g_grid_ctx.save();
13152
+ g_grid_ctx.font = `${fontSize}px 'k8x12',sans-serif`;
13153
+ g_grid_ctx.textAlign = "left";
13154
+ g_grid_ctx.textBaseline = "middle";
13155
+ g_grid_ctx.lineWidth = 3;
13156
+ g_grid_ctx.lineJoin = "round";
13157
+ for (let i2 = 0; i2 < count; i2++) {
13158
+ const kana = syllables[i2];
13159
+ if (!kana) continue;
13160
+ const note = sorted[i2];
13161
+ const renderX = note.startStep * stepWidth - g_draw_offset_x;
13162
+ const renderY = (keyCount - 1 - (note.pitch - pitchRangeStart)) * keyHeight - g_draw_offset_y;
13163
+ const w = note.durationSteps * stepWidth;
13164
+ if (w < 6) continue;
13165
+ if (renderX + w < 0 || renderX > g_grid_canvas.width) continue;
13166
+ if (renderY + keyHeight < 0 || renderY > g_grid_canvas.height) continue;
13167
+ const textX = renderX + 2;
13168
+ const textY = renderY + keyHeight / 2;
13169
+ g_grid_ctx.save();
13170
+ g_grid_ctx.beginPath();
13171
+ g_grid_ctx.rect(renderX + 1, renderY + 1, w - 2, keyHeight - 2);
13172
+ g_grid_ctx.clip();
13173
+ g_grid_ctx.strokeStyle = "rgba(0,0,0,0.85)";
13174
+ g_grid_ctx.strokeText(kana, textX, textY);
13175
+ g_grid_ctx.fillStyle = "#fff1e8";
13176
+ g_grid_ctx.fillText(kana, textX, textY);
13177
+ g_grid_ctx.restore();
13178
+ }
13179
+ g_grid_ctx.restore();
13180
+ };
13143
13181
  var drawSelectionRect = (rect) => {
13144
13182
  if (!rect) return;
13145
13183
  g_grid_ctx.save();
@@ -14491,6 +14529,19 @@ var mountDAW = (target, options = {}) => {
14491
14529
  return map;
14492
14530
  };
14493
14531
  const getActive = () => trackStates.find((t) => t.config.id === activeTrackId) ?? trackStates[0];
14532
+ let lyricKanaCacheText = "";
14533
+ let lyricKanaCache = [];
14534
+ const getActiveLyricKana = () => {
14535
+ const t = getActive();
14536
+ if (!t?.lyricModel.trim()) return [];
14537
+ const text = t.lyrics.trim();
14538
+ if (!text) return [];
14539
+ if (text !== lyricKanaCacheText) {
14540
+ lyricKanaCacheText = text;
14541
+ lyricKanaCache = normalizeLyrics(text).map((sy) => sy.kana);
14542
+ }
14543
+ return lyricKanaCache;
14544
+ };
14494
14545
  let showModal;
14495
14546
  const getSongEndStepExact = () => {
14496
14547
  let maxEndStep = 0;
@@ -14555,12 +14606,16 @@ var mountDAW = (target, options = {}) => {
14555
14606
  };
14556
14607
  const redrawAll = () => {
14557
14608
  drawGrid(gridLineSteps);
14609
+ let lyricTargetNotes = null;
14558
14610
  for (const t of trackStates) {
14559
14611
  if (hiddenTracks.has(t.config.id)) continue;
14560
14612
  if (isSolo && t.config.id !== activeTrackId) continue;
14561
14613
  const [r, g, b] = t.config.color;
14562
- const a = t.config.id === activeTrackId ? 1 : 0.3;
14563
- drawNotes(t.core.getNotes(), [r, g, b, a]);
14614
+ const isActive = t.config.id === activeTrackId;
14615
+ const a = isActive ? 1 : 0.3;
14616
+ const notes = t.core.getNotes();
14617
+ drawNotes(notes, [r, g, b, a]);
14618
+ if (isActive) lyricTargetNotes = notes;
14564
14619
  }
14565
14620
  if (activeToolMode === "select" && selectionRect) {
14566
14621
  const ctx = getGridContext();
@@ -14591,6 +14646,8 @@ var mountDAW = (target, options = {}) => {
14591
14646
  1
14592
14647
  ]);
14593
14648
  }
14649
+ if (lyricTargetNotes)
14650
+ drawNoteLyrics(lyricTargetNotes, getActiveLyricKana());
14594
14651
  drawStartLine();
14595
14652
  if (playbackState === "playing") drawPlayhead();
14596
14653
  updateScrollbars();
@@ -16057,6 +16114,7 @@ var mountDAW = (target, options = {}) => {
16057
16114
  syncLyricVisibility();
16058
16115
  syncInstDisabled();
16059
16116
  syncVelocityDisabled();
16117
+ redrawAll();
16060
16118
  fireLyricsChange(active);
16061
16119
  reloadVoicesForModel(active.lyricModel);
16062
16120
  });
@@ -16098,6 +16156,7 @@ var mountDAW = (target, options = {}) => {
16098
16156
  label: existing?.label
16099
16157
  });
16100
16158
  active.lyricModel = key;
16159
+ redrawAll();
16101
16160
  fireLyricsChange(active);
16102
16161
  updateTrackPanel();
16103
16162
  reloadVoicesForModel(key);
@@ -16117,6 +16176,7 @@ var mountDAW = (target, options = {}) => {
16117
16176
  lyricInput.addEventListener("input", () => {
16118
16177
  active.lyrics = lyricInput.value;
16119
16178
  updateLyricCount();
16179
+ redrawAll();
16120
16180
  fireLyricsChange(active);
16121
16181
  });
16122
16182
  lyricVol.addEventListener("input", () => {
@@ -18268,6 +18328,7 @@ var mountDAW = (target, options = {}) => {
18268
18328
  t.vocalBreathiness = data.vocalBreathiness ?? 50;
18269
18329
  t.vocalTension = data.vocalTension ?? 50;
18270
18330
  t.vocalOctaveUnison = data.vocalOctaveUnison ?? "none";
18331
+ if (t.config.id === activeTrackId) redrawAll();
18271
18332
  },
18272
18333
  applyTrackInstrument: (trackIndex, instrumentName) => {
18273
18334
  const t = trackStates[trackIndex];
@@ -20457,6 +20518,7 @@ var createDtmStudio = async (options = {}) => {
20457
20518
  drawGrid,
20458
20519
  drawHeader,
20459
20520
  drawKeyboard,
20521
+ drawNoteLyrics,
20460
20522
  drawNotes,
20461
20523
  drawSelectedNotes,
20462
20524
  drawSelectionRect,
package/dist/index.mjs CHANGED
@@ -13007,6 +13007,43 @@ var drawNotes = (notes, color = [59, 130, 246, 1]) => {
13007
13007
  g_grid_ctx.fillRect(renderX + 1, renderY + 1, w - 2, h - 2);
13008
13008
  }
13009
13009
  };
13010
+ var drawNoteLyrics = (notes, syllables) => {
13011
+ if (syllables.length === 0) return;
13012
+ const { keyHeight, stepWidth, keyCount, pitchRangeStart } = g_config;
13013
+ if (keyHeight < 10) return;
13014
+ const fontSize = Math.min(12, Math.floor(keyHeight * 0.85));
13015
+ const sorted = [...notes].sort((a, b) => a.startStep - b.startStep);
13016
+ const count = Math.min(sorted.length, syllables.length);
13017
+ g_grid_ctx.save();
13018
+ g_grid_ctx.font = `${fontSize}px 'k8x12',sans-serif`;
13019
+ g_grid_ctx.textAlign = "left";
13020
+ g_grid_ctx.textBaseline = "middle";
13021
+ g_grid_ctx.lineWidth = 3;
13022
+ g_grid_ctx.lineJoin = "round";
13023
+ for (let i2 = 0; i2 < count; i2++) {
13024
+ const kana = syllables[i2];
13025
+ if (!kana) continue;
13026
+ const note = sorted[i2];
13027
+ const renderX = note.startStep * stepWidth - g_draw_offset_x;
13028
+ const renderY = (keyCount - 1 - (note.pitch - pitchRangeStart)) * keyHeight - g_draw_offset_y;
13029
+ const w = note.durationSteps * stepWidth;
13030
+ if (w < 6) continue;
13031
+ if (renderX + w < 0 || renderX > g_grid_canvas.width) continue;
13032
+ if (renderY + keyHeight < 0 || renderY > g_grid_canvas.height) continue;
13033
+ const textX = renderX + 2;
13034
+ const textY = renderY + keyHeight / 2;
13035
+ g_grid_ctx.save();
13036
+ g_grid_ctx.beginPath();
13037
+ g_grid_ctx.rect(renderX + 1, renderY + 1, w - 2, keyHeight - 2);
13038
+ g_grid_ctx.clip();
13039
+ g_grid_ctx.strokeStyle = "rgba(0,0,0,0.85)";
13040
+ g_grid_ctx.strokeText(kana, textX, textY);
13041
+ g_grid_ctx.fillStyle = "#fff1e8";
13042
+ g_grid_ctx.fillText(kana, textX, textY);
13043
+ g_grid_ctx.restore();
13044
+ }
13045
+ g_grid_ctx.restore();
13046
+ };
13010
13047
  var drawSelectionRect = (rect) => {
13011
13048
  if (!rect) return;
13012
13049
  g_grid_ctx.save();
@@ -14358,6 +14395,19 @@ var mountDAW = (target, options = {}) => {
14358
14395
  return map;
14359
14396
  };
14360
14397
  const getActive = () => trackStates.find((t) => t.config.id === activeTrackId) ?? trackStates[0];
14398
+ let lyricKanaCacheText = "";
14399
+ let lyricKanaCache = [];
14400
+ const getActiveLyricKana = () => {
14401
+ const t = getActive();
14402
+ if (!t?.lyricModel.trim()) return [];
14403
+ const text = t.lyrics.trim();
14404
+ if (!text) return [];
14405
+ if (text !== lyricKanaCacheText) {
14406
+ lyricKanaCacheText = text;
14407
+ lyricKanaCache = normalizeLyrics(text).map((sy) => sy.kana);
14408
+ }
14409
+ return lyricKanaCache;
14410
+ };
14361
14411
  let showModal;
14362
14412
  const getSongEndStepExact = () => {
14363
14413
  let maxEndStep = 0;
@@ -14422,12 +14472,16 @@ var mountDAW = (target, options = {}) => {
14422
14472
  };
14423
14473
  const redrawAll = () => {
14424
14474
  drawGrid(gridLineSteps);
14475
+ let lyricTargetNotes = null;
14425
14476
  for (const t of trackStates) {
14426
14477
  if (hiddenTracks.has(t.config.id)) continue;
14427
14478
  if (isSolo && t.config.id !== activeTrackId) continue;
14428
14479
  const [r, g, b] = t.config.color;
14429
- const a = t.config.id === activeTrackId ? 1 : 0.3;
14430
- drawNotes(t.core.getNotes(), [r, g, b, a]);
14480
+ const isActive = t.config.id === activeTrackId;
14481
+ const a = isActive ? 1 : 0.3;
14482
+ const notes = t.core.getNotes();
14483
+ drawNotes(notes, [r, g, b, a]);
14484
+ if (isActive) lyricTargetNotes = notes;
14431
14485
  }
14432
14486
  if (activeToolMode === "select" && selectionRect) {
14433
14487
  const ctx = getGridContext();
@@ -14458,6 +14512,8 @@ var mountDAW = (target, options = {}) => {
14458
14512
  1
14459
14513
  ]);
14460
14514
  }
14515
+ if (lyricTargetNotes)
14516
+ drawNoteLyrics(lyricTargetNotes, getActiveLyricKana());
14461
14517
  drawStartLine();
14462
14518
  if (playbackState === "playing") drawPlayhead();
14463
14519
  updateScrollbars();
@@ -15924,6 +15980,7 @@ var mountDAW = (target, options = {}) => {
15924
15980
  syncLyricVisibility();
15925
15981
  syncInstDisabled();
15926
15982
  syncVelocityDisabled();
15983
+ redrawAll();
15927
15984
  fireLyricsChange(active);
15928
15985
  reloadVoicesForModel(active.lyricModel);
15929
15986
  });
@@ -15965,6 +16022,7 @@ var mountDAW = (target, options = {}) => {
15965
16022
  label: existing?.label
15966
16023
  });
15967
16024
  active.lyricModel = key;
16025
+ redrawAll();
15968
16026
  fireLyricsChange(active);
15969
16027
  updateTrackPanel();
15970
16028
  reloadVoicesForModel(key);
@@ -15984,6 +16042,7 @@ var mountDAW = (target, options = {}) => {
15984
16042
  lyricInput.addEventListener("input", () => {
15985
16043
  active.lyrics = lyricInput.value;
15986
16044
  updateLyricCount();
16045
+ redrawAll();
15987
16046
  fireLyricsChange(active);
15988
16047
  });
15989
16048
  lyricVol.addEventListener("input", () => {
@@ -18135,6 +18194,7 @@ var mountDAW = (target, options = {}) => {
18135
18194
  t.vocalBreathiness = data.vocalBreathiness ?? 50;
18136
18195
  t.vocalTension = data.vocalTension ?? 50;
18137
18196
  t.vocalOctaveUnison = data.vocalOctaveUnison ?? "none";
18197
+ if (t.config.id === activeTrackId) redrawAll();
18138
18198
  },
18139
18199
  applyTrackInstrument: (trackIndex, instrumentName) => {
18140
18200
  const t = trackStates[trackIndex];
@@ -20322,6 +20382,7 @@ export {
20322
20382
  drawGrid,
20323
20383
  drawHeader,
20324
20384
  drawKeyboard,
20385
+ drawNoteLyrics,
20325
20386
  drawNotes,
20326
20387
  drawSelectedNotes,
20327
20388
  drawSelectionRect,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "onjmin",
3
3
  "license": "MIT",
4
4
  "name": "@onjmin/dtm",
5
- "version": "1.0.6",
5
+ "version": "1.0.7",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {