-
Notifications
You must be signed in to change notification settings - Fork 433
FretBend supports alter (interval), prebend, and release #1580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 97 commits
03fdb47
aca37e2
7118189
766a113
17bc30d
4bcdffc
274c904
0fdac57
6d778f1
7e6ced8
ef52fe0
e3f88ee
f1eae7d
22d07da
c157a53
67540ea
34ecc42
13ac21f
9c3b1a3
0839230
cd534fe
b1c9277
caa8bd2
a21d3f6
7855e26
b95c2c0
97297be
3d5092a
e45f7b8
4f07cbb
97e33a0
edf7934
27974be
3cf71e0
d63c78a
03e6117
85cc6a8
c11ce14
d93af6d
2e1ea43
58eeb04
0b2074f
f215c8c
e4499dc
0ba3f33
32d5135
030935a
a40c9d6
4938f1e
ded5058
bb8ab1d
4c5d96d
6646a04
640f051
5ab284d
30c2a85
8262559
e36d0ff
5cf8b7d
63b9df5
5dc55d9
11b6e7e
ba04559
b2bd258
04d369e
8ef43f0
43e9277
38c0d61
adc65e3
1420a42
3ee1fba
2773315
467317b
dae3be6
5c3b870
60fcfed
2c41586
96782de
e7e0db3
d768834
099df36
f74771b
95e00d7
2afc440
f7cb7c2
f0d27f8
d651fbd
15eadd1
de0c20d
ec04053
28b8372
c5b04cc
daa6848
b0b66aa
e3749de
4c585ea
91e9f84
a79a6dc
51e8ee5
d4e175d
9879148
b39ea71
243f3b6
9a17ec8
3fc5849
d1ff663
d021fed
2447e4e
7e8a800
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5473,11 +5473,18 @@ def articulationToXmlTechnical(self, articulationMark: articulations.Articulatio | |
| >>> mxOther = MEX.articulationToXmlTechnical(g) | ||
| >>> MEX.dump(mxOther) | ||
| <other-technical>unda maris</other-technical> | ||
|
|
||
| Same with technical marks not yet supported. | ||
| TODO: support HammerOn, PullOff, Hole, Arrow. | ||
|
|
||
| >>> h = articulations.HammerOn() | ||
| >>> mxOther = MEX.articulationToXmlTechnical(h) | ||
| >>> MEX.dump(mxOther) | ||
| <other-technical /> | ||
| ''' | ||
| # these technical have extra information | ||
| # TODO: hammer-on | ||
| # TODO: pull-off | ||
| # TODO: bend | ||
| # TODO: hole | ||
| # TODO: arrow | ||
| musicXMLTechnicalName = None | ||
|
|
@@ -5489,7 +5496,7 @@ def articulationToXmlTechnical(self, articulationMark: articulations.Articulatio | |
| musicXMLTechnicalName = 'other-technical' | ||
|
|
||
| # TODO: support additional technical marks listed above | ||
| if musicXMLTechnicalName in ('bend', 'hole', 'arrow'): | ||
| if musicXMLTechnicalName in ('hole', 'arrow'): | ||
| musicXMLTechnicalName = 'other-technical' | ||
|
|
||
| mxTechnicalMark = Element(musicXMLTechnicalName) | ||
|
|
@@ -5523,7 +5530,8 @@ def articulationToXmlTechnical(self, articulationMark: articulations.Articulatio | |
| if t.TYPE_CHECKING: | ||
| assert isinstance(articulationMark, articulations.FretIndication) | ||
| mxTechnicalMark.text = str(articulationMark.number) | ||
|
|
||
| if musicXMLTechnicalName == 'bend': | ||
| self.setBend(mxTechnicalMark, articulationMark) | ||
| # harmonic needs to check for whether it is artificial or natural, and | ||
| # whether it is base-pitch, sounding-pitch, or touching-pitch | ||
| if musicXMLTechnicalName == 'harmonic': | ||
|
|
@@ -5539,6 +5547,63 @@ def articulationToXmlTechnical(self, articulationMark: articulations.Articulatio | |
| # mxArticulations.append(mxArticulationMark) | ||
| return mxTechnicalMark | ||
|
|
||
| @staticmethod | ||
| def setBend(mxh: Element, bend: articulations.FretBend) -> None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks great! |
||
| ''' | ||
| Sets the bend-alter SubElement and the pre-bend, | ||
| release and with-bar SubElements when present. | ||
|
|
||
| Called from articulationToXmlTechnical | ||
|
|
||
| >>> MEXClass = musicxml.m21ToXml.MeasureExporter | ||
|
|
||
| >>> a = articulations.FretBend(bendAlter=interval.Interval(2)) | ||
|
|
||
| >>> from xml.etree.ElementTree import Element | ||
| >>> mxh = Element('bend') | ||
|
|
||
| >>> MEXclass.setbend(mxh, a) | ||
| >>> MEXclass.dump(mxh) | ||
| <bend> | ||
| <bend-alter>2</bend-alter> | ||
| </bend> | ||
| >>> a.pre-bend = True | ||
adhooge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| >>> MEXclass.setbend(mxh, a) | ||
| >>> MEXclass.dump(mxh) | ||
| <bend> | ||
| <bend-alter>2</bend-alter> | ||
| <pre-bend/> | ||
| </bend> | ||
| >>> a = articulations.FretBend(bendAlter=interval.Interval(-2), release=OffsetQL(1, 10080)) | ||
| >>> MEXclass.setbend(mxh, a) | ||
| >>> MEXclass.dump(mxh) | ||
| <bend> | ||
| <bend-alter>-2</bend-alter> | ||
| <release offset='1'> | ||
| </bend> | ||
| >>> a = articulations.FretBend(bendAlter=interval.Interval(-2), withBar='scoop') | ||
| >>> MEXclass.setbend(mxh, a) | ||
| >>> MEXclass.dump(mxh) | ||
| <bend> | ||
| <bend-alter>1</bend-alter> | ||
| <with-bar>scoop</with-bar> | ||
| </bend> | ||
| ''' | ||
| bendAlterSubElement = SubElement(mxh, 'bend-alter') | ||
| alter = bend.bendAlter | ||
| if alter is not None: | ||
| bendAlterSubElement.text = str(alter.semitones) | ||
| if bend.preBend: | ||
| SubElement(mxh, 'pre-bend') | ||
| if bend.release is not None: | ||
| releaseSubElement = SubElement(mxh, 'release') | ||
| quarterLengthValue = bend.release | ||
| divisionsValue = int(defaults.divisionsPerQuarter * quarterLengthValue) | ||
| releaseSubElement.set('offset', str(divisionsValue)) | ||
| if bend.withBar is not None: | ||
| withBarSubElement = SubElement(mxh, 'with-bar') | ||
| withBarSubElement.text = str(bend.withBar) | ||
|
|
||
| @staticmethod | ||
| def setHarmonic(mxh: Element, harm: articulations.StringHarmonic) -> None: | ||
| # noinspection PyShadowingNames | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,8 +71,7 @@ | |
| # in method objectAttachedSpannersToTechnicals of m21ToXml.py | ||
| # ('hammer-on', articulations.HammerOn), | ||
| # ('pull-off', articulations.PullOff), | ||
| # bend not implemented because it needs many subcomponents | ||
| # ('bend', articulations.FretBend), | ||
| ('bend', articulations.FretBend), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line appears to be added twice? (see line 70)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, I might have had issues with merging new changes and the commented lines. Fixed with 91e9f84 |
||
| ('tap', articulations.FretTap), | ||
| ('fret', articulations.FretIndication), | ||
| ('heel', articulations.OrganHeel), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.