whole rest rendered one line lower than expected?

119 views
Skip to first unread message

Martin Chen

unread,
May 22, 2013, 11:58:38 AM5/22/13
to vex...@googlegroups.com
First of all, I don't really know much about music theory and I'm new to VexFlow. So please let me know if I have misunderstood anything.

In all the musical notation software I have tried to use, rests are by default rendered at the following positions:

Now I'm trying to respect the *default* positions of rests using VexFlow. For all but the whole rest, I found that VexFlow would just render them at the desired positions if I specify the key as "b/4" (treble clef). But for whole rest, it is rendered one line lower.

My code is here:

var stave1 = new Vex.Flow.Stave(0, 0, 150),
    stave2 = new Vex.Flow.Stave(150, 0, 300),
    notes1 = [
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "wr" })
    ],
    notes2 = [
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "hr" }),
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "qr" }),
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "8r" }),
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "16r" }),
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "32r" }),
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "64r" }),
        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "64r" })
    ];
stave1.setContext(ctx).draw();
stave2.setContext(ctx).draw();
Vex.Flow.Formatter.FormatAndDraw(ctx, stave1, notes1);
Vex.Flow.Formatter.FormatAndDraw(ctx, stave2, notes2);

I suspect this is a bug or improper design. Because it is inconsistent. Also I tested this in MusicXML & Finale. When I set the display step and octave of rest to b/4 and import the MusicXML to Finale, it is rendered just as expected. But when I set it to d/5, which is rendered at the desired position in VexFlow, it is rendered one line upper.


Could someone please explain this and let me know if it would be fixed someday in the future? Actually I'm fine to follow the behavior of VexFlow and instead do some work in my own code. But my concern is my app may fail if the behavior were to change in the future.

By the way, I have another question. As in my VexFlow test above, the single whole rest is rendered at the left side of the staff. How can I make it center aligned?

Great thanks in advance!
MusicXML-sample.xml

Mohit Muthanna

unread,
May 22, 2013, 12:56:54 PM5/22/13
to vex...@googlegroups.com
Try setting the note to "r/4" instead of "b/4".

Mohit.


--
--
You received this message because you are subscribed to the Google
Groups "vexflow" group.
To post to this group, send email to vex...@googlegroups.com
To unsubscribe from this group, send email to
vexflow+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/vexflow?hl=en
 
---
You received this message because you are subscribed to the Google Groups "vexflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vexflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Mohit Muthanna [mohit (at) muthanna (uhuh) com]

Martin Chen

unread,
May 22, 2013, 11:15:26 PM5/22/13
to vex...@googlegroups.com, mo...@muthanna.com
Thanks Mohit. But I get the same result...? I tried this in the VexFlow Sandbox.

Richard Gonski

unread,
May 25, 2013, 7:09:00 AM5/25/13
to vex...@googlegroups.com, mo...@muthanna.com
Try setting the whole note rest to D5 - this will put it in the right place.

As far as centering the whole note rest - you are right - it should be centered usually, but not always - it is dependent on the time signature. In 4/4 it should be centered, but in 5/5 or larger it wouldn't, and at the moment, as far as I am aware, rests do not take the time signature into account.

Regards,

Richard Gonski

Martin Chen

unread,
May 26, 2013, 6:31:59 AM5/26/13
to vex...@googlegroups.com, mo...@muthanna.com
Well, I know I can set it to D5. But that's not consistent, right? Any app that wants to support the positioning of rests will have to hack (move up 2 steps for whole rest) in order to get it right.

I saw this in wiki:
"When an entire bar is devoid of notes, a whole (semibreve) rest is used, regardless of the actual time signature."

So I think I should always render a centered whole rest when I saw a full-measure rest.

Mohit Muthanna

unread,
May 26, 2013, 7:38:47 AM5/26/13
to vex...@googlegroups.com
If "r/4" didn't work, then this is likely a bug. Can you try the formatter's automatic rest positioning to see if it'll fix it?

    formatter.formatToStave(format_voices, format_stave, {align_rests: true})

Mohit.

Martin Chen

unread,
May 26, 2013, 9:36:51 AM5/26/13
to vex...@googlegroups.com, mo...@muthanna.com
Unfortunately, it doesn't seem to fix it.

My code:
var stave = new Vex.Flow.Stave(0, 0, 150),
    note = new Vex.Flow.StaveNote({ keys: ["r/4"], duration: "wr" }),
    voice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).addTickable(note);

var formatter = new Vex.Flow.Formatter().
    joinVoices([voice], {align_rests: true}).
    formatToStave([voice], stave, {align_rests: true});

stave.setContext(ctx).draw();
voice.draw(ctx, stave);

Mohit Muthanna

unread,
May 26, 2013, 10:06:13 AM5/26/13
to vex...@googlegroups.com

Thanks for testing. If you don't mind, please file a bug so I can track this.

Martin Chen

unread,
May 26, 2013, 12:03:50 PM5/26/13
to vex...@googlegroups.com, mo...@muthanna.com
Sure, I will. Thanks!
Reply all
Reply to author
Forward
0 new messages