Browse Source

Fix wrong beaming stems for chords

master
Nils 4 years ago
parent
commit
e655044f7e
  1. 2
      engine/items.py
  2. 9
      engine/track.py
  3. 11
      qtgui/items.py
  4. 6
      qtgui/musicstructures.py

2
engine/items.py

@ -1693,7 +1693,7 @@ class Chord(Item):
"beamGroup" : self.beamGroup, #bool
"midiBytes" : midiBytesList,
"midiChannelOffset" : self.midiChannelOffset,
"beam" : tuple(), #decided later in structures export. Has the same structure as a stem.
"beam" : tuple(), #decided later in track export. Has the same structure as a stem.
}
def _lilypond(self):

9
engine/track.py

@ -1120,14 +1120,14 @@ class Track(object):
if sum(s[2] for s in stems) >= 0: #beam upwards direction
direction = 1
length = -5
beamPosition = minimum + length
startDotOnLineKeyword = "highestPitchAsDotOnLine"
beamPosition = minimum + length - 1 #if not -1 it will be the same as the highest note, in wide intervals
startDotOnLineKeyword = "lowestPitchAsDotOnLine"
#assert beamPosition <= 0
else: #beam down direction
length = 5
beamPosition = maximum + length
beamPosition = maximum + length + 2 #if not +2 it will be in the position of lowest note, in wide intervals
direction = -1
startDotOnLineKeyword = "lowestPitchAsDotOnLine"
startDotOnLineKeyword = "highestPitchAsDotOnLine"
#assert beamPosition > 0
#beams have the same syntax and structure as a stem.
@ -1144,7 +1144,6 @@ class Track(object):
currentSubGroupFlag = obj["flag"]
subBeamGroups[-1].append(obj)
for subBeamGroup in subBeamGroups:
for obj in subBeamGroup:
startStaffLine = obj[startDotOnLineKeyword]

11
qtgui/items.py

@ -440,11 +440,20 @@ class GuiChord(GuiItem):
else:
stemOrBeam = self.staticItem["stem"]
#stem[2] is left/-1 or right/1 stem shifting.
#stemOrBeam = (starting point, length, direction) #0 is middle line, but the stem for 0 begins at -1, which is the room above.
#2 is treble-g which stem begins at 1.
#negative numbers are above the middle line with the same -1 stem offset, compared to the note.
#These numbers are calculated by the backend to span the whole chord. We just need to draw the stem here.
#For beam groups the length is different for each member because they get shorter/longer with each ascending/descending note
if stemOrBeam and stemOrBeam[2] > 0:
self.directionRightAndUpwards = False
else:
self.directionRightAndUpwards = True
print (stemOrBeam)
#Stem - Both for groups and standalone.
if stemOrBeam: #may be an empty tuple for whole notes and brevis
line = QtWidgets.QGraphicsLineItem(QtCore.QLineF(0, constantsAndConfigs.stafflineGap * stemOrBeam[1]/2, 0, 0)) #x1, y1, x2, y2
@ -461,7 +470,7 @@ class GuiChord(GuiItem):
self.flag = flag #store as persistent item. Otherwise qt will delete it.
flag.setPos(self.stem.pos().x(), self.stem.line().p1().y() + self.stem.pos().y()) #we already know where the stem-line is.
#Check if this item is the start or end of a beam group and mark it with lilypond syntax
#Check if this item is the start or end of a beam group and mark it with a textitem (lilypond syntax [ ])
if self.staticItem["beamGroup"]:
if self.staticItem["beamGroup"] == "open":
beamGroupGlyph = QtWidgets.QGraphicsSimpleTextItem("[")

6
qtgui/musicstructures.py

@ -360,6 +360,9 @@ class GuiTrack(QtWidgets.QGraphicsItem):
def createBeams(self, beamList):
"""This creates the beam-rectangle above/below the stems.
The stems theselves are created in items.py"""
for b in self.beams:
self.parentScore.removeWhenIdle(b)
self.beams = []
@ -378,7 +381,7 @@ class GuiTrack(QtWidgets.QGraphicsItem):
#non-scalable X-Offsets are not possible via setPos. zoom and stretch go haywire.
#Instead we use one item for strechting and for the offset position and wrap it in an item group that is used for positioing.
#Instead we use one item for streching for the offset position and wrap it in an item group that is used for positioing.
shifterAnchor = QtWidgets.QGraphicsItemGroup()
shifterAnchor.setParentItem(self)
@ -389,6 +392,7 @@ class GuiTrack(QtWidgets.QGraphicsItem):
shifterAnchor.rectangle = rectangle
rectangle.setPos(xOffset, 0)
#We need the beam no matter the note head mode.
if constantsAndConfigs.noteHeadMode:
rectangle.show()
else:

Loading…
Cancel
Save