VexFlow JavaScript - Is there any way to fix multi voice with rest(r/4) not overlapping with note(c/5)?
How to bring rest not higher or lower (don't change key "r/4"). Link demo: JSFindle
Here is code demo:
// Create the notes
new VF.StaveNote( keys: ["c/4", "e/4", "g/4"], duration: "q" )
javascript xml angular frontend
add a comment |
How to bring rest not higher or lower (don't change key "r/4"). Link demo: JSFindle
Here is code demo:
// Create the notes
new VF.StaveNote( keys: ["c/4", "e/4", "g/4"], duration: "q" )
javascript xml angular frontend
add a comment |
How to bring rest not higher or lower (don't change key "r/4"). Link demo: JSFindle
Here is code demo:
// Create the notes
new VF.StaveNote( keys: ["c/4", "e/4", "g/4"], duration: "q" )
javascript xml angular frontend
How to bring rest not higher or lower (don't change key "r/4"). Link demo: JSFindle
Here is code demo:
// Create the notes
new VF.StaveNote( keys: ["c/4", "e/4", "g/4"], duration: "q" )
javascript xml angular frontend
javascript xml angular frontend
edited Jan 10 at 3:11
karel
2,25462732
2,25462732
asked Aug 22 '18 at 9:47
Thanh TranThanh Tran
2316
2316
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It's not clear what you're trying to do musically, but looking at the JSFiddle, you have 2 voices on the same stave and the rest from the first voice is overlapping with the second note from the second voice.
One voice creates the rest with this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
and another voice has a note at the same position as the rest:
new VF.StaveNote( keys: ["c/5"], duration: "h" )
Assuming that the note in the second voice is where you want it to be, you can control the vertical position of the rest in the first voice so that it doesn't overlap. You can do this by using a note letter indicating how high you want the rest to appear on the stave. For example replace this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
with this code:
new VF.StaveNote( keys: ["c/4"], duration: "qr" ),
and your rest will appear at C4 below the C5 note that it currently overlaps with.
If you don't want to change key "r/4", you could change key "c/4" to avoid the overlap.
If you really want the rest and note to appear at the same height on the stave but not overlapping, I think you will end up with something that is not readable as music, but you can always take complete control over the position of a StaveNote (either the note or the rest) by deriving your own class from StaveNote and overriding getAbsoluteX:
class FixedStaveNote extends VF.StaveNote
getAbsoluteX()
return 72;
;
(You would need to do this for both of the overlapping StaveNotes and return different values. If you only do it for the first one, the formatter will align the second one to it).
And finally if you want to control the vertical position of the rest without changing key "r/4", you could override calculateKeyProps:
class FixedStaveNote extends VF.StaveNote
calculateKeyProps()
super.calculateKeyProps();
for (let i = 0; i < this.keyProps.length; ++i)
const props = this.keyProps[i];
if (props.key === 'R')
props.line = 0;
This changes the stave line at which the rest will appear.
Here's an updated JSFiddle with no overlap using the override of calculateKeyProps.
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51964107%2fvexflow-javascript-is-there-any-way-to-fix-multi-voice-with-restr-4-not-over%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's not clear what you're trying to do musically, but looking at the JSFiddle, you have 2 voices on the same stave and the rest from the first voice is overlapping with the second note from the second voice.
One voice creates the rest with this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
and another voice has a note at the same position as the rest:
new VF.StaveNote( keys: ["c/5"], duration: "h" )
Assuming that the note in the second voice is where you want it to be, you can control the vertical position of the rest in the first voice so that it doesn't overlap. You can do this by using a note letter indicating how high you want the rest to appear on the stave. For example replace this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
with this code:
new VF.StaveNote( keys: ["c/4"], duration: "qr" ),
and your rest will appear at C4 below the C5 note that it currently overlaps with.
If you don't want to change key "r/4", you could change key "c/4" to avoid the overlap.
If you really want the rest and note to appear at the same height on the stave but not overlapping, I think you will end up with something that is not readable as music, but you can always take complete control over the position of a StaveNote (either the note or the rest) by deriving your own class from StaveNote and overriding getAbsoluteX:
class FixedStaveNote extends VF.StaveNote
getAbsoluteX()
return 72;
;
(You would need to do this for both of the overlapping StaveNotes and return different values. If you only do it for the first one, the formatter will align the second one to it).
And finally if you want to control the vertical position of the rest without changing key "r/4", you could override calculateKeyProps:
class FixedStaveNote extends VF.StaveNote
calculateKeyProps()
super.calculateKeyProps();
for (let i = 0; i < this.keyProps.length; ++i)
const props = this.keyProps[i];
if (props.key === 'R')
props.line = 0;
This changes the stave line at which the rest will appear.
Here's an updated JSFiddle with no overlap using the override of calculateKeyProps.
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
add a comment |
It's not clear what you're trying to do musically, but looking at the JSFiddle, you have 2 voices on the same stave and the rest from the first voice is overlapping with the second note from the second voice.
One voice creates the rest with this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
and another voice has a note at the same position as the rest:
new VF.StaveNote( keys: ["c/5"], duration: "h" )
Assuming that the note in the second voice is where you want it to be, you can control the vertical position of the rest in the first voice so that it doesn't overlap. You can do this by using a note letter indicating how high you want the rest to appear on the stave. For example replace this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
with this code:
new VF.StaveNote( keys: ["c/4"], duration: "qr" ),
and your rest will appear at C4 below the C5 note that it currently overlaps with.
If you don't want to change key "r/4", you could change key "c/4" to avoid the overlap.
If you really want the rest and note to appear at the same height on the stave but not overlapping, I think you will end up with something that is not readable as music, but you can always take complete control over the position of a StaveNote (either the note or the rest) by deriving your own class from StaveNote and overriding getAbsoluteX:
class FixedStaveNote extends VF.StaveNote
getAbsoluteX()
return 72;
;
(You would need to do this for both of the overlapping StaveNotes and return different values. If you only do it for the first one, the formatter will align the second one to it).
And finally if you want to control the vertical position of the rest without changing key "r/4", you could override calculateKeyProps:
class FixedStaveNote extends VF.StaveNote
calculateKeyProps()
super.calculateKeyProps();
for (let i = 0; i < this.keyProps.length; ++i)
const props = this.keyProps[i];
if (props.key === 'R')
props.line = 0;
This changes the stave line at which the rest will appear.
Here's an updated JSFiddle with no overlap using the override of calculateKeyProps.
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
add a comment |
It's not clear what you're trying to do musically, but looking at the JSFiddle, you have 2 voices on the same stave and the rest from the first voice is overlapping with the second note from the second voice.
One voice creates the rest with this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
and another voice has a note at the same position as the rest:
new VF.StaveNote( keys: ["c/5"], duration: "h" )
Assuming that the note in the second voice is where you want it to be, you can control the vertical position of the rest in the first voice so that it doesn't overlap. You can do this by using a note letter indicating how high you want the rest to appear on the stave. For example replace this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
with this code:
new VF.StaveNote( keys: ["c/4"], duration: "qr" ),
and your rest will appear at C4 below the C5 note that it currently overlaps with.
If you don't want to change key "r/4", you could change key "c/4" to avoid the overlap.
If you really want the rest and note to appear at the same height on the stave but not overlapping, I think you will end up with something that is not readable as music, but you can always take complete control over the position of a StaveNote (either the note or the rest) by deriving your own class from StaveNote and overriding getAbsoluteX:
class FixedStaveNote extends VF.StaveNote
getAbsoluteX()
return 72;
;
(You would need to do this for both of the overlapping StaveNotes and return different values. If you only do it for the first one, the formatter will align the second one to it).
And finally if you want to control the vertical position of the rest without changing key "r/4", you could override calculateKeyProps:
class FixedStaveNote extends VF.StaveNote
calculateKeyProps()
super.calculateKeyProps();
for (let i = 0; i < this.keyProps.length; ++i)
const props = this.keyProps[i];
if (props.key === 'R')
props.line = 0;
This changes the stave line at which the rest will appear.
Here's an updated JSFiddle with no overlap using the override of calculateKeyProps.
It's not clear what you're trying to do musically, but looking at the JSFiddle, you have 2 voices on the same stave and the rest from the first voice is overlapping with the second note from the second voice.
One voice creates the rest with this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
and another voice has a note at the same position as the rest:
new VF.StaveNote( keys: ["c/5"], duration: "h" )
Assuming that the note in the second voice is where you want it to be, you can control the vertical position of the rest in the first voice so that it doesn't overlap. You can do this by using a note letter indicating how high you want the rest to appear on the stave. For example replace this code:
new VF.StaveNote( keys: ["r/4"], duration: "qr" ),
with this code:
new VF.StaveNote( keys: ["c/4"], duration: "qr" ),
and your rest will appear at C4 below the C5 note that it currently overlaps with.
If you don't want to change key "r/4", you could change key "c/4" to avoid the overlap.
If you really want the rest and note to appear at the same height on the stave but not overlapping, I think you will end up with something that is not readable as music, but you can always take complete control over the position of a StaveNote (either the note or the rest) by deriving your own class from StaveNote and overriding getAbsoluteX:
class FixedStaveNote extends VF.StaveNote
getAbsoluteX()
return 72;
;
(You would need to do this for both of the overlapping StaveNotes and return different values. If you only do it for the first one, the formatter will align the second one to it).
And finally if you want to control the vertical position of the rest without changing key "r/4", you could override calculateKeyProps:
class FixedStaveNote extends VF.StaveNote
calculateKeyProps()
super.calculateKeyProps();
for (let i = 0; i < this.keyProps.length; ++i)
const props = this.keyProps[i];
if (props.key === 'R')
props.line = 0;
This changes the stave line at which the rest will appear.
Here's an updated JSFiddle with no overlap using the override of calculateKeyProps.
edited Nov 13 '18 at 12:55
answered Nov 13 '18 at 9:59
CCoderCCoder
341138
341138
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
add a comment |
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
You're awesome. Thank you.
– Thanh Tran
Nov 14 '18 at 10:38
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51964107%2fvexflow-javascript-is-there-any-way-to-fix-multi-voice-with-restr-4-not-over%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown