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

VexFlow dotted notes not playing properly #137

Open
sfox-developer opened this issue Aug 14, 2024 · 0 comments
Open

VexFlow dotted notes not playing properly #137

sfox-developer opened this issue Aug 14, 2024 · 0 comments

Comments

@sfox-developer
Copy link

Hey there,

thanks for the great lib and the integration with Vexflow.

I faced an issue that my track is not playing dotted notes. So i checked the code and found an issue with the conversion from vexflow to the NoteEvent. I checked the vexflow documentation as well as the midiwriter code. I found the method VexFlow.prototype.convertDuration which is checking for the VexFlow duration and additional modifications like tuplets or dots.

VexFlow.prototype.convertDuration = function (note) {
  return 'd'.repeat(note.dots) + this.convertBaseDuration(note.duration) + (note.tuplet ? 't' + note.tuplet.num_notes : '');
};

The passed note is a Tickable or StaveNote - but i did not find any property for "dots", so overrode the method by checking for the modifiers instead.

/**
 * MidiWriter FIX: note.dots does not exist, so we are checking the modifiers
 */
MidiWriter.VexFlow.prototype.convertDuration = function (note) {
    
    let durationString = "";

    if(note.modifiers.length > 0) {
        // loop through modifiers and check for a dot modifier.attrs.type == "Dot"
        note.modifiers.forEach(modifier => {
            if(modifier.attrs.type == "Dot") {
                durationString += "d";
            }
        })
    }

    return durationString + this.convertBaseDuration(note.duration) + (note.tuplet ? 't' + note.tuplet.num_notes : '');
};

Maybe i am missing something, maybe i can help anyone else out there.

Cheers!

@sfox-developer sfox-developer changed the title vexflow DOT modifier VexFlow dotted notes not playing properly Aug 14, 2024
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