A rest note with default-x and default-y
In the current musicxml format on musescore 1.2, 1.3 and 2.0, it doesn't indicates the x- and y- position of the rest notes automatically. How do musescore export file in musicxml that include default-x and default-y position which can be useful for web development as in the rest node below?
< note >
< rest / >
< duration > 1 < / duration >
< voice > 1 < / voice >
< type > quarter < / type >
< / note >
to
< note default-x = " 70.00 " default-y = " 30.00 " >
< rest / >
< duration > 1 < / duration >
< voice > 1 < / voice >
< type > quarter < / type >
< / note >
Comments
In MusicXML the x and y are optional but not usual. Surely MuseSCore is behaving normally in that case? I think if you want to add x and y values that your best bet is to edit the XML file and do a Search and Replace.
In reply to In MusicXML the x and y are by underquark
I can't replace hundreds of rest notes manually, would be appreciate if someone can shows me which API code can be added with these positions.
In reply to I can't replace hundreds of by proyb2
You've been pointed to it in http://musescore.org/en/node/34346#comment-145861
In reply to You've been pointed to it in by Jojo-Schmitz
That isn't the correct answered, the code is not related to my question.
In reply to That isn't the correct by proyb2
I agree that pointing out some section of the source code dealing with this isn't very helpful, but I also suspect most people (including me) are not understanding what you are really asking for. Can you explain why having the X/Y positions in your MusicXML export are important for what you need, and show a use case or an example?
I did see in the source code that the X/Y positions are exported depending on two specific conditions, but I didn't understand what those conditions were.
In reply to I agree that pointing out by schepers
Sorry, to clarify, when I have exported musicxml, the whole, half, quarter, eighth, 16th, 32th notes did include default-x and default-y element except the rests notes.
I'll be using to rendering notes by notes on a web page without having to calculate the position manually and that has been a problem to set a precise positioning when rendering a complex score.
For which is missing:
http://i59.tinypic.com/qzgbhc.jpg
In reply to That isn't the correct by proyb2
Not sure what you mean., As with others, I am not understanding why having default x & y values is important to you - any program that understands MusicXML should be perfectly capable of placing rests correctly without MuseScore telling it where to place them.
EDIT sorry, I see now, you are writing your own program. OK, in that case, you may indeed want to build your own special vesion of MuseScore to save you the trouble.
In which case, the code in those links is *exactly* what you need. The first link shows you the exact function where rests are exported. That is the function you would need to modify. The second link shows you exactly how you would need to modify it, by showing you how MsueScore does the same thing with notes. Simply copy/adapt the code from the second function to the first and that should do it.
In reply to Not sure what you mean., As by Marc Sabatella
See also #34451: Include default-x and default-y for Rests
In reply to Not sure what you mean., As by Marc Sabatella
Ok, I can try with lack of programming skill in Qt.
From what I have read the code, as it seems this line look incorrect:
https://github.com/musescore/MuseScore/blob/bdbaf5a27e8b45f1f193303fd35…
Line 278:
void rest(Rest* chord, int staff)
should be:
void rest(Rest* rest, int staff);
In the function scope Line 2128:
void ExportMusicXml::chord(Chord* chord, int staff, const QList* ll, DrumsetKind useDrumset)
foreach(Note* note, nl) {...}
where is the "note" variable refer from or it should have been chord instead?
foreach(Note* chord, nl) {...}
What else should I take note?
In reply to Ok, I can try with lack of by proyb2
It might indeed be better in 278 to call the parameter "rest" instead of "chord", but it doesn't really matter - it works the same no matter what you call it.
The "note" variable in the "foreach" loop is declared right there - that;'s why it says "Note* note" rather than just "note". Again, it doesn't really matter what it is called.
In reply to It might indeed be better in by Marc Sabatella
Alright, added a part of the code in bold, will it be safe to comment out foreach?
void ExportMusicXml::rest(Rest* rest, int staff)
{
static char table2[] = "CDEFGAB";
#ifdef DEBUG_TICK
qDebug("ExportMusicXml::rest() oldtick=%d", tick);
#endif
QList nl = rest->notes();
const PageFormat* pf = _score->pageFormat();
const double pageHeight = getTenthsFromInches(pf->size().height());
//foreach(Note* rest, nl) {
QString val;
attr.doAttr(xml, false);
QString noteTag = QString("note");
if (preferences.musicxmlExportLayout && pf) {
double measureX = getTenthsFromDots(rest->measure()->pagePos().x());
double measureY = pageHeight - getTenthsFromDots(rest->measure()->pagePos().y());
double noteX = getTenthsFromDots(note->pagePos().x());
double noteY = pageHeight - getTenthsFromDots(note->pagePos().y());
noteTag += QString(" default-x=\"%1\"").arg(QString::number(noteX - measureX,'f',2));
noteTag += QString(" default-y=\"%1\"").arg(QString::number(noteY - measureY,'f',2));
}
//}
if (!rest->visible() ) {
noteTag += QString(" print-object=\"no\"");
}
xml.stag(noteTag);
In reply to Alright, added a part of the by proyb2
It's a good start. You can compile MuseScore and test. See http://musescore.org/en/developers-handbook/compilation
As I said earlier, you will need to explain the interaction between
default-y
anddisplay-step
anddisplay-octave
.In reply to It's a good start. You can by [DELETED] 5
Two remarks:
When MuseScore exports positioning information for notes, it should also do it for rests. I consider it a bug to be solved that default-x and -y are exported for notes but not for rests.
Having said that, I highly doubt the value of exporting default-y, both for notes and rests: I expect this to be ignored on import as notes are positioned vertically implicitly based on pitch, and rests are either at a default position or positioned explicitly using display-step and -octave. I cannot imagine a scenario where note or rest y position should be changed by default-y. Note that MuseScore has been exporting default-y for notes at least since 1.2, without obvious ill effects.
In reply to Two remarks: When MuseScore by Leon Vinken
Just wonder has this bug been fixed? It would be great if next version handles it.
Just tried both xml exported from client MS and download from web, and find rest notes have no default-x.
Background: I am translating notes from standard to simplified (most Chinese instrument use). Parsing xml gives me a short cut to deal with engraving headaches (example attached for those who have not seen simplified sheet before).
Finale (2011 the version I use) export to 1.0, 1.1, 2.0 xml, all rest notes have default-x.
Thanks,
Joe
In reply to Just wonder has this bug been by joeliatc
Nope, 2.0 didn't even have it by default, you still have to add the coding and compile it. It works flawlessly.
In reply to Nope, 2.0 didn't even have it by proyb2
If you did the coding and tested it, please submit a pull request on github so we can integrate the fix in the next version of MuseScore. See https://musescore.org/en/developers-handbook/git-workflow