Skip to content

Tuplet formatting issuesΒ #1654

@Skinz3

Description

@Skinz3

Hello ! Im formatting 2 voices , together, as mentioned in the FAQ.

` const formatter = new Formatter();
formatter.joinVoices([this.measure1.voice, this.measure2.voice]);

var justifyWidth = GrandStaff.MIN_STAFF_WIDTH;

var staveWidth = GrandStaff.MIN_STAFF_WIDTH;

var modifierX = Math.max(
  this.measure1.stave.getModifierXShift(),
  this.measure2.stave.getModifierXShift()
);

var offset = 20;

justifyWidth -= modifierX + offset;

try {
  formatter.format(
    [this.measure1.voice, this.measure2.voice],
    justifyWidth, { align_rests: false, }
  );
} catch {
  console.log(this.barId + "error");
}`

Here is my code to draw the tuplet :

`buildTriplets(context: RenderContext) {
[this.measure1, this.measure2].forEach((measure) => {
const notes = measure.voice.getTickables() as Note[];
const ivoryNotes = measure.ivoryMesure.notes;
let currentGroup: Note[] = [];

  for (let i = 0; i < ivoryNotes.length; i++) {
    const ivoryNote = ivoryNotes[i];
    if (ivoryNote.modifiers.includes(StaveNoteModifier.Triplet)) {
      currentGroup.push(notes[i]);

      if (currentGroup.length === 3) {
        const tp = new Tuplet(currentGroup, {
          bracketed: true,
          num_notes: 3,
          notes_occupied: 2,
          ratioed: false,
        });

        console.log(tp.getBeatsOccupied())


        measure.tuplets.push(tp);

        tp.attach();
        tp.setContext(context);
        currentGroup = [];
      }
    }
  }
});


console.log("Tuplets created for both staves." + this.measure1.tuplets.length);

}`

But for some reason i got this error πŸ‘πŸΌ

Image

The getTickUsed() overflow getTotalTicks(). Its like Vexflow is not taking in consideration the triole, and keep on relying as '8' for every notes durations.

I got '[RuntimeError] BadArgument: Too many ticks.' If i set voice mode to strict.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions