Browse Source

various small stuff. typos etc.

master
Nils 3 years ago
parent
commit
cdb24b13dd
  1. 4
      engine/api.py
  2. 7
      engine/block.py
  3. 7
      engine/cursor.py
  4. 47
      engine/items.py
  5. 2
      engine/track.py

4
engine/api.py

@ -344,7 +344,7 @@ def simpleCommand(function, autoStepLeft = True, forceReturnToItem = None):
Recursive commands are not allowed"""
global topLevelFunction #todo: replace with a python-context
if not topLevelFunction:
topLevelFunction = function
topLevelFunction = function
if autoStepLeft and session.data.currentTrack().state.isAppending():
session.data.currentTrack().left()
@ -2266,7 +2266,7 @@ def pedalNotes(pedalDuration):
return False
newParts = int(self.durationGroup.baseDuration / pedalDuration)
if not newParts >= 2:
if newParts < 2:
return False
originalPitches = self.notelist #keep the actual list, not only the contents
keysig = session.data.currentTrack().state.keySignature()

7
engine/block.py

@ -145,7 +145,7 @@ class Block(object):
@parentTrack.setter
def parentTrack(self, newTrack):
if not self._parentTrack: #because it was None/not in a track
self._parentTrack = WeakSet()
self._parentTrack = WeakSet()
if newTrack:
self._parentTrack = weakref_ref(newTrack)
else:
@ -341,10 +341,7 @@ class Block(object):
return result
def isAppending(self):
if self.localCursorIndex == len(self.data): #len counts from 1 and the cursorIndex from 0. So if they are the same we are one cursor position right of last item
return True
else:
return False
return self.localCursorIndex == len(self.data) #len counts from 1 and the cursorIndex from 0. So if they are the same we are one cursor position right of last item
def lilypond(self, carryLilypondRanges):
"""Called by track.lilypond(), returns a string.

7
engine/cursor.py

@ -97,15 +97,15 @@ class Cursor:
else:
return 0
def distanceInDiatonicStepsFromTrebleB(self):
def distanceInDiatonicStepsFromTrebleB(self):
return pitch.distanceInDiatonicSteps(pitch.ly2pitch["b'"], self.pitchindex) #offset from the middle line in treble clef h', which is 0. c'' is -1, a' is +1
def asDotOnLine(self, clef):
return self.distanceInDiatonicStepsFromTrebleB() + clef.asDotOnLineOffset
def exportObject(self, trackState):
"""Every time the cursor moves this will be called.
"""Every time the cursor moves this will be called.
return a dict which is a good layout
export basis. For example for GUI frontends. They don't have to
parse and calculate their own values in slow pure Python then.
@ -129,7 +129,6 @@ class Cursor:
"dotOnLine": self.asDotOnLine(trackState.clef()),
"pitch" : self.pitchindex,
"lilypondPitch" : pitch.pitch2ly[self.pitchindex],
"position" : trackState.position(),
"appending" : trackState.isAppending(),
"blockindex" : trackState.blockindex,
"block" : block,

47
engine/items.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Copyright 2020, Nils Hilbricht, Germany ( https://www.hilbricht.net )
@ -657,29 +656,29 @@ class DurationGroup(object):
def createChordOrRest(completeDuration, pitchlist, velocityModification):
"""Return a Chord or Rest instance.
The complete duration is the absolute duration after
dots, tuplets etc. e.g. generated by midi in.
Pitchlist can also be empty then it generates rests. But you
have to explicitely set it to empty.
This is used by the pattern generator which supports both
rests and chords and works by absolute durations.
"""
"""Return a Chord or Rest instance.
The complete duration is the absolute duration after
dots, tuplets etc. e.g. generated by midi in.
Pitchlist can also be empty then it generates rests. But you
have to explicitely set it to empty.
This is used by the pattern generator which supports both
rests and chords and works by absolute durations.
"""
durationObject = Duration.createByGuessing(completeDuration)
dynamic = Dynamic()
dynamic.velocityModification = velocityModification
if pitchlist: #chord
new = Chord(firstDuration=durationObject, firstPitch=pitchlist[0])
for pitch in pitchlist[1:]:
new.addNote(pitch)
for note in new.notelist:
note.dynamic = dynamic.copy()
else:
new = Rest(durationObject)
durationObject = Duration.createByGuessing(completeDuration)
dynamic = Dynamic()
dynamic.velocityModification = velocityModification
if pitchlist: #chord
new = Chord(firstDuration=durationObject, firstPitch=pitchlist[0])
for pitch in pitchlist[1:]:
new.addNote(pitch)
for note in new.notelist:
note.dynamic = dynamic.copy()
else:
new = Rest(durationObject)
return new
return new
class Item(object):
@ -2829,6 +2828,8 @@ class ChannelChange(Item):
else:
return ""
#Note in use.
class RecordedNote(Item):
"""An intermediate item that gets created by the live recording process.
It has no Duration instance but a simple tick duration instead.
@ -2840,7 +2841,7 @@ class RecordedNote(Item):
def __init__(self, itemData):
"""Either init gets called, by creation during runtime, or instanceFromSerializedData.
That means everything in init must be matched by a loading call in instanceFromSerializedData."""
super().__init__(positionInTicks, durationInTicks )
super().__init__(positionInTicks, durationInTicks ) #TODO: that is not super._init of item. Item has no parameters!
self.positionInTicks = positionInTicks
self.durationInTicks = durationInTicks

2
engine/track.py

@ -410,7 +410,7 @@ class Track(object):
def hidden(self):
"""Is this editable or read-only (and not shown in a possible GUI).
hidden still emits playback and exports to other formats"""
return not self in self.score.tracks
return not self in self.parentData.tracks
@property
def name(self):

Loading…
Cancel
Save