Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ly/musicxml/create_musicxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ def add_clef(self, sign, line, nr=0, oct_ch=0):
octchnode = etree.SubElement(clefnode, "clef-octave-change")
octchnode.text = str(oct_ch)

def new_system(self, force_break):
etree.SubElement(self.current_bar, "print", new_system=force_break)

def add_barline(self, bl_type, repeat=None):
barnode = etree.SubElement(self.current_bar, "barline", location="right")
barstyle = etree.SubElement(barnode, "bar-style")
Expand Down
4 changes: 4 additions & 0 deletions ly/musicxml/ly2xml_mediator.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ def check_divs(self):
mult = get_mult(a, b)
self.divisions = divs*mult

def add_break(self):
if self.bar is None:
self.new_bar()
self.current_attr.add_break('yes')


##
Expand Down
10 changes: 6 additions & 4 deletions ly/musicxml/lymus2musxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ def __init__(self):

def parse_text(self, ly_text, filename=None):
"""Parse the LilyPond source specified as text.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file includes a number of whitespace-only changes in the commit, which you should try to avoid. As I describe in frescobaldi/frescobaldi#924 we have the problem that there are many whitespace-only lines in our codebase. It seems you use an editor that automatically removes this upon saving, and while this is generally a good thing (Frescobaldi offers this option too) it triggers "noise" in the commit.

Please configure your editor not to automatically remove such lines.
(This is not meant as criticism. It's a regular issue).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was something with my editor indeed and I already fixed it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Actually you have to "break" it to make it consistent with our state of the code base ;-) I would really prefer all the code to be without these false-empty lines.

If you specify a filename, it can be used to resolve \\include commands
correctly.

"""
doc = ly.document.Document(ly_text)
doc.filename = filename
self.parse_document(doc)

def parse_document(self, ly_doc, relative_first_pitch_absolute=False):
"""Parse the LilyPond source specified as a ly.document document.

If relative_first_pitch_absolute is set to True, the first pitch in a
\relative expression without startpitch is considered to be absolute
(LilyPond 2.18+ behaviour).

"""
# The document is copied and the copy is converted to absolute mode to
# facilitate the export. The original document is unchanged.
Expand Down Expand Up @@ -497,6 +497,8 @@ def Command(self, command):
if self.tupl_span:
self.mediator.unset_tuplspan_dur()
self.tupl_span = False
elif command.token == '\\break':
self.mediator.add_break()
else:
if command.token not in excls:
print("Unknown command:", command.token)
Expand Down
6 changes: 6 additions & 0 deletions ly/musicxml/xml_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def new_xml_bar_attr(self, obj):
"""Create bar attribute xml-nodes."""
if obj.has_attr():
self.musxml.new_bar_attr(obj.clef, obj.time, obj.key, obj.mode, obj.divs)
if obj.new_system:
self.musxml.new_system(obj.new_system)
if obj.repeat:
self.musxml.add_barline(obj.barline, obj.repeat)
elif obj.barline:
Expand Down Expand Up @@ -726,10 +728,14 @@ def __init__(self):
self.staves = 0
self.multiclef = []
self.tempo = None
self.new_system = None

def __repr__(self):
return '<{0} {1}>'.format(self.__class__.__name__, self.time)

def add_break(self, force_break):
self.new_system = force_break

def set_key(self, muskey, mode):
self.key = muskey
self.mode = mode
Expand Down