Skip to content

Commit

Permalink
fix: type issue in one of the files
Browse files Browse the repository at this point in the history
  • Loading branch information
VehpuS committed Apr 19, 2024
1 parent f482201 commit d8a78e1
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions musicxml-singer-with-oddvoices/src/oddVoiceJSON/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,25 +588,32 @@ export const musicXMLToEvents = (
}
});

// Chords with no lyrics should have the previous lyrics added to them
if (!newLyricText && currChordLvl > 1) {
// Find the last lyric event for this part and voice with a lower chord level
const lastLyricEvent = findLast(
lyricsEvents,
(e) => e.partIdx === partIdx && e.voice === currentVoice
(e) =>
e.partIdx === partIdx &&
e.voice === currentVoice &&
e.time === timeElapsedForPartAndVoice
);
if (lastLyricEvent) {
const newLyricEvent = cloneDeep(lastLyricEvent);
continuesPreviousLyric = Boolean(newLyricEvent.continuesPrevious);
newLyricText = `${continuesPreviousLyric ? "" : " "}${newLyricEvent.lyric ?? ""}`;
newLyricEvent.chordLevel = currChordLvl;
console.log("Adding previous lyric", {
measureChild,
newLyricText,
partChordLyrics: partChordLyricsTexts[`${partIdx}_${currChordLvl}`],
lastLyricEvent,
newLyricEvent,
});
lyricsEvents.push(newLyricEvent);
// Only add this event if it doesn't exist yet
if (!find(lyricsEvents, newLyricEvent)) {
continuesPreviousLyric = Boolean(newLyricEvent.continuesPrevious);
newLyricText = `${continuesPreviousLyric ? "" : " "}${newLyricEvent.lyric ?? ""}`;
console.log("Adding previous lyric", {
measureChild,
newLyricText,
partChordLyrics: partChordLyricsTexts[`${partIdx}_${currChordLvl}`],
lastLyricEvent,
newLyricEvent,
});
lyricsEvents.push(newLyricEvent);
}
}
}

Expand Down

0 comments on commit d8a78e1

Please sign in to comment.