Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuplet formatting issues #1654

Open
Skinz3 opened this issue Mar 8, 2025 · 0 comments
Open

Tuplet formatting issues #1654

Skinz3 opened this issue Mar 8, 2025 · 0 comments

Comments

@Skinz3
Copy link

Skinz3 commented Mar 8, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant