cuthbertLab / music21j

Javascript port of music21 -- Toolkit for Computational Musicology
Other
147 stars 43 forks source link

Prevent getBeams() from creating single stop beam #232

Closed vanderstel closed 1 year ago

vanderstel commented 1 year ago

We have a very specific situation where TimeSignature.getBeams() can product a single 'stop' beam at the final note and no others. This happens when the penultimate note in a measure:

  1. is beamable
  2. is held across a beat
  3. is preceded by a non-beamable note
  4. is followed by a beamable note

This PR updates getBeams() to acccount for this case, and Renderer.formatVoiceGroup() to ensure that errors like this do not happen again.


Screen Shot 2023-10-16 at 6 23 05 AM
const s = new music21.stream.Measure();
s.autoBeam = true;
s.renderOptions.useVexflowAutobeam = false;
s.append(new music21.meter.TimeSignature('3/4'));
for (const ql of [0.5, 1.0, 0.75, 0.75]) {
    const n = new music21.note.Note('C#', ql);
    s.append(n);
}
s.replaceDOM();