Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
16 music21/musicxml/base.py
@@ -229,6 +229,8 @@ def __init__(self):
('lyric', False, Lyric),
('syllabic', True),
('text', True),
+ ('elision', False),
+ ('extend', False),
('trill-mark', False, TrillMark),
('mordent', False, Mordent),
('inverted-mordent', False, InvertedMordent),
@@ -2579,6 +2581,7 @@ def __init__(self, number=None):
# entities
self.syllabic = None # begin, middle, end, or single
self.text = None
+ self.extend = False
def filterLyric(self, text):
'''
@@ -2599,6 +2602,7 @@ def _getComponents(self):
c.append(('syllabic', self.syllabic))
# only filter when getting components
c.append(('text', self.filterLyric(self.text)))
+ c.append(('extend', self.extend))
return c
@@ -3202,7 +3206,17 @@ def endElement(self, name):
self._mxObjs['lyric'].syllabic = self._currentTag.charData
elif name == 'text':
- self._mxObjs['lyric'].text = self._currentTag.charData
+ if self._mxObjs['lyric'].text is None:
+ self._mxObjs['lyric'].text = self._currentTag.charData
+ else:
+ self._mxObjs['lyric'].text += self._currentTag.charData
+
+ elif name == 'elision':
+ if self._mxObjs['lyric'].text is not None:
+ self._mxObjs['lyric'].text += u'\u00a0'
+
+ elif name == 'extend':
+ self._mxObjs['lyric'].extend = True
elif name == 'trill-mark':
self._mxObjs['ornaments'].append(self._mxObjs['trill-mark'])
View
2  music21/musicxml/translate.py
@@ -733,6 +733,7 @@ def lyricToMx(l):
mxLyric.set('number', l.number)
# mxl expects begin, middle, end, as well as single
mxLyric.set('syllabic', l.syllabic)
+ mxLyric.set('extend', l.extend)
return mxLyric
@@ -748,6 +749,7 @@ def mxToLyric(mxLyric, inputM21=None):
l.text = mxLyric.get('text')
l.number = mxLyric.get('number')
l.syllabic = mxLyric.get('syllabic')
+ l.extend = mxLyric.get('extend')
#-------------------------------------------------------------------------------
View
22 music21/note.py
@@ -92,13 +92,15 @@ class Lyric(music21.JSONSerializer):
'''
- def __init__(self, text=None, number=1, syllabic=None, applyRaw = False):
+ def __init__(self, text=None, number=1, syllabic=None, extend=False, applyRaw = False):
music21.JSONSerializer.__init__(self)
# these are set by _setTextAndSyllabic
self.text = None
# given as begin, middle, end, or single
self.syllabic = None
+
+ self.extend = extend
self._setTextAndSyllabic(text, applyRaw)
@@ -112,23 +114,25 @@ def jsonAttributes(self):
>>> from music21 import *
>>> l = note.Lyric()
>>> l.jsonAttributes()
- ['text', 'syllabic', 'number']
+ ['text', 'syllabic', 'number', 'extend']
'''
# do not need self._autoGatherAttributes()
# as this uses public attributes (not underscore leading)
# must explicitly define
- return ['text', 'syllabic', 'number']
+ return ['text', 'syllabic', 'number', 'extend']
def __repr__(self):
+ buf = ['music21.note.Lyric']
+ buf.append('number={}'.format(self.number))
+ if self.extend:
+ buf.append('extend')
+ if self.syllabic is not None:
+ buf.append('syllabic={}'.format(self.syllabic))
if self.text is not None:
- if self.syllabic is not None:
- return '<music21.note.Lyric number=%d syllabic=%s text="%s">' % (self.number, self.syllabic, self.text)
- else:
- return '<music21.note.Lyric number=%d text="%s">' % (self.number, self.text)
- else:
- return '<music21.note.Lyric number=%d>' % (self.number)
+ buf.append('text={}'.format(repr(self.text)))
+ return '<{}>'.format(' '.join(buf))
def _setTextAndSyllabic(self, rawText, applyRaw):

No commit comments for this range

Something went wrong with that request. Please try again.