From a46f5e7e948790de29512825cfafb7e78698a3eb Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 21 Jun 2024 14:41:58 -1000 Subject: [PATCH] Augmented Second Chord Stems Temporarily work around a Vexflow bug where chords with augmented seconds and stems down do not draw properly. --- src/stream/makeNotation.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/stream/makeNotation.ts b/src/stream/makeNotation.ts index 35a229bf..35281e7e 100644 --- a/src/stream/makeNotation.ts +++ b/src/stream/makeNotation.ts @@ -183,6 +183,18 @@ export function setStemDirectionForUnspecified( } for (const n of s.rc(note.NotRest)) { + if (n.pitches.length > 1) { + const pitchSet = new Set(n.pitches.map(p => p.diatonicNoteNum)); + if (pitchSet.size < n.pitches.length) { + // bug in Vexflow v4 at least -- chords with augmented seconds + // and down stems do no render properly. + // set their stems to 'unspecified' which Vexflow will currently + // render as upstems. + n.stemDirection = 'unspecified'; + continue; + } + } + if (n.stemDirection !== 'unspecified') { continue; } @@ -202,6 +214,9 @@ export function setStemDirectionForUnspecified( const _up_down: readonly string[] = ['up', 'down']; const _up_down_unspecified: readonly string[] = ['up', 'down', 'unspecified']; +/** + * Set stem directions for all notes in a beam group. + */ export function setStemDirectionOneGroup( group: note.NotRest[], {