A rest note with default-x and default-y

• Sep 24, 2014 - 18:54

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 >
< note default-x = " 70.00 " default-y = " 30.00 " >
< rest / >
< duration > 1 < / duration >
< voice > 1 < / voice >
< type > quarter < / type >
< / note >


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 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 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:

In reply to 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 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:

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 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 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";
qDebug("ExportMusicXml::rest() oldtick=%d", tick);

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\"");

In reply to by Nicolas

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 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.


Attachment Size
Mary Did You Know - PTX Version 1.jpg 87.54 KB

Do you still have an unanswered question? Please log in first to post your question.