--
--
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.
<Vexflow-Three-Voices.png>
In Dan Ringwalt MusciXML post the topic of three voices per stave came up. Rather than hi-jack that post, I decided to start a new one. Last night I decided to test vexflow to see what would happen if three voices were added to a stave. I was quite surprised at the results. In the sample below, I tried to duplicate two of the most common occurrences that I have run into. The only change to vexflow source was to comment out the 2 voice check in modifiercontext.js.
#1: Notes need to be offset to avoid collision between the voices, and stems from one voice drawing into a second voice (beat 1). The middle voice stem on beat 1 extends too far and overlaps the lower voice. There needs to be a way to shorten stems when needed.
#2: Middle voice counter melody with note in between notes of another voice that must be offset (beats 1 & 3). As you can see the notes in the middle voice were offset when needed. I wasn't expecting that, but it happened.There probably should be a bit more offset of the stems to get some separation. Also, the dot placement is not correct.
There are more cases, but these are the two most frequent. Overall, implementing three voice capability shouldn't be that difficult.
Comments welcome.
--
--
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.
As far as I know, no music editor correctly imports 3 or more voices per staff without needing human hinting, so the creators of Vexflow shouldn't be hard on themselves if it's not doing it right. The ideal result in the images currently given (though it doesn't work for everything) would be to have the middle voice use a very short stem so that the beams don't hit the third voice. It's very hard to do this right in cases where all three voices are close to each other. One of the notation books (not Behind Bars. Blanking right now) has examples of effective engraving of up to five(!) voices on a staff.
btw -- one thing that might be too late to change now, but has always bothered me a bit in Vexflow: if American English is used for duration types (w, h, q) then the American singular "staff" (where "stave" is almost never used in the singular) would be better than stave.
Mike - I thought I recognized your name. You are active in the MusicXML forum. Years ago, so was I, but have since lost my forum login information. I still get the forum emails in my Hotmail account.
As I mentioned in my original post, I agree that when possible, shortened stems should be utilized to avoid collisions. In those cases where a stem cannot be shortened to avoid collision, then a person must make a decision whether a third voice should be used at all, but rather combine two voices into one. I also agree with your stave versus staff comment, but for consistency, I use stave in vexflow communications.
Mohit - kudos to vexflow for it's ability to display three voices as well as it does. I was astonished to see the middle voice shift in both tests. I made a quick hack to the stavenote class to enable setting the stem length to something other than 35 to see what shortening stems would do, and it worked great. I agree that trying to shorten stems programmatically would probably be a challenge.
I did modify the tests to see the effect accidentals and fret hand fingers would have on the notation display. They worked like a charm. I moved the modified classes to my server, so you can view the latest tests that includes accidentals, fret hand fingers and shortened stems.
http://el-kay.com/test/vexflow/tests/voicetest.html
BTW: I did verify autobeam works as expected. If a stems direction is specified when applyAndGetBeams is called, the stem directions of all notes are correct. If no stem direction is specified it follows the notation standard stem directions depending on where in the stave the note is positioned.
--
--
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.
The shortened stems look great. I'll think of a way to expose shortened stems via VexTab.The dots look off though, don't you think?
As an aside, I ran some more experiments, and I think we could still do better with automatic rest positioning. Right now your algorithms (which are great) align them with neighboring notes. I think that we could add another formatting pass at the ModifierContext level, perhaps inside formatNotes, to shift rests vertically if they collide with other notes (or rests).
Mohit,
I think I have the dot positioning working correctly. I have no idea how to render the dots on the second and third note groups in the "Dots Basic" test. With all of those notes grouped together, there just isn't any place to render the dots on the displaced notes without overlaying the dots on the normal notes!! I added the dot tests to the three voice tests so you can see the results.
http://el-kay.com/test/vexflow/tests/voicetest.html
I believe modifiercontext.formatNotes has to be reviewed closely. All of the code is assuming only two notes, and although it seems to work with three voices, I'm not certain it will work in all instances.
Larry
--
--
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.
Larry
--
--
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,
I have recoded formatNotes for three voices. It shifts voices and shortens stems as needed. It still needs further testing, but you can view the tests at the link below. Test #1 covers different scenarios where notes must be shifted and/or stems shortened. Atlthough I would never write notation this way, I was trying for force various conditions. All of the tests in flow.html are the same.
http://el-kay.com/test/vexflow/tests/voicetest.html
http://el-kay.com/test/vexflow/tests/flow.html
One question, what is the purpose of formatNotesByY? I don't really see any advantage of using this function.
Also, as I have suspected, there is something wrong with the formatter. These tests are justified, and the separation between the eighth notes in test #1 should be the same for each pair.
This also occurs in test #2. The eighth note between beats 2 & 3 should be placed midway between the bass quarter notes.
Larry
--
--
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.
Wow, they look really good. Do you shift/shorten algorithmically, or are manual hints provided? What happens when notes are very close together and have beams?
One question, what is the purpose of formatNotesByY? I don't really see any advantage of using this function.I don't remember -- let me take a look and get back to you. I think it allows you to align multiple note heads that are on the same stave, but I'm not sure.
This is a corner case that seems to fare poorly with the current formatter. What's happening here is that the displaced note groups (e.g., the three StaveNotes on the first tick in stave 1) consume a larger width quota (the size of two notes). The same thing is happening in tick 6.The formatter has no visibility into the internals of each tick (by design), just metrics such as 'width', 'extraLeftPx', 'extraRightPx', etc. So I think we can treat the left note as a modifier and increase 'extraLeftPx' by the note width, while decreasing 'width' by the same amount. It's a bit hacky, and I think there may be cleaner ways to fix this (maybe a third formatting pass that redistributes whitespace.)
Wow, they look really good. Do you shift/shorten algorithmically, or are manual hints provided? What happens when notes are very close together and have beams?
All shifts/shortens are done algorithmically. There is no manual hinting. I did add a couple functions to stavenote to manually set stem length and force shift of the note group if ever needed, but they aren't used in the tests. I added a third test with a more complex variation of test #1 with 16th notes and voice overlap on beat 1. The second bass "B" eighth note collides with the middle voice beam, but I have no idea how to avoid that. Hopefully no one would ever code notation that looks like that.
One question, what is the purpose of formatNotesByY? I don't really see any advantage of using this function.I don't remember -- let me take a look and get back to you. I think it allows you to align multiple note heads that are on the same stave, but I'm not sure.
It would be nice to know. The function could be re-written, but I honestly don't see a need for it.
My first impression without looking at it closely was that the extraRightPx is not being maintained properly. That's what I found in the dots formatting that caused the large separation of the notes in the multi-voice test. Not sure if this is the case or not.This is a corner case that seems to fare poorly with the current formatter. What's happening here is that the displaced note groups (e.g., the three StaveNotes on the first tick in stave 1) consume a larger width quota (the size of two notes). The same thing is happening in tick 6.The formatter has no visibility into the internals of each tick (by design), just metrics such as 'width', 'extraLeftPx', 'extraRightPx', etc. So I think we can treat the left note as a modifier and increase 'extraLeftPx' by the note width, while decreasing 'width' by the same amount. It's a bit hacky, and I think there may be cleaner ways to fix this (maybe a third formatting pass that redistributes whitespace.)
--
--
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.
I think we can just just replace formatNotes with formatNotesByY and everything should work, but I'm not sure if it will break code that wants to format without a stave. (Either way, I think the requirement is probably historical and not worth supporting.)
Right, you can move pixels out of 'width' into either 'extraLeftPx' or 'extraRightPx' -- either will fix this problem.
--
--
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.
Larry
--
--
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.
I submitted the pull request. Tthree voices should be plug and play in VexTab if it currently supports more than two voices.
--
--
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.
Everything looks great so far! I'm using formatNotesByY to format notes on two staves together, so I wonder if it's possible to use the same algorithm there. I think it is necessary to use it to justify voices on multiple staves in a part
Mohit,
I am close to getting the three voice formatting with rest collision detection completed. It would have been done a week ago, but I have been ill with the flu and didn't feel good enough to work on the computer.
You can view the results at the following links:
http://el-kay.com/test/vexflow/tests/voicetest.html
http://el-kay.com/test/vexflow/tests/flow.html
There are a few tests in flow,html that are broken. I am reasonably certain that it is a function of not sorting the voices in modifiercontext.formatNotes before the new formatting is applied, so the upper voice notes are shifted rather than the lower voice. I will try to come up with a way to sort the voices so we get them in the proper order.
You can see how I modified the rest bounding boxes for rests in the Stavenote Bounding Boxes test.
The auto rest positioning tests in the first link shows a before and after comparison. The first test is basically the same as your 'Multiple Playback Instruments" sample in the your "New In My Vexflow" article, I had to move a few notes to create some rest collisions. The second test shows all possible rest combinations for three voices.
I tried to add some text above the measures to indicate the first measure shows the default rest positions and the second shows the same notes/rests with the rests shifted. Unfortunately, I couldn't find a way to enter text above the measures that spans several notes without affecting the note spacing. Any idea how to do it?
I am going to create one or more additional tests using 1/8th note and possibly 1/6th note rests to see how they fare with the new formatting.
Another thing I noticed is that not all ledger lines are drawn for rests below the staff. In the second test there are two rests on the "A" ledger line, but the "C" ledger lines are not drawn. This needs to be investigated.
--
--
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.
You can see how I modified the rest bounding boxes for rests in the Stavenote Bounding Boxes test.
Excellent! How did you get the heights?
These look excellent! Looking at the 4th tick in "auto adjust rests - three voices", should the bottom rest be slightly lower?
If you call .setWidth(0) on the text annotation, the note spacing will not be affected. Alternatively you can use the TextNote class, which gives you more positioning and formatting flexibility.
I am going to create one or more additional tests using 1/8th note and possibly 1/6th note rests to see how they fare with the new formatting.
Another thing I noticed is that not all ledger lines are drawn for rests below the staff. In the second test there are two rests on the "A" ledger line, but the "C" ledger lines are not drawn. This needs to be investigated.Ouch, I see that. Does this only happen for rests?
You can see how I modified the rest bounding boxes for rests in the Stavenote Bounding Boxes test.
Excellent! How did you get the heights?
I added upper and lower line bounds to the glyph type properties in tables.js. I was a bit surprised that the rest glyphs are not an even multiple of half-line spacing, so the bounds do extend beyond the actual glyph.
These look excellent! Looking at the 4th tick in "auto adjust rests - three voices", should the bottom rest be slightly lower?
When a middle voice stem collides with a lower voice, I chose to shorten the stem at the very beginning of the formatting. Other than at that point, there is no really good point to shorten the stem. It can always be positioned lower by manually specifying the rest position. For instance on the tickable you mentioned, specifying the rest as "G/3" would lower the rest and the shortened stem would be slightly longer.
If you call .setWidth(0) on the text annotation, the note spacing will not be affected. Alternatively you can use the TextNote class, which gives you more positioning and formatting flexibility.
I tried using textnotes and that's where I ran into the problem of the text affecting the spacing. Guess I didn't code the textnotes correctly.
The ledger lines are not drawn correctly only for rests, and it is both above and below the staff
I am going to create one or more additional tests using 1/8th note and possibly 1/6th note rests to see how they fare with the new formatting.
Another thing I noticed is that not all ledger lines are drawn for rests below the staff. In the second test there are two rests on the "A" ledger line, but the "C" ledger lines are not drawn. This needs to be investigated.Ouch, I see that. Does this only happen for rests?
--
--
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.
--
--
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.