Browse Source

various small stuff. typos etc.

master
Nils 4 years ago
parent
commit
cdb24b13dd
  1. 4
      engine/api.py
  2. 7
      engine/block.py
  3. 1
      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""" Recursive commands are not allowed"""
global topLevelFunction #todo: replace with a python-context global topLevelFunction #todo: replace with a python-context
if not topLevelFunction: if not topLevelFunction:
topLevelFunction = function topLevelFunction = function
if autoStepLeft and session.data.currentTrack().state.isAppending(): if autoStepLeft and session.data.currentTrack().state.isAppending():
session.data.currentTrack().left() session.data.currentTrack().left()
@ -2266,7 +2266,7 @@ def pedalNotes(pedalDuration):
return False return False
newParts = int(self.durationGroup.baseDuration / pedalDuration) newParts = int(self.durationGroup.baseDuration / pedalDuration)
if not newParts >= 2: if newParts < 2:
return False return False
originalPitches = self.notelist #keep the actual list, not only the contents originalPitches = self.notelist #keep the actual list, not only the contents
keysig = session.data.currentTrack().state.keySignature() keysig = session.data.currentTrack().state.keySignature()

7
engine/block.py

@ -145,7 +145,7 @@ class Block(object):
@parentTrack.setter @parentTrack.setter
def parentTrack(self, newTrack): def parentTrack(self, newTrack):
if not self._parentTrack: #because it was None/not in a track if not self._parentTrack: #because it was None/not in a track
self._parentTrack = WeakSet() self._parentTrack = WeakSet()
if newTrack: if newTrack:
self._parentTrack = weakref_ref(newTrack) self._parentTrack = weakref_ref(newTrack)
else: else:
@ -341,10 +341,7 @@ class Block(object):
return result return result
def isAppending(self): 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 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
def lilypond(self, carryLilypondRanges): def lilypond(self, carryLilypondRanges):
"""Called by track.lilypond(), returns a string. """Called by track.lilypond(), returns a string.

1
engine/cursor.py

@ -129,7 +129,6 @@ class Cursor:
"dotOnLine": self.asDotOnLine(trackState.clef()), "dotOnLine": self.asDotOnLine(trackState.clef()),
"pitch" : self.pitchindex, "pitch" : self.pitchindex,
"lilypondPitch" : pitch.pitch2ly[self.pitchindex], "lilypondPitch" : pitch.pitch2ly[self.pitchindex],
"position" : trackState.position(),
"appending" : trackState.isAppending(), "appending" : trackState.isAppending(),
"blockindex" : trackState.blockindex, "blockindex" : trackState.blockindex,
"block" : block, "block" : block,

47
engine/items.py

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

2
engine/track.py

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

Loading…
Cancel
Save